today have a big problem...
this is my cleanup:
<?php
function do_cleanup() {
global $site_config;
//LOCAL TORRENTS - GET PEERS DATA AND UPDATE BROWSE STATS
$torrents = array();
$res = mysql_query("SELECT torrent, seeder, COUNT(*) AS c FROM peers GROUP BY torrent, seeder");
while ($row = mysql_fetch_assoc($res)) {
if ($row["seeder"] == "yes")
$key = "seeders";
else
$key = "leechers";
$torrents[$row["torrent"]][$key] = $row["c"];
}
$fields = explode(":", "comments:leechers:seeders");
$res = mysql_query("SELECT id, seeders, leechers FROM torrents WHERE external !='yes'");
while ($row = mysql_fetch_assoc($res)) {
$id = $row["id"];
$torr = $torrents[$id];
foreach ($fields as $field) {
if (!isset($torr[$field]))
$torr[$field] = 0;
}
$update = array();
foreach ($fields as $field) {
if ($torr[$field] != $row[$field])
$update[] = "$field = " . $torr[$field];
}
if (count($update))
mysql_query("UPDATE torrents SET " . implode(",", $update) . " WHERE id = $id AND external !='yes'");
}
// DELETE DOUBLE PEERS, (Toglie i peers morti da 1ora=3600 - 30min=1800)
// mysql_query("DELETE FROM peers WHERE ".gmtime()."-UNIX_TIMESTAMP(last_action) >= 1800");
// DELETE IP HISTORY, (Rimuove gli IP inutilizzati da 14 gg)
// mysql_query("DELETE FROM iplog WHERE lastused >= FROM_UNIXTIME(".(gmtime() - 1209600).")");
//LOCAL TORRENTS - MAKE NON-ACTIVE/OLD TORRENTS INVISIBLE
$deadtime = gmtime() - $site_config["max_dead_torrent_time"];
mysql_query("UPDATE torrents SET visible='no' WHERE visible='yes' AND last_action < FROM_UNIXTIME($deadtime) AND external !='yes'");
//PROMOTE USERS TO UPLOADER
//IF YOUR DEFAULT USERS CLASS IS NOT 1, CHANGE IT
//IF YOUR DEFAULT POWER USER CLASS IS NOT 2, CHANGE IT
//10 GB = 10737418240
//1 GB = 1073741824
//This variable containes the needed amount of uploaded data
$up = 134217728000;
mysql_query("UPDATE users SET class = '2' WHERE uploaded > '$up' AND class = '1'");
/////////Update Seederbonus by speed/////////
/// MOD from TBDEV - dottor
/// edited and adapted by MasterRoot
/// www.maniatorrent.org
/////////////////////////////////////////////////////
$res = mysql_query("SELECT DISTINCT userid FROM peers WHERE seeder = 'yes'") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0)
{
while ($arr = mysql_fetch_assoc($res))
{
$work = mysql_query("select count(*) from peers WHERE seeder ='yes' AND userid = $arr[userid]");
$row_count = mysql_result($work,0,"count(*)");
$speedu = mysql_query("SELECT sum(((p.uploaded - p.uploadoffset )) / (unix_timestamp(p.last_action) - unix_timestamp(p.started))) AS speed FROM peers p INNER JOIN users u ON p.userid=u.id WHERE u.id=$arr[userid]");
if($speeduu > "100.00")
$bonuspay="0.750"; //// if over 100kbs = 3 per hr
elseif($speeduu > "75.00")
$bonuspay="0.500"; //// if over 75 but less than 100 = 2.0 per hr
elseif($speeduu > "50.00")
$bonuspay="0.375"; //// if over 50kbs but under 75kbs = 1.5 per hr
elseif($speeduu > "30.00")
$bonuspay="0.250"; /// if over 30kbs but under 50 kbs = 1.0 an hr
elseif($speeduu > "15.00")
$bonuspay="0.1875"; //// if over 15 kbs but less than 30kbs = .75 per hr
elseif($speeduu > "1.00")
$bonuspay="0.125"; //// if over 1kbs but less than 15kbs = .5 per hr
elseif($speeduu < "1.00")
$bonuspay="0.0225"; //// less than kb/s = 1/4 per hr
mysql_query("UPDATE users SET seedbonus = seedbonus+$bonuspay*$row_count WHERE id = $arr[userid]") or sqlerr(__FILE__, __LINE__);
}
}
/////////End Update Seederbonus by speed/////////
/// MOD from TBDEV - dottor
/// edited and adapted by MasterRoot
/// www.maniatorrent.org
/////////////////////////////////////////////////////
//DELETE OLD NON-ACTIVE PEERS
$res = mysql_query("DELETE FROM peers WHERE ".gmtime()."-UNIX_TIMESTAMP(last_action) >= 1800");
//DELETE PENDING USER ACCOUNTS OVER TIMOUT AGE
$deadtime = gmtime() - $site_config["signup_timeout"];
mysql_query("DELETE FROM users WHERE status = 'pending' AND added < FROM_UNIXTIME($deadtime)");
//LEECHWARN USERS WITH LOW RATIO
if ($site_config["ratiowarn_enable"]){
$minratio = $site_config["ratiowarn_minratio"];
$downloaded = $site_config["ratiowarn_mingigs"]*1024*1024*1024;
$length = $site_config["ratiowarn_daystowarn"];
//ADD WARNING
$res = mysql_query("SELECT id,username 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 = "You have been warned because of having low ratio. You need to get a ".$minratio." before next ".$length." days or your account may be banned.";
$expiretime = gmdate("Y-m-d H:i:s", gmtime() + (86400 * $length));
while ($arr = mysql_fetch_assoc($res)){
mysql_query("INSERT INTO warnings (userid, reason, added, expiry, warnedby, type) VALUES ('".$arr["id"]."','".$reason."','".$timenow."','".$expiretime."','0','Poor Ratio')");
mysql_query("UPDATE users SET warned='yes' 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 <B>added</B> for: <a href=account-details.php?id=".$arr["id"].">".$arr["username"]."</a>");
}
}
//REMOVE WARNING
$res1 = mysql_query("SELECT id,username FROM users WHERE warned = 'yes' AND enabled='yes' AND uploaded / downloaded >= $minratio AND downloaded >= $downloaded");
if (mysql_num_rows($res1) > 0){
$timenow = get_date_time();
$reason = "Your warning of low ratio has been removed. We highly recommend you to keep a your ratio up to not be warned again.\n";
while ($arr1 = mysql_fetch_assoc($res1)){
write_log("Auto Leech warning has been removed for: <a href=account-details.php?id=".$arr1["id"].">".$arr1["username"]."</a>");
mysql_query("UPDATE users SET warned = 'no' WHERE id = '".$arr1["id"]."'");
mysql_query("UPDATE warnings SET expiry = '".$timenow."' WHERE userid = '".$arr1["id"]."'");
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES ('0', '".$arr1["id"]."', '".$timenow."', '".$reason."', '0')");
}
}
//BAN WARNED USERS
$res = mysql_query("SELECT id,username FROM users WHERE class = 1 AND enabled='yes' AND warned = 'yes' AND uploaded / downloaded < $minratio AND downloaded >= $downloaded");
if (mysql_num_rows($res) > 0){
$timenow = get_date_time();
$expires = (86400 * $length);
while ($arr = mysql_fetch_assoc($res)){
$r = mysql_query("SELECT id, UNIX_TIMESTAMP(expiry) as expiry FROM warnings WHERE userid=$arr[id]");
$row = mysql_fetch_assoc($r);
if (gmtime() - $row["expiry"] >= 0) {
mysql_query("UPDATE users SET enabled='no', warned='no' WHERE id='".$arr["id"]."'");
write_log("User <a href=account-details.php?id=".$arr["id"].">".$arr["username"]."</a> has been banned (Auto Leech warning).");
}
}
}
}//check if warning system is on
//END//
//TOTAL SEED TIME
$res = mysql_query("SELECT DISTINCT userid FROM peers WHERE seeder = 'yes'") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0)
{
while ($arr = mysql_fetch_assoc($res))
{
mysql_query("UPDATE users SET seed_time = seed_time+$site_config[autoclean_interval]");
}
}
//OPTIMISE TABLES
mysql_query("OPTIMIZE TABLE `peers` , `torrents` , `tasks` , `guests` , `users` , `messages`; ");
}//end func
?>
every time i force a clean, my seed point add + 0.3
and not count a speed!
if i seed to 1k i force clean and my point +0.3
if i seed to 60k i froce clean and my point +0.3
if i force a clean 3 times my point +0.3 +0.3 +0.3 everytime!!!
HELP!!!