User Warning System Btit Tracker 1.32 - Част Първа
Урока е взет от http://www.btiteam.org/ така като ме помолиха да го преведа
Това е урок за създаване на предупредителна система на юзърите на вашия тракер.
А самата система е за администраторите на тракера,
да дават различни предупреждения на техните потребители, дали било за спам или друго.
Така да започваме...

1.Започваме с базите данни:

ALTER TABLE `users`
ADD `warns` int(10) NOT NULL default '0',
ADD `disabled` varchar(10) NOT NULL default 'no',
ADD `disabledby` int(10) NOT NULL default '0',
ADD `disabledon` datetime NOT NULL default '0000-00-00 00:00:00',
ADD `disabledreason` varchar(255) default NULL,
ADD `warnremovedby` int(10) NOT NULL default '0' ;

CREATE TABLE `warnings` (
`id` int(10) NOT NULL auto_increment,
`userid` int(10) NOT NULL default '0',
`warns` char(2) NOT NULL default '',
`added` datetime NOT NULL default '0000-00-00 00:00:00',
`expires` datetime NOT NULL default '0000-00-00 00:00:00',
`warnedfor` int(2) NOT NULL default '0',
`reason` varchar(255) NOT NULL default '',
`addedby` int(20) NOT NULL default '0',
`active` varchar(10) NOT NULL default '',
PRIMARY KEY (`id`)
) AUTO_INCREMENT=1 ;


2. Отваряте language/language.php и добавяте това:

define("ACP_WARNEDU", "Warnings");
define("DISABLE_ACCOUNT", "Account disabled");
define("ENABLE_ACCOUNT", "Account enabled");
define("ERR_ACCOUNT_DISABLED", "Error: This account has been Disabled !");
define("ONE_WEEK", "1 week");
define("TWO_WEEKS", "2 weeks");
define("THREE_WEEKS", "3 weeks");
define("FOUR_WEEKS", "4 weeks");
define("PERMANENTLY", "unlimited");
define("WARN_FALSE", "False");
define("WARN_TRUE", "True");
define("WARN_CONFIRM", "Are you sure you want to Warn this user ?");
define("WARN_REMOVE", "Are you sure you want to remove this Warn ?");
define("WARN_LEVEL_RESET", "Reset the Warn Level for this user ?");
define("WARN_DISABLE_ACCOUNT", "Are you sure you want to Disable this account ?");
define("WARN_ENABLE_ACCOUNT", "Are you sure you want to Enable this account ?");
define("WARNED_USERS", "Warned users");


3.Създавате файл WARNEDUSERS.PHP и добавяте това в него:

<?php
require_once ("include/functions.php");
require_once ("include/config.php");

dbconn();
block_begin("".WARNED_USERS."");


if (!$CURUSER || $CURUSER["admin_access"]=="yes")

{
//Per Page Listing Limitation Start - 00:06 24.06.2006
$numwarns = mysql_query("SELECT COUNT(*) FROM warnings WHERE active='yes'");
$row = mysql_fetch_array($numwarns);
$count = $row[0];
$perpage = $GLOBALS["warnsppage"];
list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, "admincp.php?do=warnedu&".$addparams);
//Per Page Listing Limitation Stop

$res = mysql_query("SELECT * FROM warnings WHERE active='yes' ORDER BY warns DESC $limit") or sqlerr();
$num = mysql_num_rows($res);

print("<table border=0 width=100% cellspacing=2 cellpadding=0>");

//Per Page Listing Limitation Start - 00:07 24.06.2006
if ($count > $perpage)
print("<tr><td class=lista align=center colspan=10><br>".$pagertop."</td></tr>");
//Per Page Listing Limitation Stop


//Checkbox Remove Start - 10:03 30.07.2006
print("<script type=\"text/javascript\">
<!--
function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
if(!document.forms[FormName])
return;
var objCheckBoxes = document.forms[FormName].elements[FieldName];
if(!objCheckBoxes)
return;
var countCheckBoxes = objCheckBoxes.length;
if(!countCheckBoxes)
objCheckBoxes.checked = CheckValue;
else
// set the check value for all check boxes
for(var i = 0; i < countCheckBoxes; i++)
objCheckBoxes[i].checked = CheckValue;
}
-->
</script>
");
//Checkbox Remove Stop


//Checkbox Remove start - 10:04 30.07.2006
print ("<form method=post name=deleteall action=warn.php?action=admincpremovewarn>");
//Checkbox Remove Stop

print("<tr><td class=header align=center>ID</td><td class=header align=center>Username</td><td class=header align=center>Total Warns</td><td class=header align=center>Date added</td><td class=header align=center>Expiration date</td><td class=header align=center>Duration</td><td class=header align=center>Reason</td><td class=header align=center>Warned by</td><td class=header align=center>Active</td><td class=header align=center><input type=\"checkbox\" name=\"all\" onclick=\"SetAllCheckBoxes('deleteall','remwarn[]',this.checked)\" /></td></tr>");

if ("$num"=="0")
print("<tr><td class=lista align=center colspan=10>There are no warned users at this time.</td></tr>");
else
{

while ($arr = mysql_fetch_array($res))
{
if ($arr["warnedfor"]==0)
$duration = "Unlimited warn";
elseif ($arr['warnedfor']==1)
$duration = "".$arr['warnedfor']." week warn";
else
$duration = "".$arr['warnedfor']." weeks warn";

if ($arr["active"]=="no")
$active = "<font color=green><b>No</b></font>";
else
$active = "<font color=red><b>Yes</b></font>";

$get_staffname = mysql_query("SELECT username FROM users WHERE id = " . $arr['addedby']);
$warnedby = mysql_fetch_array($get_staffname);

$get_username = mysql_query("SELECT * FROM users WHERE id = " . $arr['userid']);
$warned = mysql_fetch_array($get_username);

print("<tr><td class=lista align=center>".$arr['id']."</td><td class=lista align=center><a href=userdetails.php?id=".$arr['userid'].">".$warned['username']."</a></td><td class=lista align=center><a href=listwarns.php?uid=".$arr['userid'].">".$warned['warns']."</a></td><td class=lista align=center>".$arr['added']."</td><td class=lista align=center>".$arr['expires']."</td><td class=lista align=center>".$duration."</td><td class=lista align=center>".$arr['reason']."</td><td class=lista align=center><a href=userdetails.php?id=".$arr['addedby'].">".$warnedby['username']."</a></td><td class=lista align=center>".$active."</td><td class=lista align=center><input type=\"checkbox\" name=\"remwarn[]\" value=\"".$arr[userid]."\" /></td></tr>");
}

}
print("<tr><td class=header align=center colspan=9><a href=\"javascript: history.go(-1);\">".BACK."</a></td><td class=header align=center colspan=1><input type=submit value=".DELETE."></td></tr>");
print ("</form>");


//Per Page Listing Limitation Start - 00:08 24.06.2006
if ($count > $perpage)
print("<tr><td class=lista align=center colspan=10><br>".$pagerbottom."</td></tr>");
//Per Page Listing Limitation Stop

print("</table>");


}
else
{
print("<table border=0 width=100% cellspacing=2 cellpadding=0><tr><td class=lista align=center>");

print("<br /><table align=\"center\" border=\"0\" width=\"500\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
print("<td class=\"lista\" align=\"center\" style=\"border-style: dotted; border-width: 1px\" bordercolor=\"#CC0000\">\n");
print("<font color=\"#CC0000\"><b>".ERROR."</b><br />".ERR_NOT_AUTH."<br /></font></td>\n");
print("</tr></table><br />\n");
print("<center><a href=javascript:history.go(-1)>".BACK."</a></center>");

print("</td></tr></table>");
block_end();
print ("<br>");
stdfoot();
exit;
}
block_end();
print ("<br>");
stdfoot();
?>


4.Създавате warn.php и слагате това:

<?php
require_once ("include/functions.php");
require_once ("include/config.php");
dbconn();
if (!$CURUSER || $CURUSER["edit_users"]!="yes")
{
require_once "include/functions.php";
require_once "include/config.php";
standardheader("Get a freakin' life and stop trying to hack the tracker !");
block_begin(ERROR);
err_msg("Error", "Piss off !!! Staff only !");
print ("<br>");
block_end();
stdfoot();
}
else
{
standardheader("User Warning System");

if (isset($_GET["action"])) $action=$_GET["action"];
else $action = "";

//warn users script bellow
if ($action=="warn")
{
if ($_POST["reason"] == "" ||$_POST["username"] == "" || $_POST["warnfor"] == "")
{
err_msg("Error", "Missing form data.");
}
else
{

$reason = $_POST["reason"];
$username = $_POST["username"];
$added = gmdate("Y-m-d H:i:s");
$warnedfor = $_POST["warnfor"];

//7 days warning period start
if ($_POST[warnfor] == 7)
{
$dayswarn = 7;
$weekswarn = $dayswarn/7;
$period = "a 1 week";
$expire = gmdate("d")+$dayswarn;
if ($expire >= 30)
{
$month = gmdate("m")+1;
$days = $expire-30;

if ($days <= 9)
{
if ($month <= 9)
$expiration = gmdate("Y-0".$month."-0".$days." H:i:s");
else
$expiration = gmdate("Y-".$month."-0".$days." H:i:s");
}
else
{
if ($month <= 9)
$expiration = gmdate("Y-0".$month."-".$days." H:i:s");
else
$expiration = gmdate("Y-".$month."-".$days." H:i:s");
}
}
else

if ($expire <= 9)
$expiration = gmdate("Y-m-0".$expire." H:i:s");
else
$expiration = gmdate("Y-m-".$expire." H:i:s");
}
//7 days warning period stop

//14 days warning period start
elseif ($_POST[warnfor] == 14)
{
$dayswarn = 14;
$weekswarn = $dayswarn/7;
$period = "a 2 weeks";
$expire = gmdate("d")+$dayswarn;
if ($expire >= 30)
{
$month = gmdate("m")+1;
$days = $expire-30;

if ($days <= 9)
{
if ($month <= 9)
$expiration = gmdate("Y-0".$month."-0".$days." H:i:s");
else
$expiration = gmdate("Y-".$month."-0".$days." H:i:s");
}
else
{
if ($month <= 9)
$expiration = gmdate("Y-0".$month."-".$days." H:i:s");
else
$expiration = gmdate("Y-".$month."-".$days." H:i:s");
}
}
else

if ($expire <= 9)
$expiration = gmdate("Y-m-0".$expire." H:i:s");
else
$expiration = gmdate("Y-m-".$expire." H:i:s");
}
//14 days warning period stop

//21 days warning period start
elseif ($_POST[warnfor] == 21)
{
$dayswarn = 21;
$weekswarn = $dayswarn/7;
$period = "a 3 weeks";
$expire = gmdate("d")+$dayswarn;
if ($expire >= 30)
{
$month = gmdate("m")+1;
$days = $expire-30;

if ($days <= 9)
{
if ($month <= 9)
$expiration = gmdate("Y-0".$month."-0".$days." H:i:s");
else
$expiration = gmdate("Y-".$month."-0".$days." H:i:s");
}
else
{
if ($month <= 9)
$expiration = gmdate("Y-0".$month."-".$days." H:i:s");
else
$expiration = gmdate("Y-".$month."-".$days." H:i:s");
}
}
else


if ($expire <= 9)
$expiration = gmdate("Y-m-0".$expire." H:i:s");
else
$expiration = gmdate("Y-m-".$expire." H:i:s");
}
//21 days warning period stop

//28 days warning period start
elseif ($_POST[warnfor] == 28)
{
$dayswarn = 28;
$weekswarn = $dayswarn/7;
$period = "a 4 weeks";
$expire = gmdate("m")+1;
($expire>=10?$expire:"0".$expire);
$expiration = gmdate("Y-".$expire."-d H:i:s");
}
//28 days warning period stop

//Unlimited warning period start
else
{
$dayswarn = "0";
$weekswarn = "0";
$period = "an unlimited";
$expiration = "0000-00-00 00-00-00";
}
//Unlimited warning period start

//Prepare the variables for insertion in the DB
$userid = $_GET["id"];
$url = $_GET["returnto"];
$active = "yes";


$sqluserid = sqlesc($_GET["id"]);
$sqladded = sqlesc($added);
$sqlexpires = sqlesc($expiration);
$sqlwarnedfor = sqlesc($weekswarn);
$sqlreason = sqlesc($HTTP_POST_VARS["reason"]);
$sqladdedby = sqlesc($CURUSER["uid"]);
$sqlactive = sqlesc($active);
$sqlusername = sqlesc($HTTP_POST_VARS["username"]);

$warns = mysql_query("SELECT warns FROM users WHERE id=$sqluserid");
$warnings = mysql_fetch_array($warns);
$sqlwarns = sqlesc($warnings[warns]+1);

$staff = mysql_query("SELECT username FROM users WHERE id=$sqladdedby");
$staffname = mysql_fetch_array($staff);
$subj = sqlesc("<b><font color=red>WARNING !!!</font></b>");
$msg = sqlesc("You have received ".$period." warning from ".$staffname[username]." because: ".$reason.".");

//for testing purposes - you can delete all commented code bellow
//print("Reason: ".$reason."");
//print("<br>Username: ".$username."");
//print("<br>Warnedfor: ".$weekswarn." (".$weekswarn." weeks = ".$dayswarn." days)");
//print("<br>Userid: ".$userid."");
//print("<br>Redirect: ".$url."");
//print("<br>Added: ".$added."");
//print("<br>Expires: ".$expiration."");
//print("<br>Added by: ".$CURUSER["uid"]."");
//print("<br>Active: ".$active."");
//print("<br><br><br>");
//print("".$warnedfor."<br />");
//print("SQLs:");
//print("<br>sql1: mysql_query(\"INSERT INTO warnings (userid,added,expires,warnedfor,reason,addedby,active) VALUES ($sqluserid,$sqladded,$sqlexpires,$sqlwarnedfor,$sqlreason,$sqladdedby,$sqlactive)\") or sqlerr();");
//print("<br>sql2: mysql_query(\"UPDATE users SET warns=warns+1 WHERE id=$sqluserid AND username=$sqlusername LIMIT 1\") or sqlerr();");
//print("<br>sql3: mysql_query(\"INSERT INTO messages (sender, receiver, added, msg, subject) VALUES($sqladdedby,$sqluserid,UNIX_TIMESTAMP(),$msg,$subj)\") or sqlerr(__FILE__, __LINE__);");
//for testing purposes only - you can delete all commented out code above

//Executing the queries with the above info
mysql_query("UPDATE users SET warns=warns+1 WHERE id=$sqluserid AND username=$sqlusername LIMIT 1") or sqlerr();
mysql_query("INSERT INTO warnings (userid,warns,added,expires,warnedfor,reason,addedby,active) VALUES ($sqluserid,$sqlwarns,$sqladded,$sqlexpires,$sqlwarnedfor,$sqlreason,$sqladdedby,$sqlactive)") or sqlerr();
mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(666666,$sqluserid,UNIX_TIMESTAMP(),$msg,$subj)") or sqlerr(__FILE__, __LINE__);
redirect($url);
}
}

//remove warn from users script bellow
elseif ($action=="removewarn")
{
$username = $_GET["username"];
$url = $_GET["returnto"];

$sqluserid = sqlesc($_GET["id"]);
$sqlusername = sqlesc($_GET["username"]);
$sqlremover = sqlesc($_GET["remover"]);
$subj = sqlesc("<b><font color=green>WARN Removed !!!</font></b>");
$msg = sqlesc("Your warning has been removed by ".$CURUSER['level']." ".$username.".");

//for testing purposes - you can delete all commented code bellow
//print("userid: ".$userid.", username: ".$username.", remover: ".$remover.", redirect: ".$url."<br><br>");
//print("SQLs:");
//print("<br>sql1: mysql_query(\"UPDATE warnings SET active='no' WHERE userid=$sqluserid LIMIT 1\") or sqlerr();");
//print("<br>sql2: mysql_query(\"UPDATE users SET warnremovedby=$sqlremover WHERE id=$sqluserid AND username=$sqlusername LIMIT 1\") or sqlerr();");
//print("<br>sql3: mysql_query(\"INSERT INTO messages (sender, receiver, added, msg, subject) VALUES($sqlremover,$sqluserid,UNIX_TIMESTAMP(),$msg,$subj)\") or sqlerr(__FILE__, __LINE__);");
//for testing purposes only - you can delete all commented out code above

mysql_query("UPDATE warnings SET active='no' WHERE userid=$sqluserid AND active='yes' LIMIT 1") or sqlerr();
mysql_query("UPDATE users SET warnremovedby=$sqlremover WHERE id=$sqluserid AND username=$sqlusername LIMIT 1") or sqlerr();
mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(666666,$sqluserid,UNIX_TIMESTAMP(),$msg,$subj)") or sqlerr(__FILE__, __LINE__);
redirect($url);
}


//remove warn from admincp.php script bellow
elseif ($action=="admincpremovewarn")
{

if (empty($_POST["remwarn"]))
{
$url = "admincp.php?do=warnedu";
redirect($url);
}
else
{
//get data for queries
$url = "admincp.php?do=warnedu";
$userid = implode(", ", $_POST[remwarn]);
$sqluserid = sqlesc($userid);
$sqlremover = sqlesc($CURUSER[uid]);
$subj = sqlesc("<b><font color=green>WARN Removed !!!</font></b>");
$msg = sqlesc("Your warning has been removed by ".$CURUSER['level']." ".$CURUSER[username].".");


//***********execute the queries***********
//update warnings table
mysql_query("UPDATE warnings SET active='no' WHERE userid IN (".implode(", ", $_POST[remwarn]).") AND active='yes'") or sqlerr();

//update users table
mysql_query("UPDATE users SET warnremovedby=$sqlremover WHERE id IN (".implode(", ", $_POST[remwarn]).") ") or sqlerr();

//send a private message to every user that got his warn removed
$message = mysql_query("SELECT username, id FROM users WHERE id IN (".implode(", ", $_POST[remwarn]).") ") or sqlerr();
while ($get_id = mysql_fetch_array($message))
{
$uid=$get_id[id];
mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(666666,$uid,UNIX_TIMESTAMP(),$msg,$subj)") or sqlerr(__FILE__, __LINE__);
}

//redirect back to admincp
redirect($url);
}
}


//reset user warn level script bellow
elseif ($action=="resetwarnlevel")
{
//get data for queries
$userid = $_GET[uid];
$url = $_GET[returnto];

//subject & body for the private message
$subj = sqlesc("<b><font color=green>Warn Level Reset !!!</font></b>");
$msg = sqlesc("Your Warning Level has been reset by ".$CURUSER['level']." ".$CURUSER[username].".");


//***********execute the queries***********
//update warnings table
mysql_query("DELETE FROM warnings WHERE userid='$userid'") or sqlerr();

//update users table
mysql_query("UPDATE users SET warns='0', warnremovedby='0' WHERE id='$userid' ") or sqlerr();

//send a private message to every user that got his warn removed
$message = mysql_query("SELECT username, id FROM users WHERE id='$userid' ") or sqlerr();
$get_id = mysql_fetch_array($message);
$uid=$get_id[id];
mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(666666,$uid,UNIX_TIMESTAMP(),$msg,$subj)") or sqlerr(__FILE__, __LINE__);

//redirect back to admincp
redirect($url);
}


//disable account script bellow
elseif ($action=="disable")
{
//get data for queries
$disabled = $_POST[disable];
$reason = $_POST[reason];
$username = $_POST[name];
$userid = $_POST[id];
$url = $_GET[returnto];
$datetime = gmdate("Y-m-d H:i:s");

if (!$reason)
{
redirect($url);
}
else
{

if ("$disabled" == "no")
{
redirect($url);
}
else
{
//***********execute the queries***********
$warnstats = mysql_query("SELECT * FROM warnings WHERE userid='$userid' AND active='yes'");
if (mysql_num_rows($warnstats) >= 1)
{
//update warnings table
mysql_query("UPDATE warnings SET active='no' WHERE userid='$userid' AND active='yes'") or sqlerr();
//update users table
mysql_query("UPDATE users SET warnremovedby='".$CURUSER[uid]."', disabled='yes', disabledby='".$CURUSER[uid]."', disabledon='$datetime', disabledreason='$reason' WHERE id='$userid' AND username='$username'") or sqlerr();
}
else
{
//update users table
mysql_query("UPDATE users SET disabled='yes', disabledby='".$CURUSER[uid]."', disabledon='$datetime', disabledreason='$reason' WHERE id='$userid' AND username='$username'") or sqlerr();
}

//redirect back to userdetails
redirect($url);
}
}
}


//enable account script bellow
elseif ($action=="enable")
{
//get data for queries
$disabled = $_POST[disable];
$username = $_POST[name];
$userid = $_POST[id];
$url = $_GET[returnto];

if ("$disabled" == "yes")
{
redirect($url);
}
else
{
//***********execute the queries***********
//update users table
mysql_query("UPDATE users SET warnremovedby='0', disabled='no', disabledby='0', disabledon='0000-00-00 00:00:00', disabledreason=NULL WHERE id='$userid' AND username='$username'") or sqlerr();

//redirect back to userdetails
redirect($url);
}
}
}
?>


5. Сега - listwarns.php

<?php
require_once ("include/functions.php");
require_once ("include/config.php");

dbconn();
standardheader("".$CURUSER['username']."'s warning list");

//begin user warnings private page
block_begin("".$CURUSER['username']."'s warning list");

$userid = $_GET["uid"];

//check to see if user is owner of account or if user has admin_access
if (!$CURUSER || $CURUSER["admin_access"]=="yes" || $CURUSER["edit_users"]=="yes" || $CURUSER["uid"]=="$userid")

{
if (isset($_GET["action"])) $action=$_GET["action"];
else $action = "";

if ($action=="uid")
{

if ($_GET["uid"] == "")
{
err_msg("Error", "Missing form data.");
}

}

//gather warnings from database
$warns = mysql_query("SELECT * FROM warnings WHERE userid=$userid") or sqlerr();
$num = mysql_num_rows($warns);

//begin to print the list of warns
print("<table border=0 width=100% cellspacing=2 cellpadding=0>");
print("<tr><td class=header align=center>ID</td><td class=header align=center>Date added</td><td class=header align=center>Expiration date</td><td class=header align=center>Duration</td><td class=header align=center>Reason</td><td class=header align=center>Warned by</td><td class=header align=center>Active</td>
</tr>");

//if user has no warns (active or not) print a "no warns" message
if ("$num"=="0")
print("<tr><td class=lista align=center colspan=7>This user has no standing warnings.</td></tr>");
else
{

//print list of warns
while ($arr = mysql_fetch_assoc($warns))
{
if ($arr["warnedfor"]==0)
$duration = "Unlimited warn";
elseif ($arr['warnedfor']==1)
$duration = "".$arr['warnedfor']." week warn";
else
$duration = "".$arr['warnedfor']." weeks warn";

if ($arr["active"]=="no")
$active = "<font color=green><b>No</b></font>";
else
$active = "<font color=red><b>Yes</b></font>";

$get_staffname = mysql_query("SELECT username FROM users WHERE id = " . $arr['addedby']);
$warnedby = mysql_fetch_array($get_staffname);

print("<tr><td class=lista align=center>".$arr['id']."</td><td class=lista align=center>".$arr['added']."</td><td class=lista align=center>".$arr['expires']."</td><td class=lista align=center>".$duration."</td><td class=lista align=center>".$arr['reason']."</td><td class=lista align=center><a href=userdetails.php?id=".$arr['addedby'].">".$warnedby['username']."</a></td><td class=lista align=center>".$active."</td></tr>");
}
}
print("<tr><td class=header align=center colspan=7><a href=\"javascript: history.go(-1);\">".BACK."</a></td></tr>");
print("</table>");
//end list of warns

}
else
{
print("<table border=0 width=100% cellspacing=2 cellpadding=0><tr><td class=lista align=center>");

print("<br /><table align=\"center\" border=\"0\" width=\"500\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n");
print("<td class=\"lista\" align=\"center\" style=\"border-style: dotted; border-width: 1px\" bordercolor=\"#CC0000\">\n");
print("<font color=\"#CC0000\"><b>".ERROR."</b><br />".ERR_NOT_AUTH."<br /></font></td>\n");
print("</tr></table><br />\n");
print("<center><a href=javascript:history.go(-1)>".BACK."</a></center>");

print("</td></tr></table>");
block_end();
print ("<br>");
stdfoot();
exit;
}
block_end();
print ("<br>");
stdfoot();
?>


6. Сега отваряте config.php и намирате:

$GLOBALS["usepopup"] = false;


Добавяте след него:

//user warning system hack
//the number of warnings an account get's disabled at
$warntimes ="3";
//number of warns per page listed in admincp
$warnsppage ="25";


7. Сега functions.php намирате:

$query="select prefixcolor, suffixcolor, users.id, downloaded,uploaded, IF(downloaded>0,uploaded/downloaded,0) as ratio, username,level,UNIX_TIMESTAMP(joined) AS joined,UNIX_TIMESTAMP(lastconnect) AS lastconnect, flag, flagpic, name FROM users INNER JOIN users_level ON users.id_level=users_level.id LEFT JOIN countries ON users.flag=countries.id WHERE users.id>1 $where ORDER BY $order $by $limit";


В реда
$query="select prefixcolor, suffixcolor,
Го заменете с то
$query="select prefixcolor, suffixcolor, users.disabled,


Намирате:

while ($row_user=mysql_fetch_array($rusers))
{


Добавяте след него:

//User Warning System Hack Start - 6:04 PM 9/2/2006
$warn_stats = mysql_query("SELECT * FROM warnings WHERE userid = ".$row_user["id"]." AND active='yes'");
$warn_stat = mysql_num_rows($warn_stats);
if ("$warn_stat"=="0")
$warned = "";
else
$warned = "<img src=\"images/warned.gif\" border=\"0\" title=\"This user has been warned. For more details see the FAQ\" />";
//User Warning System Hack Stop
//Account Disabled Hack Start
if ($row_user[disabled] == "no")
$disabled = "";
else
$disabled = " <img src=\"images/disabled.gif\" border=\"0\" title=\"This account has been disabled. For more details see the FAQ\" />";
//Account Disabled Hack Stop


Намерете:
print("<td class=\"lista\"><a href=userdetails.php?id=".$row_user["id"].">".unesc($row_user["prefixcolor"]).unesc($row_user["username"]).unesc($row_user["suffixcolor"])."</a></td>");


И го заменете с:
print("<td class=\"lista\"><a href=userdetails.php?id=".$row_user["id"].">".unesc($row_user["prefixcolor"]).unesc($row_user["username"]).unesc($row_user["suffixcolor"])."</a>".$warned."".$disabled."</td>");


include/sanity.php
Намирате:

global $PRIVATE_ANNOUNCE, $TORRENTSDIR, $CURRENTPATH,$LIVESTATS,$LOG_HISTORY;


Заменете global с global $warntimes,

Намирате:
}
?>

И го заменяте с:

//AutoRemove User Warnings Upon Expiration Hack Start - 11:54 01.07.2006
$datetime = gmdate("Y-m-d H:i:s");
$subj = sqlesc("<b><font color=green>WARN EXPIRED !!!</font></b>");
$msg = sqlesc("Your warning expired and has been removed by the System.");
$warnstats = mysql_query("SELECT * FROM warnings WHERE expires <= '$datetime' AND active='yes'");
while ($arr = mysql_fetch_assoc($warnstats))
{
if (mysql_num_rows($warnstats) > 0)
{//User Warning System Hack Start
print("\n<td class=\"header\" align=\"center\"><a href=\"admincp.php?do=warnedu\">".ACP_WARNEDU."</a></td>");
//User Warning System Hack Stop
$numwarns = $arr["warns"];
if ("$numwarns" >= "$warntimes")
{
$reason="Maximum number of warnings reached!";
mysql_query("UPDATE warnings SET active='no' WHERE userid='$arr[userid]' AND active='yes'") or sqlerr();
mysql_query("UPDATE users SET warnremovedby='666666', disabled='yes', disabledby='666666', disabledon=UNIX_TIMESTAMP(), disabledreason='$reason' WHERE id='$arr[userid]' AND username='$name'") or sqlerr();
}
else
{
if ($arr["warnedfor"] == "0")
{
}
else
{
mysql_query("UPDATE warnings SET active='no' WHERE userid='$arr[userid]' AND active='yes'") or sqlerr();
mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES('2','$arr[userid]',UNIX_TIMESTAMP(),$msg,$subj)") or sqlerr(__FILE__, __LINE__);
mysql_query("UPDATE users SET warnremovedby='2' WHERE id='$arr[userid]' AND username='$name'") or sqlerr();
}
}
}
}
//AutoRemove user Warnings Upon Expiration Hack Stop


adminc.php

Намирате:

print("\n<td class=\"header\" align=\"center\"><a href=\"admincp.php?do=searchdiff\">Search Diff.</a></td>");

След него:

//User Warning System Hack Start
print("\n<td class=\"header\" align=\"center\"><a href=\"admincp.php?do=warnedu\">".ACP_WARNEDU."</a></td>");
//User Warning System Hack Stop

Намирате:

elseif ($do=="logview")
{
include("include/sitelog.php");
}


След него:

//User Warning System Hack Start
elseif ($do=="warnedu")
{
include("warnedusers.php");
}
//User Warning System Hack Stop

НАМИРАТЕ:

<tr><td class="header">Limit for Most Popular Torrents block:</td><td class="lista"><input type="text" name="mostpoplimit" value="<?php echo $GLOBALS["block_mostpoplimit"];?>" size="3" maxlength="3" /></td></tr>


СЛЕД НЕГО:

<!-- User Warning System Hack Start -->
<tr><td class="header" align="center" colspan=2>User Warning System Settings</td></tr>
<tr><td class="header">Accounts get disabled after:<br><font size=1 color=green>(number of warns an account get's disabled after)</font></td><td class="lista"><input type="text" name="warned" value="<?php echo $GLOBALS["warntimes"];?>" /></td></tr>
<tr><td class="header">Warnings per page:<br><font size=1 color=green>(number of warns listed per page in admincp)</font></td><td class="lista"><input type="text" name="warnsppage" value="<?php echo $GLOBALS["warnsppage"];?>" /></td></tr>
<!-- User Warning System Hack Stop -->


НАМИРАТЕ:

$foutput.= "\$GLOBALS[\"usepopup\"] = " . $_POST["usepopup"] . ";\n";


СЛЕД НЕГО:

//User Warning System Hack Start - 00:45 08.08.2006
$foutput.= "//user warning system hack\n";
$foutput.= "//the number of warnings an account get's disabled at\n";
$foutput.= "\$warntimes =\"".$_POST["warned"]."\";\n";
$foutput.= "//number of warns per page listed in admincp\n";
$foutput.= "\$warnsppage =\"".$_POST["warnsppage"]."\";\n";
//User Warning System Hack Stop




Ще продължим във втора част с userdetails.php :)







/ Трябва да сте регистриран за да напишете коментар /