0) { while ($arr = mysql_fetch_assoc($res)) { $modcomment = sqlesc(gmdate("Y-m-d") . " - Auto-disabled for inactivity By System\n"); $users_buffer[] = '(' . $arr['id'] . ', \'no\', ' . $modcomment . ')'; } if (sizeof($users_buffer) > 0) { @mysql_query("INSERT INTO users (id, enabled, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE enabled=values(enabled), modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); $count = mysql_affected_rows(); write_log("Cleanup: Disabled " . $count . " Member(s) for inactivity"); } unset ($users_buffer); } //==End //remove expired warnings $res = mysql_query("SELECT id FROM users WHERE warned=1 AND warneduntil < NOW() AND warneduntil <> '0000-00-00 00:00:00'") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { $dt = sqlesc(get_date_time()); $msg = sqlesc("Your warning has been removed. Please keep in your best behaviour from now on.\n"); while ($arr = mysql_fetch_assoc($res)) { mysql_query("UPDATE users SET warned = 0, warneduntil = '0000-00-00 00:00:00' WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__); mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id], $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__); } } // Update stats $seeders = get_row_count("peers", "WHERE seeder='yes'"); $leechers = get_row_count("peers", "WHERE seeder='no'"); mysql_query("UPDATE avps SET value_u=$seeders WHERE arg='seeders'") or sqlerr(__FILE__, __LINE__); mysql_query("UPDATE avps SET value_u=$leechers WHERE arg='leechers'") or sqlerr(__FILE__, __LINE__); //Delete 30 day Old PMs $secs = 2592000; $dt = sqlesc(get_date_time(gmtime() - $secs)); mysql_query("DELETE FROM messages WHERE added < $dt"); //Delete 30 day old unfilled requests $secs = 2592000; $dt = sqlesc(get_date_time(gmtime() - $secs)); mysql_query("DELETE FROM requests WHERE added < $dt AND filledby=0"); // update forum post/topic count $forums = mysql_query("select id from forums"); while ($forum = mysql_fetch_assoc($forums)) { $postcount = 0; $topiccount = 0; $topics = mysql_query("select id from topics where forumid=$forum[id]"); while ($topic = mysql_fetch_assoc($topics)) { $res = mysql_query("select count(*) from posts where topicid=$topic[id]"); $arr = mysql_fetch_row($res); $postcount += $arr[0]; ++$topiccount; } mysql_query("update forums set postcount=$postcount, topiccount=$topiccount where id=$forum[id]"); } //Update Active Users $dt = gmtime() - 180; $dt = sqlesc(get_date_time($dt)); $sql = 'SELECT id, username, class,donor,warned FROM users WHERE last_access >= '.$dt.' ORDER BY username'; $res = mysql_query($sql); $output = ''; while($row = mysql_fetch_assoc($res)) { $output .= $row['id'].' '.$row['username'].' '.$row['class'].' '.$row['donor'].' '.$row['warned']."\n"; } $fh = @fopen("/home/pat/proaudiotorrents.org/public_html/cache-online.txt","w"); @fputs ($fh,"$output\n"); @fclose ($fh); // Promote Users $resap = mysql_query("SELECT * FROM classes where autolevel='yes' ORDER by class DESC"); while ($arrap = mysql_fetch_array($resap)) { $minjoin = sqlesc(get_date_time(gmtime() - $arrap[mintime])); $minupload = $arrap["minupload"]; $maxupload = $arrap["maxupload"]; $minratio = $arrap["minratio"]; $class = $arrap["class"]; $msg = sqlesc("Congratulations, you have been auto-promoted to [b]" . $arrap["classname"] . "[/b]. :)\n You must keep your ratio above $arrap[minratio] to keep this class"); $res = mysql_query("SELECT id, username FROM users WHERE class < $class AND uploaded >= $minupload AND uploaded / downloaded >= $minratio"); if (mysql_num_rows($res) > 0) { while ($arr = mysql_fetch_assoc($res)) { $dt = sqlesc(get_date_time()); $text = sqlesc("\n" . get_date_time() . " Auto Promoted to $arrap[classname]"); mysql_query("UPDATE users SET class = $arrap[class], invites = $arrap[invites], modcomment=CONCAT(modcomment,$text) WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__); mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id], $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__); // status_change($arr['id']); } } } //Demote Users $resap = mysql_query("SELECT * FROM classes where autolevel='yes'"); while ($arrap = mysql_fetch_array($resap)) { $res = mysql_query("SELECT id FROM users WHERE class = " . $arrap["class"] . " AND uploaded / downloaded < " . $arrap["minratio"] . " AND donor='no'") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { $dt = sqlesc(get_date_time()); $msg = sqlesc("You have been auto-demoted from " . $arrap["classname"] . " to " . get_user_class_name($arrap["demoteclass"]) ." because your share ratio has dropped below " . $arrap["minratio"]); while ($arr = mysql_fetch_assoc($res)) { mysql_query("UPDATE users SET class = $arrap[demoteclass] WHERE id = $arr[id]") or sqlerr(__FILE__, __LINE__); mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id], $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__); // status_change($arr['id']); } } } // give some bonus to the people that seed //read the bonus setting - had to be done this way, for some reason, i couldn't retrieve the info from the array (yes, I tried setting it as global) $res = mysql_query("SELECT * FROM `temp`") or sqlerr(__FILE__, __LINE__); while ($arr = mysql_fetch_assoc($res)){ $seed_bonus=$arr['sb']; } $seed_bonus=number_format(($seed_bonus/4),3); mysql_query("UPDATE `temp` SET `sb` = '$seed_bonus'"); //get everyone that seeds $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)) { $seedbonus_user_id=$arr['userid']; //.. get the amount of torrents seeded $sql_result = mysql_query("SELECT * FROM `peers` WHERE `seeder` = 'yes' AND `userid` = $seedbonus_user_id"); $num_torrents_seeded=number_format(mysql_num_rows($sql_result),3); $seed_bonus_applied=$seed_bonus*$num_torrents_seeded; //echo $seedbonus_user_id.' | '.$num_torrents_seeded.' | '.$seed_bonus_applied.'
'; mysql_query("UPDATE users SET seedbonus = seedbonus+$seed_bonus_applied WHERE id = $seedbonus_user_id"); //mysql_query("UPDATE `temp` SET `sb` = '$num_torrents_seeded'"); //.. give proper bonus } } // WARNINGS function autowarn($length, $limit, $minratio) { $msg = sqlesc("This is an automatic warning because your share ratio is too low at this moment.\n\nYou have " . $length . " days to higher your share ratio, read the rules to see what your ratio must be.\nIf your share ratio is too low after these 5 days your downloading priviliges will be disabled then you will have another 5 days to improv your ratio if you still fail to do so your account might be banned permanently!"); $until = sqlesc(get_date_time(gmtime() + (($length+1)*86400))); $dt = sqlesc(get_date_time()); $limit = $limit *1024*1024*1024; $res = mysql_query("SELECT id,ip FROM users WHERE class <= " . UC_VIP . " AND enabled = 'yes' AND downloaded > $limit AND uploaded / downloaded < $minratio and warned = 0") or sqlerr(__FILE__, __LINE__); while ($arr = mysql_fetch_assoc($res)) { mysql_query("UPDATE users SET permban = 'yes', warned = 1, warneduntil = ".$until." WHERE id=$arr[id]") or sqlerr(__FILE__, __LINE__); mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id], $dt, $msg, 0)") or sqlerr(__FILE__, __LINE__); } } autowarn(5,4,0.10); autowarn(5,10,0.20); autowarn(5,20,0.30); autowarn(5,30,0.40); autowarn(5,40,0.50); autowarn(5,50,0.60); autowarn(5,60,0.65); //AUTO-BAN and unban function autoban($length, $limit, $minratio, $nextlimit) { $res = mysql_query("SELECT id,ip FROM users WHERE class <= " . UC_VIP . " AND warned = 1 AND warneduntil < $length AND enabled = 'yes' AND downloaded > $limit AND uploaded / downloaded < $minratio") or sqlerr(__FILE__,__LINE__); while ($arr = mysql_fetch_assoc($res)) { mysql_query("UPDATE users SET downloadpos='no' WHERE id=$arr[id]") or sqlerr(__FILE__, __LINE__); } $res2 = mysql_query("SELECT id,ip FROM users WHERE class <= " . UC_VIP . " AND downloadpos = 'no' AND enabled = 'yes' AND downloaded < $nextlimit AND uploaded / downloaded >= $minratio") or sqlerr(__FILE__,__LINE__); while ($arr2 = mysql_fetch_assoc($res2)) { mysql_query("UPDATE users SET downloadpos='yes' WHERE id=$arr2[id]") or sqlerr(__FILE__, __LINE__); } } $secs = 1*86400; // 1 day $length = sqlesc(get_date_time(gmtime() + $secs)); // less than 1 day of warning left autoban($length, 4*1024*1024*1024, 0.10, 10*1024*1024*1024); autoban($length, 10*1024*1024*1024, 0.20, 20*1024*1024*1024); autoban($length, 20*1024*1024*1024, 0.30, 30*1024*1024*1024); autoban($length, 30*1024*1024*1024, 0.40, 40*1024*1024*1024); autoban($length, 40*1024*1024*1024, 0.50, 50*1024*1024*1024); autoban($length, 50*1024*1024*1024, 0.60, 60*1024*1024*1024); autoban($length, 60*1024*1024*1024, 0.65, 99*1024*1024*1024*1024*1024); } ?>