hello.
my question is just, when i run this query it will only select user who have a ratio less thanm 0.50, but some users screw up their ratio because of the anti hit and run system so they get a - (minus) in their ratio. The problem is then that the query bellow doesnt select the negative ratio. Why?
$autowarn=mysql_query("SELECT id, warns FROM users WHERE id_level>=3 AND id_level<=6 AND downloaded>5368709120 AND uploaded/downloaded<0.50 AND disabled='no' AND awarn='no'");
//$autowarn=mysql_query("SELECT id FROM users WHERE downloaded>5368709120 AND uploaded/downloaded<0.50 AND disabled='no' AND awarn='no'");
Full code:
//AutoWarn Low Ratio User Start - 14:32 3/10-2007
$autowarn=mysql_query("SELECT id, warns FROM users WHERE id_level>=3 AND id_level<=6 AND downloaded>5368709120 AND uploaded/downloaded<0.50 AND disabled='no' AND awarn='no'");
//$autowarn=mysql_query("SELECT id FROM users WHERE downloaded>5368709120 AND uploaded/downloaded<0.50 AND disabled='no' AND awarn='no'");
$period = "a 1 week";
$reason = "your ratio is under 0.5";
$subj = sqlesc("WARNING !!!");
$msg = sqlesc("You have received [b]".$period." warning[/b] from [b]The System[/b] because: [b]".$reason."[/b].");
$added = gmdate("Y-m-d H:i:s");
$sqladded = sqlesc($added);
$expiration = date("Y-m-d H:i:s", mktime( date("H"), date("i"), date("s"), date(m), date(d)+7,date(Y)));
$warnedfor = "1";
$addedby = "0";
$active = "yes";
function warn_expiration($timestamp = 0)
{
return date("Y-m-d H:i:s", $timestamp);
}
while($warn=mysql_fetch_assoc($autowarn)) {
$warnings = mysql_fetch_array($autowarn);
$sqlwarns = sqlesc($warn[warns]+1);
//Executing the queries with the above info
mysql_query("Update users SET warns=warns+1 WHERE id=$warn[id]") or sqlerr();
mysql_query("Update users SET awarn='yes' WHERE id=$warn[id]") or sqlerr();
mysql_query("INSERT INTO warnings (userid,warns,added,expires,warnedfor,reason,addedby,active) VALUES ('$warn[id]',$sqlwarns,'$added','$expiration','$warnedfor','$reason','$addedby','$active')") or sqlerr();
mysql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0,'$warn[id]',UNIX_TIMESTAMP(),$msg,$subj)") or sqlerr(__FILE__, __LINE__);
}
//AutoWarn Low Ratio User Ends
Another way to might maybe fix this is to change the punish hack for hit and runners, like add so they never get a negative upload stats. it will allways be 0 and then they should be selected from the query above?
Do not know how to do that.
The code looks like this:
//CobraCRK's Anti Hit&Run Mod v1 Start
if ($GLOBALS["enable_hr"] == true)
{
$res = mysql_query("SELECT pid, infohash FROM peers WHERE status = 'seeder'");
if (mysql_num_rows($res) > 0)
{
while ($arr = mysql_fetch_assoc($res))
{
$x=$arr['pid'];
$t=$arr['infohash'];
$pl=mysql_query("SELECT id FROM users WHERE pid='$x'");
$ccc=mysql_result($pl,0,"id");
mysql_query("UPDATE history SET seed = seed+1800 WHERE uid = $ccc AND infohash='$t'");
}
}
$r=mysql_query("SELECT uid,infohash FROM history WHERE active='no' AND hit=0 AND date < ( UNIX_TIMESTAMP( ) - 604800) AND downloaded>104857600 AND seed<72000 AND uploaded/downloaded<0.60 ");
echo mysql_num_rows($r);
while($x = mysql_fetch_array($r)){
$t=mysql_query("SELECT username FROM users WHERE id=$x[uid]");
$xa=mysql_result($t,0,"username");
echo "$xa ";
$a=mysql_query("SELECT id_level FROM users WHERE id=$x[uid] LIMIT 1");
$p=mysql_result($a,0,"id_level");
if($p<4)
{
@mysql_query("Update users SET uploaded=uploaded-3221225472 WHERE id=$x[uid]");
@mysql_query("INSERT INTO messages (sender, receiver, added, subject, msg) VALUES (0,$x[uid],UNIX_TIMESTAMP(),'You are a hit&runner','You have made hit&run at the torrent: [URL]$BASEURL/details.php?id=$x[infohash][/URL] ! Your upload is now 3GB lower! Continue this way and you shall be banned soon!')");
@mysql_query("Update history SET hit=2 WHERE uid=$x[uid] AND infohash='$x[infohash]'");
// echo "Update history SET hit=2 WHERE uid=$x[uid] AND infohash=$x[infohash]";
}
}
}
//CobraCRK's Anti Hit&Run Mod v1 Ends