Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
[MOD] Contact staff
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2 Only Mods Complete

Unknown User
2012-11-04 20:58:32
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
Unknown User
2013-02-19 10:10:31
I use the svn version but this code does not work, the code page is red from top to bottom though I have used the codes for the 2.8 thank you for your help if someone files for svn thank you for advance.

J'utilise la version svn mais les codes présent ne fonctionne pas, la page code est rouge du haut en bas pourtant j'ai bien utilisé les codes pour la 2.08 merci de votre aide si quelqu'un a les dossiers pour la svn merci d'avance.
Unknown User
2013-03-04 12:33:01
if some 1 have that mod for V2.8 complete i be really thanks i have try all this files above on the post wont work for me if some 1 have it for V2.8 please post a copy off it thanks guys
Unknown User
2013-03-05 09:32:58
[url="https://www.torrenttrader.org/index.php?/topic/17063-mode-contact-webmaster/#entry88115"]https://www.torrenttrader.org/index.php?/topic/17063-mode-contact-webmaster/#entry88115[/url]
Unknown User
2013-03-05 11:01:01
that isnt what i want what i wont is the contact staff and the staffbox
Unknown User
2013-03-11 18:49:28
works great - some visual changes needed but all in all great MOD
Unknown User
2013-06-11 04:39:26
Thanks
Unknown User
2013-07-17 03:05:10
Some error for me
Unknown User
2013-07-17 13:17:43
looks like these files will not work well in 2.08 due to them using shorttags:(

I have attached some new files that should work fine in 2.08

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6829"]staffbox.php[/url]

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6826"]contactstaff.php[/url] [url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6828"]takecontact.php[/url]
contactstaff.php
Download
takecontact.php
Download
staffbox.php
Download
Unknown User
2013-07-17 19:56:06
merci ca marche nikkel, mais quand une personne contact le staff et quand je lui ai faire la reponse ca affiche

Database Error. Please report this to an administrator.

Mais le message sent quand meme.
Unknown User
2013-07-17 20:54:45
Database Error. Please report this to an administrator.
does no good if you don't also add the last info from your_siteurl/admincp.php?action=sqlerr
Unknown User
2013-08-17 20:47:23
Database Error in staffbox.php on line 87: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1. Query was: SELECT username FROM users WHERE id=.
Unknown User
2013-08-20 04:01:29
Tnanks, it'w work now, i just deleted an issues

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=6902"]staffbox.php[/url]
staffbox.php
Download
Unknown User
2014-12-26 11:25:29
TT 2.08


First time SQL


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;



and add to admincp.php

this line


<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>



add to navigate_block


echo "<li><a href='contactstaff.php'>".T_("CONTACT_STAFF")."</a></li>";


[url='http://devscorner.xyz/applications/core/interface/file/attachment.php?id=7171']staffbox.php[/url]

[url='http://devscorner.xyz/applications/core/interface/file/attachment.php?id=7172']takecontact.php[/url]

[url='http://devscorner.xyz/applications/core/interface/file/attachment.php?id=7173']contactstaff.php[/url]
staffbox.php
Download
takecontact.php
Download
contactstaff.php
Download
2026-11-09 14:45:07
Thank you to fozshell for sharing this mod, to MasterRoot at TBDev for the original hack, and to Daffy, walker1977, mostvotedplaya, spiritblue and Noname12 for the fixes and ideas in this topic. It is still a very useful addition after all these years.

Here is an updated version for PHP 8 that brings the fixes from all five pages together. Please take a backup of your files and database first.

Sending, answering, marking as answered and deleting were tested on PHP 8.5 with MariaDB 10.10 using a staff account. The check that keeps regular members out of staffbox.php was only reviewed in the code, so please try that with a test account.

What changed
- mysql_* calls, short open tags, $HTTP_POST_VARS, stderr, sqlerr and TYPE=MYISAM are gone
- Moderators and Super Moderators can use the staff box, because it checks the class and no longer depends on the Admin CP permission
- Staff can get a notice on the home page while messages are waiting, as requested earlier in this topic
- Unanswered messages no longer cause a query error on the empty answeredby value
- Messages from deleted members stay visible instead of disappearing from the list
- SQL injection through setanswered and the answer fields is closed, and subjects and names are escaped
- Marking and deleting now need a form submit, so a plain link cannot trigger them
- A double click or page refresh no longer sends the same message twice
- All language keys start with SC_, so they cannot change text elsewhere on the site

run SQL
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;


Save this as contactstaff.php in your root
<?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();
?>


Save this as takecontact.php in your root
<?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"));
?>


Save this as staffbox.php in your root
Staff are class 5 and up on a default install; change SC_STAFF_CLASS at the top if yours differ.
<?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"]); ?> &middot; <?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> &middot; " . 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> &middot; " . 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();
?>


Add the links wherever they suit your theme
<a href="contactstaff.php">Contact Staff</a>
<a href="staffbox.php">Messages to Staff</a>

The first is for members and the second for staff. Moderators without Admin CP access need the staff link somewhere other than the Admin CP.

Optional: notice for staff in index.php, after stdhead
// 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();
   }
}


Add to english.php
$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';


Thanks again!

If It Ain't Dutch, It Ain't Much!!
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 5
  • Members: 0
  • Guests online: 5
  • Comments: 3
  • Messages: 1,728