09 Report Mod

Started by Mindless, July 21, 2012, 09:40:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mindless

#1
Credits to sir_snugglebunny
Language Outstanding
Move reports.php to admin panel to follow.
Xhtml Valid
Thanks to putyn for report alert block made from staffcontact mod :)

Run the sql :
Code (sql) Select
CREATE TABLE `reports` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `reported_by` int(10) unsigned NOT NULL default '0',
  `reporting_what` int(10) unsigned NOT NULL default '0',
  `reporting_type` enum('User','Comment','Request_Comment','Offer_Comment','Request','Offer','Torrent','Hit_And_Run','Post') character set utf8 NOT NULL default 'Torrent',
  `reason` text character set utf8 NOT NULL,
  `who_delt_with_it` int(10) unsigned NOT NULL default '0',
  `delt_with` tinyint(1) NOT NULL default '0',
  `added` int(11) NOT NULL default '0',
  `how_delt_with` text character set utf8 NOT NULL,
  `2nd_value` int(10) unsigned NOT NULL default '0',
  `when_delt_with` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



@File include/config.php add beside the msgalert :
Code (php) Select
$TBDEV['report_alert'] = 1; // saves a query when off


@File bitorrent.php or template.php add :
Code (php) Select
//==Big red report thingy box:
   if($TBDEV['report_alert'] && $CURUSER['class'] >= UC_MODERATOR) {
      $num = mysql_result(mysql_query('SELECT COUNT(id) FROM reports WHERE delt_with = 0'),0);
      if($num > 0)
      $htmlout .= "<table border='0' cellspacing='0' cellpadding='10'>
                  <tr><td style='padding: 10px; background: #ccc'>\n
                  <b><a href='reports.php'>".sprintf($lang['gl_reportmsg_alert'], $num). "!</a></b>
                  </td></tr></table><br/>";
   }
   //==End



Save and upload report.php to root :
Code (php) Select
<?php
require_once("include/bittorrent.php");
require_once (
"include/user_functions.php");
dbconn();
loggedinorreturn();
//parked(); // uncomment out if you use this

$lang array_mergeload_language('global') );
$HTMLOUT '';
$id_2='';
$id_2b='';
// === now all reports just use a single var $id and a type thanks dokty... again
$id = ($_GET["id"] ? $_GET["id"] : $_POST["id"]);
$type = ($_GET["type"] ? $_GET["type"] : $_POST["type"]);
if (!
is_valid_id($id))
    
stderr("Error""Bad ID!");
$typesallowed = array("User""Comment""Request_Comment""Offer_Comment""Request""Offer""Torrent""Hit_And_Run""Post");
if (!
in_array($type$typesallowed))
    
stderr("Error""What you are trying to report doesn't exist!");
// === still need a second value passed for stuff like hit and run where you need two id's
if ((isset($_GET["id_2"])) || (isset($_POST["id_2"]))) {
    
$id_2 = ($_GET["id_2"] ? $_GET["id_2"] : $_POST["id_2"]);
    if (!
is_valid_id($id_2))
        
stderr("Error""I smell a rat!");
    
$id_2b "&amp;id_2=$id_2";
}

if ((isset(
$_GET["do_it"])) || (isset($_POST["do_it"]))) {
    
$do_it = ($_GET["do_it"] ? $_GET["do_it"] : $_POST["do_it"]);
    if (!
is_valid_id($do_it))
     
stderr("Error""I smell a rat!");
    
// == make sure the reason is filled out and is set
    
$reason sqlesc($_POST["reason"]);
    if (!
$reason)
     
stderr("Error""You MUST enter a reason for this report! Use your back button and fill in the reason");
    
// === check if it's been reported already
    
$res mysql_query("SELECT id FROM reports WHERE reported_by = $CURUSER[id] AND reporting_what = $id AND reporting_type = '$type'") or sqlerr(__FILE____LINE__);
    if (
mysql_num_rows($res) != 0)
    
stderr("Report Failure!""You have allready reported <b>" str_replace("_" " "$type) . "</b> with id: <b>$id</b>!");
    
// === ok it's not been reported yet let's go on
    
$dt sqlesc(time());
    
mysql_query("INSERT into reports (reported_by, reporting_what, reporting_type, reason, added, 2nd_value) VALUES ($CURUSER[id], '$id', '$type', $reason$dt, '$id_2')") or sqlerr(__FILE____LINE__);
    
$HTMLOUT .="<table width='650'><tr><td class='colhead'><h1>Success!</h1></td></tr>" "<tr><td class='clearalt6' align='center'>Successfully Reported <b>" str_replace("_" " "$type) . "</b> with id: <b>$id</b>!<br /><b>Reason:</b> $reason</td></tr></table>";
    print 
stdhead("Reports") . $HTMLOUT stdfoot();
    die();
    }
//=== end do_it
    // === starting main page for reporting all...
    
$HTMLOUT .="<form method='post' action='report.php?type=$type$id_2b&amp;id=$id&amp;do_it=1'>
    <table width='650'>
    <tr><td class='colhead' colspan='2'>
    <h1>Report: " 
str_replace("_" " "$type) . "</h1></td></tr>" "
    <tr><td class='clearalt6' colspan='2' align='center'>
    <img src='
{$TBDEV['pic_base_url']}warned.gif' alt='warned' title='Warned' border='0' /> Are you sure you would like to report <b>" str_replace("_" " "$type) . "</b> with id: <b>$id</b>" "
    <img src='
{$TBDEV['pic_base_url']}warned.gif' alt='warned' title='Warned' border='0' /><br />to the Staff for violation of the <a class='altlink' href='rules.php' target='_blank'>rules</a>?</td></tr>" "
    <tr><td class='clearalt6' align='right'><b>Reason:</b></td><td class='clearalt6'><textarea name='reason' cols='70' rows='5'></textarea> [ required ]<br /></td></tr>" 
"
    <tr><td class='clearalt6' colspan='2' align='center'><input type='submit' class='button' value='Confirm Report' /></td></tr></table></form>"
;
print 
stdhead("Report") . $HTMLOUT stdfoot();
die;
?>



Save and upload reports.php to root :
Code (php) Select
<?php
require_once("include/bittorrent.php");
require_once (
"include/user_functions.php");
require_once (
"include/html_functions.php");
require_once (
"include/pager_functions.php");
dbconn(false);

$lang array_mergeload_language('global') );

$HTMLOUT '';

$delt_link='';

$type='';

if (
$CURUSER["class"] < UC_ADMINISTRATOR)
header"Location: {$TBDEV['baseurl']}/index.php");

// === cute solved in thing taked from helpdesk mod
function round_time($ts)
{
    
$mins floor($ts 60);
    
$hours floor($mins 60);
    
$mins -= $hours 60;
    
$days floor($hours 24);
    
$hours -= $days 24;
    
$weeks floor($days 7);
    
$days -= $weeks 7;
    
$t "";
    if (
$weeks 0)
        return 
"$weeks week" . ($weeks "s" "");
    if (
$days 0)
        return 
"$days day" . ($days "s" "");
    if (
$hours 0)
        return 
"$hours hour" . ($hours "s" "");
    if (
$mins 0)
        return 
"$mins min" . ($mins "s" "");
    return 
"< 1 min";
}
// === now all reports just use a single var $id and a type thanks dokty... again
if (isset($_GET["id"])) {
    
$id = ($_GET["id"] ? $_GET["id"] : $_POST["id"]);
    if (!
is_valid_id($id))
        
stderr("Error""Bad ID!");
}
if (isset(
$_GET["type"])) {
    
$type = ($_GET["type"] ? $_GET["type"] : $_POST["type"]);
    
$typesallowed = array("User""Comment""Request_Comment""Offer_Comment""Request""Offer""Torrent""Hit_And_Run""Post");
    if (!
in_array($type$typesallowed))
        
stderr("Error""Bad report type!");
}
// === Let's deal with this damn report
if ((isset($_GET["deal_with_report"])) || (isset($_POST["deal_with_report"]))) {
    if (!
is_valid_id($_POST['id']))
    
stderr("Error""I smell a rat!");
    
$how_delt_with "how_delt_with = " sqlesc($_POST["how_delt_with"]);
    
$when_delt_with "when_delt_with = " sqlesc(time());
    
mysql_query ("UPDATE reports SET delt_with = 1, $how_delt_with$when_delt_with , who_delt_with_it = $CURUSER[id] WHERE delt_with!=1 AND id = $_POST[id]") or sqlerr(__FILE____LINE__);
    }
    
// === end deal_with_report
    // === main reports page
    
$HTMLOUT .="<table width='600'><tr><td class='colhead'><h1>Active Reports</h1></td></tr><tr><td class='clearalt6' align='center'>";
    
// === if get delete
    
if ((isset($_GET["delete"])) && ($CURUSER["class"] == UC_SYSOP)) {
    
$res mysql_query("DELETE FROM reports WHERE id = $id") or sqlerr(__FILE____LINE__);
    
$HTMLOUT .="<h1>Report Deleted!</h1>\n";
    }
    
// === get the count make the page
   
$res mysql_query("SELECT count(id) FROM reports") or sqlerr(__FILE____LINE__);
   
$row mysql_fetch_array($res);
   
$count $row[0];
   
$perpage 15;
   
$pager pager($perpage$count$_SERVER["PHP_SELF"] . "?&amp;");

   if (
$count == '0')
   
$HTMLOUT .="<p align='center'><b>No Reports, they are all playing nice!</b></p></td></tr>";
   else {
   
$HTMLOUT .= $pager['pagertop'];
   
$HTMLOUT .="<form method='post' action='reports.php?deal_with_report=1'>
   <table width='650'><tr><td class='colhead' align='left' valign='top'>Added</td>
   <td class='colhead' align='left' valign='top'>Reported by</td>" 
"
   <td class='colhead' align='left' valign='top'>Reporting What</td>"
."
   <td class='colhead' align='left' valign='top'>Type</td><td class='colhead' align='left' valign='top'>Reason</td>" 
"
   <td class='colhead' align='center' valign='top'>Dealt With</td><td class='colhead' align='center' valign='top'>Deal With It</td>" 
"
   " 
. ($CURUSER["class"] == UC_SYSOP "<td class='colhead' align='center' valign='top'>Delete</td>" "") . "</tr>";
    
// === get the info
    
$res_info mysql_query("SELECT reports.id, reports.reported_by, reports.reporting_what, reports.reporting_type, reports.reason, reports.who_delt_with_it, reports.delt_with, reports.added, reports.how_delt_with, reports.when_delt_with, reports.2nd_value, users.username FROM reports INNER JOIN users on reports.reported_by = users.id ORDER BY id DESC ".$pager['limit']."");
    while (
$arr_info mysql_fetch_assoc($res_info)) {
        
// =======change colors thanks Jaits
        
$count2='';
        
$count2 = (++$count2) % 2;
        
$class 'clearalt' . ($count2 == 0?'6':'7');
        
// =======end
        // === cute solved in thing taked from helpdesk mod by nuerher
        
$added $arr_info["added"];
        
$solved_date $arr_info["when_delt_with"];

        if (
$solved_date == "0") {
            
$solved_in " [N/A]";
            
$solved_color "pink";
        } else {
            
$solved_in_wtf $arr_info["when_delt_with"] - $arr_info["added"];
            
$solved_in "&nbsp;[" round_time($solved_in_wtf) . "]";

            if (
$solved_in_wtf 3600)
                
$solved_color "red";
            else if (
$solved_in_wtf 3600)
                
$solved_color "yellow";
            else if (
$solved_in_wtf <= 3600)
                
$solved_color "green";
        }
        
// === has it been delt with yet?
        
if ($arr_info["delt_with"]) {
            
$res_who mysql_query("SELECT username FROM users WHERE id=$arr_info[who_delt_with_it]");
            
$arr_who mysql_fetch_assoc($res_who);
            
$dealtwith "<font color='" $solved_color "'><b>Yes -</b> </font> by: <a class='altlink' href='userdetails.php?id=$arr_info[who_delt_with_it]'><b>$arr_who[username]</b></a><br /> in: <font color='" $solved_color "'>" $solved_in "</font>";
            
$checkbox "<input type='radio' name='id' value='{$arr_info['id']}' disabled='disabled' />";
        } else {
            
$dealtwith "<font color='red'><b>No</b></font>";
            
$checkbox "<input type='radio' name='id' value='{$arr_info['id']}' />";
        }
        
// === make a link to the reported thing
        
if ($arr_info["reporting_type"] != "") {
            switch (
$arr_info["reporting_type"]) {
                case 
"User":
                    
$res_who2 mysql_query("SELECT username FROM users WHERE id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='userdetails.php?id=$arr_info[reporting_what]'><b>$arr_who2[username]</b></a>";
                    break;
                case 
"Comment":
                    
$res_who2 mysql_query("SELECT comments.user, users.username, torrents.id FROM comments, users, torrents WHERE comments.user = users.id AND comments.id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='details.php?id=$arr_who2[id]&amp;viewcomm=$arr_info[reporting_what]#comm$arr_info[reporting_what]'><b>$arr_who2[username]</b></a>";
                    break;
                case 
"Request_Comment":
                    
$res_who2 mysql_query("SELECT comments.request, comments.user, users.username FROM comments, users WHERE comments.user = users.id AND comments.id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='viewrequests.php?id=$arr_who2[request]&amp;req_details=1&amp;viewcomm=$arr_info[reporting_what]#comm$arr_info[reporting_what]'><b>$arr_who2[username]</b></a>";
                    break;
                case 
"Offer_Comment":
                    
$res_who2 mysql_query("SELECT comments.offer, comments.user, users.username FROM comments, users WHERE comments.user = users.id AND comments.id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='viewoffers.php?id=$arr_who2[offer]&amp;off_details=1&amp;viewcomm=$arr_info[reporting_what]#comm$arr_info[reporting_what]'><b>$arr_who2[username]</b></a>";
                    break;
                case 
"Request":
                    
$res_who2 mysql_query("SELECT request FROM requests WHERE id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='viewrequests.php?id=$arr_info[reporting_what]&amp;req_details=1'><b>" htmlspecialchars($arr_who2['request']) . "</b></a>";
                    break;
                case 
"Offer":
                    
$res_who2 mysql_query("SELECT name FROM offers WHERE id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='viewoffers.php?id=$arr_info[reporting_what]&amp;off_details=1'><b>" htmlspecialchars($arr_who2['name']) . "</b></a>";
                    break;
                case 
"Torrent":
                    
$res_who2 mysql_query("SELECT name FROM torrents WHERE id = $arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='details.php?id=$arr_info[reporting_what]'><b>" htmlspecialchars($arr_who2['name']) . "</b></a>";
                    break;
                case 
"Hit_And_Run":
                    
$res_who2 mysql_query("SELECT users.username, torrents.name, r.2nd_value FROM users, torrents LEFT JOIN reports AS r ON r.2nd_value = torrents.id WHERE users.id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<b>user:</b> <a class='altlink' href='userdetails.php?id=" $arr_info['reporting_what'] . "&amp;completed=1'><b>" $arr_who2['username'] . "</b></a><br />hit and run on:<br /> <a class='altlink' href='details.php?id=" $arr_info['2nd_value'] . "&amp;page2=0#snatched'><b>" htmlspecialchars($arr_who2['name']) . "</b></a>";
                    break;
                case 
"Post":
                    
$res_who2 mysql_query("SELECT subject FROM topics WHERE id = " $arr_info['2nd_value']);
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<b>post:</b> <a class='altlink' href='forums.php?action=viewtopic&amp;topicid=" $arr_info['2nd_value'] . "&amp;page=last#" $arr_info['reporting_what'] . "'><b>" htmlspecialchars($arr_who2['subject']) . "</b></a>";
                    break;
            }
        }
        
        
$HTMLOUT .="<tr><td align='left' valign='top' class='$class'>" .get_date($arr_info['added'], 'DATE',0,1) . "</td>
        <td align='left' valign='top' class='
$class'><a class='altlink' href='userdetails.php?id=" $arr_info['reported_by'] . "'>" "<b>" $arr_info['username'] . "</b></a></td>
        <td align='left' valign='top' class='
$class'>{$link_to_thing}</td>
        <td align='left' valign='top' class='
$class'><b>" str_replace("_" " "$arr_info["reporting_type"]) . "</b>" "</td>
        <td align='left' valign='top' class='
$class'>" .htmlspecialchars($arr_info['reason']) . "</td>
        <td align='center' valign='top' class='
$class'>{$dealtwith} {$delt_link}</td>
        <td align='center' valign='middle' class='
$class'>{$checkbox}</td>" . ($CURUSER["class"] == UC_SYSOP "<td align='center' valign='middle' class='$class'><a class='altlink' href='reports.php?id=" $arr_info['id'] . "&amp;delete=1'><font color='red'>Delete</font></a></td>" "") . "</tr>\n";
        
// ===how was it delt with?
        
if ($arr_info['how_delt_with'])
        
$HTMLOUT .="<tr>
        <td colspan='" 
. ($CURUSER["class"] == UC_SYSOP "6" "5") . "' class='$class' align='left'><b>Delt with by " $arr_who['username'] . ":</b> " .get_date($arr_info['when_delt_with'], 'LONG',0,1) . "</td></tr>
        <tr><td colspan='" 
. ($CURUSER["class"] == UC_SYSOP "6" "5") . "' class='$class' align='left'>" .htmlspecialchars($arr_info['how_delt_with']) . "<br /><br /></td></tr>";
    }
}
$HTMLOUT .="</table>";
if (
$count '0') {
// === deal with it
$HTMLOUT .= "<br /><br /><p align='center'><b>How $CURUSER[username] Delt with this report:</b> [ required ] </p><textarea name='how_delt_with' cols='70' rows='5'></textarea><br /><br />" "<input type='submit' class='button' value='Confirm' /><br /><br /></form></td></tr></table>";
//=== end if count
print stdhead("Active Reports") . $HTMLOUT stdfoot();
die;
?>



Add to forums.php - Note this line is for the 09 multi-layer forum which already has the link - you may need to alter it slighty for default forums.php :
Code (php) Select
//==Report Forum Post
$HTMLOUT.="<a href='{$TBDEV['baseurl']}/report.php?type=Post&amp;id=".$postid."&amp;id_2=".$topicid."&amp;id_3=".$posterid."'><img src='".$TBDEV['pic_base_url'].$forum_pics['p_report_btn']."' border='0' alt='Report Post' /></a>";
//==End



Add to details.php where you want the link - probably the bottom of the table :
Code (php) Select
//==Report Torrent
$HTMLOUT .= tr("Report Torrent", "<form action='report.php?type=Torrent&amp;id=$id' method='post'><input class='button' type='submit' name='submit' value='Report This Torrent' /> For breaking the <a href='rules.php'>rules</a></form>", 1);
//==End



Add to userdetails.php where you want the link probably under userinfo before the table end :
Code (php) Select
//==Report User
$HTMLOUT .= tr("Report User","<form method='post' action='report.php?type=User&amp;id={$id}'> <input type='submit' value='Report User' class='button' /> Click to Report this user for Breaking the rules.</form>", 1);
//==End


Updates :

Code (php) Select
//==Big red report thingy box:
   if($TBDEV['report_alert'] && $CURUSER['class'] >= UC_MODERATOR) {
      $num = mysql_result(mysql_query('SELECT COUNT(id) FROM reports WHERE delt_with = 0'),0);
      if($num > 0)
      $htmlout .= "<table border='0' cellspacing='0' cellpadding='10'>
                  <tr><td style='padding: 10px; background: #ccc'>\n
                  <b><a href='admin.php?action=reports'>".sprintf($lang['gl_reportmsg_alert'], $num). "!</a></b>
                  </td></tr></table><br/>";
   }



userdetails.php
   
Code (php) Select
//==Report User
$HTMLOUT .= tr("{$lang['userdetails_report']}","<form method='post' action='report.php?type=User&id={$id}'> <input type='submit' value='Report User' class='button' /> {$lang['userdetails_report1']}</form>", 1);
//==End



Code (php) Select
lang_userdetails.php
'userdetails_report' => "Report User",
'userdetails_report1' => "Click to Report this user for Breaking the rules.",



details.php

Code (php) Select
//==Report Torrent
$HTMLOUT .= tr("{$lang['details_report']}", "<form action='report.php?type=Torrent&id=$id' method='post'><input class='button' type='submit' name='submit' value='Report This Torrent' /> {$lang['details_report1']} <a href='rules.php'>{$lang['details_report2']}</a></form>", 1);
//==End



Code (php) Select
lang_details.php
'details_report' => 'Report Torrent',
'details_report1' => 'For breaking the',
'details_report2' => 'rules',



admin.php

Code (php) Select
'reports' => 'reports',


admin/index.php

Code (php) Select
<span class='btn'><a href='admin.php?action=reports'>{$lang['index_reports']}</a></span>


lang/lang_ad_index.php

Code (php) Select
'index_reports' => 'Reports',

report.php

Code (php) Select
<?php
require_once("include/bittorrent.php");
require_once (
"include/user_functions.php");
dbconn();
loggedinorreturn();
//parked(); // uncomment out if you use this

$lang array_mergeload_language('global'), load_language('report') );
$HTMLOUT '';
$id_2='';
$id_2b='';
// === now all reports just use a single var $id and a type thanks dokty... again
$id = ($_GET["id"] ? $_GET["id"] : $_POST["id"]);
$type = ($_GET["type"] ? $_GET["type"] : $_POST["type"]);
if (!
is_valid_id($id))
    
stderr("{$lang['report_error']}""{$lang['report_error1']}");
$typesallowed = array("User""Comment""Request_Comment""Offer_Comment""Request""Offer""Torrent""Hit_And_Run""Post");
if (!
in_array($type$typesallowed))
    
stderr("{$lang['report_error']}""{$lang['report_error2']}");
// === still need a second value passed for stuff like hit and run where you need two id's
if ((isset($_GET["id_2"])) || (isset($_POST["id_2"]))) {
    
$id_2 = ($_GET["id_2"] ? $_GET["id_2"] : $_POST["id_2"]);
    if (!
is_valid_id($id_2))
        
stderr("{$lang['report_error']}""{$lang['report_error3']}");
    
$id_2b "&amp;id_2=$id_2";
}

if ((isset(
$_GET["do_it"])) || (isset($_POST["do_it"]))) {
    
$do_it = ($_GET["do_it"] ? $_GET["do_it"] : $_POST["do_it"]);
    if (!
is_valid_id($do_it))
     
stderr("{$lang['report_error']}""{$lang['report_error3']}");
    
// == make sure the reason is filled out and is set
    
$reason sqlesc($_POST["reason"]);
    if (!
$reason)
     
stderr("{$lang['report_error']}""{$lang['report_error4']}");
    
// === check if it's been reported already
    
$res mysql_query("SELECT id FROM reports WHERE reported_by = $CURUSER[id] AND reporting_what = $id AND reporting_type = '$type'") or sqlerr(__FILE____LINE__);
    if (
mysql_num_rows($res) != 0)
    
stderr("{$lang['report_error5']}""{$lang['report_error6']} <b>" str_replace("_" " "$type) . "</b> {$lang['report_id']} <b>$id</b>!");
    
// === ok it's not been reported yet let's go on
    
$dt sqlesc(time());
    
mysql_query("INSERT into reports (reported_by, reporting_what, reporting_type, reason, added, 2nd_value) VALUES ($CURUSER[id], '$id', '$type', $reason$dt, '$id_2')") or sqlerr(__FILE____LINE__);
    
$HTMLOUT .="<table width='650'><tr><td class='colhead'><h1>{$lang['report_success']}</h1></td></tr>" "<tr><td class='clearalt6' align='center'>{$lang['report_success1']} <b>" str_replace("_" " "$type) . "</b> {$lang['report_id']} <b>$id</b>!<br /><b>{$lang['report_reason']}</b> $reason</td></tr></table>";
    print 
stdhead("Reports") . $HTMLOUT stdfoot();
    die();
    }
//=== end do_it
    // === starting main page for reporting all...
    
$HTMLOUT .="<form method='post' action='report.php?type=$type$id_2b&amp;id=$id&amp;do_it=1'>
    <table width='650'>
    <tr><td class='colhead' colspan='2'>
    <h1>Report: " 
str_replace("_" " "$type) . "</h1></td></tr>" "
    <tr><td class='clearalt6' colspan='2' align='center'>
    <img src='
{$TBDEV['pic_base_url']}warned.gif' alt='warned' title='Warned' border='0' /> {$lang['report_report']} <b>" str_replace("_" " "$type) . "</b> {$lang['report_id']} <b>$id</b>" "
    <img src='
{$TBDEV['pic_base_url']}warned.gif' alt='warned' title='Warned' border='0' /><br />{$lang['report_report1']} <a class='altlink' href='rules.php' target='_blank'>{$lang['report_rules']}</a>?</td></tr>" "
    <tr><td class='clearalt6' align='right'><b>
{$lang['report_reason']}</b></td><td class='clearalt6'><textarea name='reason' cols='70' rows='5'></textarea><br /> [ {$lang['report_req']} ]<br /></td></tr>" "
    <tr><td class='clearalt6' colspan='2' align='center'><input type='submit' class='button' value='
{$lang['report_confirm']}' /></td></tr></table></form>";
print 
stdhead("Report") . $HTMLOUT stdfoot();
die;
?>


reports.php

Code (php) Select
<?php
if ( ! defined'IN_TBDEV_ADMIN' ) )
{
   print 
"<h1>{$lang['text_incorrect']}</h1>{$lang['text_cannot']}";
   exit();
}

require_once(
"include/bittorrent.php");
require_once (
"include/user_functions.php");
require_once (
"include/html_functions.php");
require_once (
"include/pager_functions.php");


$lang array_merge$langload_language('ad_reports') );

$HTMLOUT '';

$delt_link='';

$type='';

if (
$CURUSER["class"] < UC_ADMINISTRATOR)
header"Location: {$TBDEV['baseurl']}/index.php");

// === cute solved in thing taked from helpdesk mod
function round_time($ts)
{
    
$mins floor($ts 60);
    
$hours floor($mins 60);
    
$mins -= $hours 60;
    
$days floor($hours 24);
    
$hours -= $days 24;
    
$weeks floor($days 7);
    
$days -= $weeks 7;
    
$t "";
    if (
$weeks 0)
        return 
"$weeks week" . ($weeks "s" "");
    if (
$days 0)
        return 
"$days day" . ($days "s" "");
    if (
$hours 0)
        return 
"$hours hour" . ($hours "s" "");
    if (
$mins 0)
        return 
"$mins min" . ($mins "s" "");
    return 
"< 1 min";
}
// === now all reports just use a single var $id and a type thanks dokty... again
if (isset($_GET["id"])) {
    
$id = ($_GET["id"] ? $_GET["id"] : $_POST["id"]);
    if (!
is_valid_id($id))
        
stderr("{$lang['reports_error']}""{$lang['reports_error1']}");
}
if (isset(
$_GET["type"])) {
    
$type = ($_GET["type"] ? $_GET["type"] : $_POST["type"]);
    
$typesallowed = array("User""Comment""Request_Comment""Offer_Comment""Request""Offer""Torrent""Hit_And_Run""Post");
    if (!
in_array($type$typesallowed))
        
stderr("{$lang['reports_error']}""{$lang['reports_error2']}");
}
// === Let's deal with this damn report
if ((isset($_GET["deal_with_report"])) || (isset($_POST["deal_with_report"]))) {
    if (!
is_valid_id($_POST['id']))
    
stderr("{$lang['reports_error']}""{$lang['reports_error3']}");
    
$how_delt_with "how_delt_with = " sqlesc($_POST["how_delt_with"]);
    
$when_delt_with "when_delt_with = " sqlesc(time());
    
mysql_query ("UPDATE reports SET delt_with = 1, $how_delt_with$when_delt_with , who_delt_with_it = $CURUSER[id] WHERE delt_with!=1 AND id = $_POST[id]") or sqlerr(__FILE____LINE__);
    }
    
// === end deal_with_report
    // === main reports page
    
$HTMLOUT .="<table width='600'><tr><td class='colhead'><h1>{$lang['reports_active']}</h1></td></tr><tr><td class='clearalt6' align='center'>";
    
// === if get delete
    
if ((isset($_GET["delete"])) && ($CURUSER["class"] == UC_SYSOP)) {
    
$res mysql_query("DELETE FROM reports WHERE id = $id") or sqlerr(__FILE____LINE__);
    
$HTMLOUT .="<h1>{$lang['reports_deleted']}</h1>\n";
    }
    
// === get the count make the page
   
$res mysql_query("SELECT count(id) FROM reports") or sqlerr(__FILE____LINE__);
   
$row mysql_fetch_array($res);
   
$count $row[0];
   
$perpage 15;
   
$pager pager($perpage$count$_SERVER["PHP_SELF"] . "?&amp;");

   if (
$count == '0')
   
$HTMLOUT .="<p align='center'><b>{$lang['reports_nice']}</b></p></td></tr>";
   else {
   
$HTMLOUT .= $pager['pagertop'];
   
$HTMLOUT .="<form method='post' action='admin.php?action=reports&amp;deal_with_report=1'>
   <table width='650'><tr><td class='colhead' align='left' valign='top'>
{$lang['reports_added']}</td>
   <td class='colhead' align='left' valign='top'>
{$lang['reports_report']}</td>" "
   <td class='colhead' align='left' valign='top'>
{$lang['reports_report']}</td>"."
   <td class='colhead' align='left' valign='top'>
{$lang['reports_type']}</td><td class='colhead' align='left' valign='top'>{$lang['reports_reason']}</td>" "
   <td class='colhead' align='center' valign='top'>
{$lang['reports_dealt']}</td><td class='colhead' align='center' valign='top'>{$lang['reports_deal']}</td>" "
   " 
. ($CURUSER["class"] == UC_SYSOP "<td class='colhead' align='center' valign='top'>{$lang['reports_delete']}</td>" "") . "</tr>";
    
// === get the info
    
$res_info mysql_query("SELECT reports.id, reports.reported_by, reports.reporting_what, reports.reporting_type, reports.reason, reports.who_delt_with_it, reports.delt_with, reports.added, reports.how_delt_with, reports.when_delt_with, reports.2nd_value, users.username FROM reports INNER JOIN users on reports.reported_by = users.id ORDER BY id DESC ".$pager['limit']."");
    while (
$arr_info mysql_fetch_assoc($res_info)) {
        
// =======change colors thanks Jaits
        
$count2='';
        
$count2 = (++$count2) % 2;
        
$class 'clearalt' . ($count2 == 0?'6':'7');
        
// =======end
        // === cute solved in thing taked from helpdesk mod by nuerher
        
$added $arr_info["added"];
        
$solved_date $arr_info["when_delt_with"];

        if (
$solved_date == "0") {
            
$solved_in " [N/A]";
            
$solved_color "pink";
        } else {
            
$solved_in_wtf $arr_info["when_delt_with"] - $arr_info["added"];
            
$solved_in "&nbsp;[" round_time($solved_in_wtf) . "]";

            if (
$solved_in_wtf 3600)
                
$solved_color "red";
            else if (
$solved_in_wtf 3600)
                
$solved_color "yellow";
            else if (
$solved_in_wtf <= 3600)
                
$solved_color "green";
        }
        
// === has it been delt with yet?
        
if ($arr_info["delt_with"]) {
            
$res_who mysql_query("SELECT username FROM users WHERE id=$arr_info[who_delt_with_it]");
            
$arr_who mysql_fetch_assoc($res_who);
            
$dealtwith "<font color='" $solved_color "'><b>{$lang['reports_yes']}</b> </font> {$lang['reports_by']} <a class='altlink' href='userdetails.php?id=$arr_info[who_delt_with_it]'><b>$arr_who[username]</b></a><br /> {$lang['reports_in']} <font color='" $solved_color "'>" $solved_in "</font>";
            
$checkbox "<input type='radio' name='id' value='{$arr_info['id']}' disabled='disabled' />";
        } else {
            
$dealtwith "<font color='red'><b>{$lang['reports_no']}</b></font>";
            
$checkbox "<input type='radio' name='id' value='{$arr_info['id']}' />";
        }
        
// === make a link to the reported thing
        
if ($arr_info["reporting_type"] != "") {
            switch (
$arr_info["reporting_type"]) {
                case 
"User":
                    
$res_who2 mysql_query("SELECT username FROM users WHERE id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='userdetails.php?id=$arr_info[reporting_what]'><b>$arr_who2[username]</b></a>";
                    break;
                case 
"Comment":
                    
$res_who2 mysql_query("SELECT comments.user, users.username, torrents.id FROM comments, users, torrents WHERE comments.user = users.id AND comments.id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='details.php?id=$arr_who2[id]&amp;viewcomm=$arr_info[reporting_what]#comm$arr_info[reporting_what]'><b>$arr_who2[username]</b></a>";
                    break;
                case 
"Request_Comment":
                    
$res_who2 mysql_query("SELECT comments.request, comments.user, users.username FROM comments, users WHERE comments.user = users.id AND comments.id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='viewrequests.php?id=$arr_who2[request]&amp;req_details=1&amp;viewcomm=$arr_info[reporting_what]#comm$arr_info[reporting_what]'><b>$arr_who2[username]</b></a>";
                    break;
                case 
"Offer_Comment":
                    
$res_who2 mysql_query("SELECT comments.offer, comments.user, users.username FROM comments, users WHERE comments.user = users.id AND comments.id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='viewoffers.php?id=$arr_who2[offer]&amp;off_details=1&amp;viewcomm=$arr_info[reporting_what]#comm$arr_info[reporting_what]'><b>$arr_who2[username]</b></a>";
                    break;
                case 
"Request":
                    
$res_who2 mysql_query("SELECT request FROM requests WHERE id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='viewrequests.php?id=$arr_info[reporting_what]&amp;req_details=1'><b>" htmlspecialchars($arr_who2['request']) . "</b></a>";
                    break;
                case 
"Offer":
                    
$res_who2 mysql_query("SELECT name FROM offers WHERE id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='viewoffers.php?id=$arr_info[reporting_what]&amp;off_details=1'><b>" htmlspecialchars($arr_who2['name']) . "</b></a>";
                    break;
                case 
"Torrent":
                    
$res_who2 mysql_query("SELECT name FROM torrents WHERE id = $arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<a class='altlink' href='details.php?id=$arr_info[reporting_what]'><b>" htmlspecialchars($arr_who2['name']) . "</b></a>";
                    break;
                case 
"Hit_And_Run":
                    
$res_who2 mysql_query("SELECT users.username, torrents.name, r.2nd_value FROM users, torrents LEFT JOIN reports AS r ON r.2nd_value = torrents.id WHERE users.id=$arr_info[reporting_what]");
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<b>{$lang['reports_user']}</b> <a class='altlink' href='userdetails.php?id=" $arr_info['reporting_what'] . "&amp;completed=1'><b>" $arr_who2['username'] . "</b></a><br />{$lang['reports_hit']}<br /> <a class='altlink' href='details.php?id=" $arr_info['2nd_value'] . "&amp;page2=0#snatched'><b>" htmlspecialchars($arr_who2['name']) . "</b></a>";
                    break;
                case 
"Post":
                    
$res_who2 mysql_query("SELECT subject FROM topics WHERE id = " $arr_info['2nd_value']);
                    
$arr_who2 mysql_fetch_assoc($res_who2);
                    
$link_to_thing "<b>{$lang['reports_post']}</b> <a class='altlink' href='forums.php?action=viewtopic&amp;topicid=" $arr_info['2nd_value'] . "&amp;page=last#" $arr_info['reporting_what'] . "'><b>" htmlspecialchars($arr_who2['subject']) . "</b></a>";
                    break;
            }
        }
        
        
$HTMLOUT .="<tr><td align='left' valign='top' class='$class'>" .get_date($arr_info['added'], 'DATE',0,1) . "</td>
        <td align='left' valign='top' class='
$class'><a class='altlink' href='userdetails.php?id=" $arr_info['reported_by'] . "'>" "<b>" $arr_info['username'] . "</b></a></td>
        <td align='left' valign='top' class='
$class'>{$link_to_thing}</td>
        <td align='left' valign='top' class='
$class'><b>" str_replace("_" " "$arr_info["reporting_type"]) . "</b>" "</td>
        <td align='left' valign='top' class='
$class'>" .htmlspecialchars($arr_info['reason']) . "</td>
        <td align='center' valign='top' class='
$class'>{$dealtwith} {$delt_link}</td>
        <td align='center' valign='middle' class='
$class'>{$checkbox}</td>" . ($CURUSER["class"] == UC_SYSOP "<td align='center' valign='middle' class='$class'><a class='altlink' href='admin.php?action=reports&amp;id=" $arr_info['id'] . "&amp;delete=1'><font color='red'>{$lang['reports_delete']}</font></a></td>" "") . "</tr>\n";
        
// ===how was it delt with?
        
if ($arr_info['how_delt_with'])
        
$HTMLOUT .="<tr>
        <td colspan='" 
. ($CURUSER["class"] == UC_SYSOP "6" "5") . "' class='$class' align='left'><b>{$lang['reports_with']} " $arr_who['username'] . ":</b> " .get_date($arr_info['when_delt_with'], 'LONG',0,1) . "</td></tr>
        <tr><td colspan='" 
. ($CURUSER["class"] == UC_SYSOP "6" "5") . "' class='$class' align='left'>" .htmlspecialchars($arr_info['how_delt_with']) . "<br /><br /></td></tr>";
    }
}
$HTMLOUT .="</table>";
if (
$count '0') {
// === deal with it
$HTMLOUT .= "<br /><br /><p align='center'><b>{$lang['reports_how']} $CURUSER[username] {$lang['reports_dealt1']}</b> [ {$lang['reports_req']} ] </p><textarea name='how_delt_with' cols='70' rows='5'></textarea><br /><br />" "<input type='submit' class='button' value='Confirm' /><br /><br /></form></td></tr></table>";
//=== end if count
print stdhead("Active Reports") . $HTMLOUT stdfoot();
die;
?>


lang_ad_report.php

Code (php) Select
<?php

$lang 
= array(

#reports
'text_incorrect' => "Incorrect access",
'text_cannot' => "You cannot access this file directly.",
'reports_error' => "Error",
'reports_error1' => "Bad ID!",
'reports_error2' => "Bad report type!",
'reports_error3' => "I smell a rat!",
'reports_active' => "Active Reports",
'reports_deleted' => "Report Deleted!",
'reports_nice' => "No Reports, they are all playing nice!",
'reports_added' => "Added",
'reports_report' => "Reported by",
'reports_report1' => "Reporting What",
'reports_type' => "Type",
'reports_reason' => "Reason",
'reports_dealt' => "Dealt With",
'reports_deal' => "Deal With It",
'reports_delete' => "Delete",
'reports_yes' => "Yes -",
'reports_by' => "by:",
'reports_in' => "in:",
'reports_no' => "No",
'reports_user' => "user:",
'reports_hit' => "hit and run on:",
'reports_post' => "post:",
'reports_with' => "Dealt with by",
'reports_how' => "How",
'reports_dealt1' => "Dealt with this report:",
'reports_req' => "required",
);

?>


lang_report.php

Code (php) Select
<?php

$lang 
= array(

#report

'report_error' => "Error",
'report_error1' => "Bad ID!",
'report_error2' => "What you are trying to report doesn't exist!",
'report_error3' => "I smell a rat!",
'report_error4' => "You MUST enter a reason for this report! Use your back button and fill in the reason",
'report_error5' => "Report Failure!",
'report_error6' => "You have already reported",
'report_id' => "with id:",
'report_success' => "Success!",
'report_success1' => "Successfully Reported",
'report_reason' => "Reason:",
'report_report' => "Are you sure you would like to report",
'report_report1' => "to the Staff for violation of the",
'report_rules' => "rules",
'report_req' => "required",
'report_confirm' => "Confirm Report",
);
?>


Add to include/torrenttable_functions - note the line will go into your commenttable_function which is situated under the torrenttable - it drops straight into the function :
Code (php) Select
($CURUSER["class"] >= UC_VIP ? " - [<a href='report.php?type=Comment&amp;id=".$row['id']."'>Report this Comment</a>]" : "") .

And thats all for now.