if using 2.07+ use the 1 from https://www.torrenttrader.org/topic/9584-mod-contact-staff/page__st__40#entry83880 and change the class to well your class level you want to access it.. about as far as i will help for an bugged version 2.07
CREATE TABLE IF NOT EXISTS `staffmessages` (
`id` int(10) unsigned NOT NULL auto_increment,
`sender` int(10) unsigned NOT NULL default '0',
`added` datetime default NULL,
`msg` text,
`subject` varchar(100) NOT NULL default '',
`answeredby` int(10) unsigned NOT NULL default '0',
`answered` tinyint(1) NOT NULL default '0',
`answer` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
<td align="center"><a href="staffbox.php"><img src="images/admin/contact.png" border="0" width="32" height="32" alt="" /><br /><?php echo T_("STAFF_CONTACT"); ?></a><br /></td>
echo "<li><a href='contactstaff.php'>".T_("CONTACT_STAFF")."</a></li>";
CREATE TABLE IF NOT EXISTS `staffmessages` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`sender` INT UNSIGNED NOT NULL DEFAULT 0,
`added` DATETIME NULL DEFAULT NULL,
`msg` TEXT NULL,
`subject` VARCHAR(100) NOT NULL DEFAULT '',
`answeredby` INT UNSIGNED NOT NULL DEFAULT 0,
`answered` TINYINT(1) NOT NULL DEFAULT 0,
`answer` TEXT NULL,
KEY `answered` (`answered`)
) ENGINE=MyISAM;<?php
// Contact Staff: members write to the staff. Handled by takecontact.php and answered in staffbox.php.
// Hack by MasterRoot, edited for TorrentTrader by foz, with fixes from the community. Updated for PHP 8.
require_once("backend/functions.php");
dbconn();
loggedinonly();
stdhead(T_("SC_TITLE"));
begin_frame(T_("SC_TITLE"));
?>
<p><?php echo T_("SC_INTRO"); ?></p>
<form method="post" action="takecontact.php">
<p><label><?php echo T_("SC_SUBJECT"); ?><br /><input type="text" name="subject" size="60" maxlength="100" required /></label></p>
<p><label><?php echo T_("SC_MESSAGE"); ?><br /><textarea name="msg" rows="12" style="width:100%" required></textarea></label></p>
<input type="submit" value="<?php echo T_("SC_SEND"); ?>" />
</form>
<?php
end_frame();
stdfoot();
?><?php
// Contact Staff: saves a member's message for the staff. Updated for PHP 8.
require_once("backend/functions.php");
dbconn();
loggedinonly();
if ($_SERVER["REQUEST_METHOD"] !== "POST") {
header("Location: contactstaff.php");
exit;
}
$subject = trim((string) ($_POST["subject"] ?? ""));
$msg = trim((string) ($_POST["msg"] ?? ""));
if ($subject === "" || $msg === "") {
show_error_msg(T_("ERROR"), T_("SC_FILL_IN_BOTH"), 1);
}
$sender = (int) $CURUSER["id"];
$subject = substr($subject, 0, 100);
// a double click or page refresh does not send it twice
$since = get_date_time(time() - 600);
$same = mysqli_fetch_row(SQL_Query_exec("SELECT COUNT(*) FROM staffmessages WHERE sender = $sender AND subject = " . sqlesc($subject) . " AND added > '$since'"));
if (!$same || (int) $same[0] === 0) {
SQL_Query_exec("INSERT INTO staffmessages (sender, added, msg, subject) VALUES ($sender, '" . get_date_time() . "', " . sqlesc($msg) . ", " . sqlesc($subject) . ")");
}
autolink("index.php", T_("SC_SENT"));
?><?php
//===========================================================================
// DO NOT EDIT THIS OUT
// Created by foz www.basslinebeats.co.uk foz@basslinebeats.co.uk
// Based on the hack by MasterRoot. Updated for PHP 8.
//===========================================================================
require_once("backend/functions.php");
dbconn();
loggedinonly();
// lowest class that can read and answer messages to the staff
const SC_STAFF_CLASS = 5;
if ((int) get_user_class() < SC_STAFF_CLASS) {
show_error_msg(T_("ERROR"), T_("SC_NOT_ALLOWED"), 1);
}
function sc_e($value) {
return htmlspecialchars((string) $value, ENT_QUOTES);
}
function sc_user($id, $name) {
return $name !== null ? "<a href='account-details.php?id=" . (int) $id . "'><b>" . sc_e($name) . "</b></a>" : "-";
}
function sc_ids($value) {
return array_values(array_filter(array_map("intval", (array) $value)));
}
// ---- form actions
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$staff = (int) $CURUSER["id"];
$do = (string) ($_POST["do"] ?? "");
if ($do === "answer") {
$id = (int) ($_POST["id"] ?? 0);
$answer = trim((string) ($_POST["answer"] ?? ""));
$row = mysqli_fetch_assoc(SQL_Query_exec("SELECT m.*, u.username FROM staffmessages m LEFT JOIN users u ON u.id = m.sender WHERE m.id = $id"));
if (!$row || $answer === "") show_error_msg(T_("ERROR"), T_("SC_FILL_IN_ANSWER"), 1);
SQL_Query_exec("UPDATE staffmessages SET answered = 1, answeredby = $staff, answer = " . sqlesc($answer) . " WHERE id = $id");
if ($row["username"] !== null) {
$pm = "" . $row["username": . "]" . $row["msg"] . "
\n" . $answer . "\n\n" . T_("SC_REGARDS");
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, subject, msg, poster) VALUES ($staff, " . (int) $row["sender"] . ", '" . get_date_time() . "', " . sqlesc("Re: " . $row["subject"]) . ", " . sqlesc($pm) . ", $staff)");
}
autolink("staffbox.php?action=viewpm&pmid=$id", T_("SC_ANSWER_SENT"));
}
$ids = sc_ids($_POST["ids"] ?? array());
if (($do === "mark" || $do === "delete") && !$ids) {
show_error_msg(T_("ERROR"), T_("SC_NOTHING_SELECTED"), 1);
}
if ($do === "mark") {
SQL_Query_exec("UPDATE staffmessages SET answered = 1, answeredby = $staff WHERE answered = 0 AND id IN (" . implode(",", $ids) . ")");
autolink("staffbox.php", T_("SC_MARKED"));
}
if ($do === "delete") {
SQL_Query_exec("DELETE FROM staffmessages WHERE id IN (" . implode(",", $ids) . ")");
autolink("staffbox.php", T_("SC_DELETED"));
}
}
// ---- one message
if (($_GET["action"] ?? "") === "viewpm") {
$id = (int) ($_GET["pmid"] ?? 0);
$row = mysqli_fetch_assoc(SQL_Query_exec("SELECT m.*, s.username AS sender_name, a.username AS answer_name FROM staffmessages m LEFT JOIN users s ON s.id = m.sender LEFT JOIN users a ON a.id = m.answeredby WHERE m.id = $id"));
stdhead(T_("SC_BOX_TITLE"));
begin_frame(T_("SC_BOX_TITLE"));
if (!$row) {
echo "<p>" . T_("SC_NOT_FOUND") . "</p>";
} else {
?>
<table class="table_table" cellpadding="5" width="100%">
<tr><th class="table_head" colspan="2"><?php echo sc_e($row["subject"]); ?></th></tr>
<tr><td class="table_col1" width="140"><b><?php echo T_("SC_FROM"); ?></b></td><td class="table_col2"><?php echo sc_user($row["sender"], $row["sender_name"]); ?> · <?php echo sc_e(utc_to_tz((string) $row["added"])); ?></td></tr>
<tr><td class="table_col1"><b><?php echo T_("SC_MESSAGE"); ?></b></td><td class="table_col2"><div><?php echo format_comment((string) $row["msg"]); ?></div></td></tr>
<tr><td class="table_col1"><b><?php echo T_("SC_STATUS"); ?></b></td><td class="table_col2"><?php
echo $row["answered"] ? "<b style='color:green'>" . T_("SC_ANSWERED") . "</b> · " . sc_user($row["answeredby"], $row["answer_name"]) : "<b style='color:red'>" . T_("SC_WAITING") . "</b>";
?></td></tr>
<?php if ((string) $row["answer"] !== "") { ?>
<tr><td class="table_col1"><b><?php echo T_("SC_ANSWER"); ?></b></td><td class="table_col2"><div><?php echo format_comment((string) $row["answer"]); ?></div></td></tr>
<?php } ?>
<?php if (!$row["answered"]) { ?>
<tr><td class="table_col1"><b><?php echo T_("SC_REPLY"); ?></b></td><td class="table_col2">
<form method="post" action="staffbox.php">
<input type="hidden" name="do" value="answer" /><input type="hidden" name="id" value="<?php echo $id; ?>" />
<textarea name="answer" rows="10" style="width:100%" required></textarea>
<div><a href="tags.php"><?php echo T_("SC_BBCODE_ALLOWED"); ?></a></div>
<input type="submit" value="<?php echo T_("SC_SEND_ANSWER"); ?>" />
</form>
</td></tr>
<?php } ?>
</table>
<form method="post" action="staffbox.php">
<input type="hidden" name="ids[]" value="<?php echo $id; ?>" />
<?php if (!$row["answered"]) { ?><button type="submit" name="do" value="mark"><?php echo T_("SC_MARK_ANSWERED"); ?></button><?php } ?>
<button type="submit" name="do" value="delete" onclick="return confirm('<?php echo sc_e(T_("SC_DELETE_CONFIRM")); ?>');"><?php echo T_("SC_DELETE"); ?></button>
</form>
<?php
}
echo "<p><a href='staffbox.php'>" . T_("SC_BACK_TO_LIST") . "</a></p>";
end_frame();
stdfoot();
exit;
}
// ---- all messages
$count = get_row_count("staffmessages");
list($pagertop, $pagerbottom, $limit) = pager(20, $count, "staffbox.php?");
$res = SQL_Query_exec("SELECT m.id, m.added, m.subject, m.answered, m.sender, m.answeredby, s.username AS sender_name, a.username AS answer_name FROM staffmessages m LEFT JOIN users s ON s.id = m.sender LEFT JOIN users a ON a.id = m.answeredby ORDER BY m.answered ASC, m.id DESC $limit");
stdhead(T_("SC_BOX_TITLE"));
begin_frame(T_("SC_BOX_TITLE"));
if ($count == 0) {
echo "<p align='center'>" . T_("SC_NO_MESSAGES") . "</p>";
} else {
if ($count > 20) echo $pagertop;
echo "<form method='post' action='staffbox.php' id='staffbox'><table class='table_table' cellpadding='5' width='100%'><tr>";
foreach (array(T_("SC_SUBJECT"), T_("SC_FROM"), T_("ADDED"), T_("SC_STATUS")) as $heading) echo "<th class='table_head'>$heading</th>";
echo "<th class='table_head'><input type='checkbox' name='checkall' onclick='checkAll(this.form.id)' /></th></tr>";
while ($res && ($row = mysqli_fetch_assoc($res))) {
$status = $row["answered"] ? "<b style='color:green'>" . T_("SC_ANSWERED") . "</b> · " . sc_user($row["answeredby"], $row["answer_name"]) : "<b style='color:red'>" . T_("SC_WAITING") . "</b>";
echo "<tr><td class='table_col1'><a href='staffbox.php?action=viewpm&pmid=" . (int) $row["id"] . "'><b>" . sc_e($row["subject"]) . "</b></a></td>"
. "<td class='table_col2'>" . sc_user($row["sender"], $row["sender_name"]) . "</td>"
. "<td class='table_col1' align='center'>" . sc_e(utc_to_tz((string) $row["added"])) . "</td>"
. "<td class='table_col2'>$status</td>"
. "<td class='table_col1' align='center'><input type='checkbox' name='ids[]' value='" . (int) $row["id"] . "' /></td></tr>";
}
echo "</table><p align='right'>";
echo "<button type='submit' name='do' value='mark'>" . T_("SC_MARK_ANSWERED") . "</button> ";
echo "<button type='submit' name='do' value='delete' onclick=\"return confirm('" . sc_e(T_("SC_DELETE_CONFIRM")) . "');\">" . T_("SC_DELETE") . "</button>";
echo "</p></form>";
if ($count > 20) echo $pagerbottom;
}
end_frame();
stdfoot();
?><a href="contactstaff.php">Contact Staff</a>
<a href="staffbox.php">Messages to Staff</a>// Tells staff on the home page when messages to the staff are waiting.
if (!empty($CURUSER) && (int) $CURUSER["class"] >= 5) {
$sc_res = SQL_Query_exec("SELECT COUNT(*) FROM staffmessages WHERE answered = 0");
$sc_row = $sc_res ? mysqli_fetch_row($sc_res) : null;
$sc_open = $sc_row ? (int) $sc_row[0] : 0;
if ($sc_open > 0) {
begin_frame(T_("SC_BOX_TITLE"));
echo "<p>"
. ($sc_open === 1 ? T_("SC_STAFF_NOTICE_ONE") : sprintf(T_("SC_STAFF_NOTICE_MANY"), $sc_open))
. " <a href='staffbox.php'><b>" . T_("SC_STAFF_NOTICE_LINK") . "</b></a></p>";
end_frame();
}
}$LANG["SC_TITLE"] = 'Contact Staff';
$LANG["SC_BOX_TITLE"] = 'Messages to Staff';
$LANG["SC_INTRO"] = 'Have a question, suggestion or concern? Send a message to the staff and we will reply by private message as soon as we can.';
$LANG["SC_SUBJECT"] = 'Subject';
$LANG["SC_MESSAGE"] = 'Message';
$LANG["SC_SEND"] = 'Send message';
$LANG["SC_SENT"] = 'Thank you. Your message has been sent to the staff.';
$LANG["SC_FILL_IN_BOTH"] = 'Please fill in both the subject and your message.';
$LANG["SC_FILL_IN_ANSWER"] = 'Please enter an answer.';
$LANG["SC_NOT_ALLOWED"] = 'You do not have permission to view this page.';
$LANG["SC_NOT_FOUND"] = 'This message could not be found.';
$LANG["SC_NO_MESSAGES"] = 'There are no messages yet.';
$LANG["SC_NOTHING_SELECTED"] = 'Please select at least one message.';
$LANG["SC_FROM"] = 'From';
$LANG["SC_STATUS"] = 'Status';
$LANG["SC_ANSWERED"] = 'Answered';
$LANG["SC_WAITING"] = 'Waiting for an answer';
$LANG["SC_ANSWER"] = 'Answer';
$LANG["SC_REPLY"] = 'Reply';
$LANG["SC_SEND_ANSWER"] = 'Send answer';
$LANG["SC_ANSWER_SENT"] = 'Your answer has been sent to the member.';
$LANG["SC_MARK_ANSWERED"] = 'Mark as answered';
$LANG["SC_MARKED"] = 'The selected messages are marked as answered.';
$LANG["SC_DELETE"] = 'Delete';
$LANG["SC_DELETED"] = 'The selected messages have been deleted.';
$LANG["SC_DELETE_CONFIRM"] = 'Delete the selected messages? This cannot be undone.';
$LANG["SC_BACK_TO_LIST"] = 'Back to all messages';
$LANG["SC_BBCODE_ALLOWED"] = 'BB Code is allowed';
$LANG["SC_REGARDS"] = 'Kind regards, the Staff';
$LANG["SC_STAFF_NOTICE_ONE"] = 'There is 1 message to the staff waiting for an answer.';
$LANG["SC_STAFF_NOTICE_MANY"] = 'There are %d messages to the staff waiting for an answer.';
$LANG["SC_STAFF_NOTICE_LINK"] = 'Open messages to staff';No users online
Torrents
Members
Online