Ad this in Sql
ALTER TABLE users ADD `lowratio` enum('yes','no')
And this in cleanup.php
PHP Code:
$minratio = 0.5; // min ratio
$downloaded = 1*1024*1024*1024; // min gigs downloaded
$length = 2*7; // days to warn
// ADD WARNING
$res = mysql_query("SELECT id, username, modcomment, uploaded, downloaded, lowratio FROM users WHERE class = 1 AND warned = 'no' AND enabled= 'yes' AND uploaded / downloaded < $minratio AND downloaded >= $downloaded");
if (mysql_num_rows($res) > 0){
$timenow = get_date_time();
$reason = "Ai fost avertizat pentru ca ai ratia prea mica. Trebuie sa o ridici peste [b]".$minratio."[/b] in urmatoarele [b]".$length."[/b] zile sau contul tau va fi dezactivat.";
$until = sqlesc(get_date_time(gmtime() + ($length*86400)));
while ($arr = mysql_fetch_assoc($res)){
$ratio = number_format($arr["uploaded"] / $arr["downloaded"], 3);
$modcomment = htmlspecialchars($arr["modcomment"]);
$modcomment = gmdate("Y-m-d H:i") . " - Warned for low ratio by System.\n(UL=".prefixed($arr['uploaded']).", DL=".prefixed($arr['downloaded']).", Ratio=".$ratio.")\n".$modcomment;
$modcom = sqlesc($modcomment);
mysql_query("UPDATE users SET warned = 'yes', warneduntil = $until, lowratio = 'yes', modcomment = $modcom WHERE id=$arr[id]");
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES ('0', '".$arr["id"]."', '".$timenow."', '".$reason."', '0')");
write_log("Auto Leech Warning has been added for: <b>".$arr["username"]."</b>");
}
}
// REMOVE WARNING
$res1 = mysql_query("SELECT users.id, users.username FROM users WHERE warned = 'yes' AND enabled='yes' AND lowratio='yes' AND uploaded / downloaded >= $minratio AND downloaded >= $downloaded");
if (mysql_num_rows($res1) > 0){
$timenow = get_date_time();
$reason = "Avertizarea pentru ratie prea mica a fost inlaturata. Pastreaza ratia la o valoare ridicata pentru a nu fi avertizat din nou.\n";
while ($arr1 = mysql_fetch_assoc($res1)){
mysql_query("UPDATE users SET warned = 'no', warneduntil = '0000-00-00 00:00:00', lowratio = 'no' WHERE id = '".$arr1["id"]."'");
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES ('0', '".$arr1["id"]."', '".$timenow."', '".$reason."', '0')");
write_log("Auto Leech Warning has been removed for: <b>".$arr1["username"]."</b>");
}
}
// DISABLE WARNED USERS
$res = mysql_query("SELECT id, username FROM users WHERE warned='yes' AND warneduntil < NOW() AND warneduntil <> '0000-00-00 00:00:00' AND lowratio='yes'") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0){
while ($arr = mysql_fetch_assoc($res)){
mysql_query("UPDATE users SET enabled = 'no', warneduntil = '0000-00-00 00:00:00' WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__);
}
}