/** |--------------------------------------------------------------------------| | https://github.com/Bigjoos/ | |--------------------------------------------------------------------------| | Licence Info: GPL | |--------------------------------------------------------------------------| | Copyright (C) 2010 U-232 V5 | |--------------------------------------------------------------------------| | A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon. | |--------------------------------------------------------------------------| | Project Leaders: Mindless, Autotron, whocares, Swizzles. | |--------------------------------------------------------------------------| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e ) \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ */ function docleanup($data) { global $INSTALLER09, $queries, $mc1; set_time_limit(0); ignore_user_abort(1); require_once INCL_DIR . 'function_happyhour.php'; //==Putyns HappyHour $f = $INSTALLER09['happyhour']; $happy = unserialize(file_get_contents($f)); $happyHour = strtotime($happy["time"]); $curDate = TIME_NOW; $happyEnd = $happyHour + 3600; if ($happy["status"] == 0 && $INSTALLER09['happy_hour'] == true) { write_log("Happy hour was @ " . get_date($happyHour, 'LONG', 1, 0) . " and Catid " . $happy["catid"] . " "); happyFile("set"); } elseif ($curDate > $happyEnd && $happy["status"] == 1) { happyFile("reset"); } //== End if ($queries > 0) { write_log("Happyhour Clean -------------------- Happyhour cleanup Complete using {$queries} queries --------------------"); } if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) { $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated"; } if ($data['clean_log']) { cleanup_log($data); } }
function doslowcleanup() { global $SITENAME, $DEFAULTBASEURL, $torrent_dir, $autoslowclean_interval, $READPOST_EXPIRY, $CACHE, $queries, $query_stat, $torrent_dir, $tdeadtime, $delaccounts, $oldtorrents, $slotduration, $max_dead_torrent_time, $max_dead_topic_time, $max_dead_user_time, $ad_ratio, $ap_time, $ap_limit, $ap_ratio, $torrent_ttl; set_time_limit(1200); $result = mysql_query("show processlist") or sqlerr(__FILE__, __LINE__); while ($row = mysql_fetch_array($result)) { if ($row["Time"] > 100 || $row["Command"] == "Sleep") { $sql = "kill " . $row["Id"] . ""; mysql_query($sql) or sqlerr(__FILE__, __LINE__); } } ignore_user_abort(1); if ($delaccounts) { // delete inactive user accounts $dt = sqlesc(get_date_time(gmtime() - $max_dead_user_time)); $maximumclass = UC_POWER_USER; sql_query("DELETE FROM users WHERE status='confirmed' AND parked='no' AND class <= {$maximumclass} AND last_access < {$dt}"); } // == Updated promote power users $limit = 25 * 1024 * 1024 * 1024; $res = sql_query("SELECT id, uploaded, downloaded FROM users WHERE class = 0 AND uploaded >= {$limit} AND uploaded / downloaded >= {$ap_ratio} AND enabled='yes' and added < DATE_SUB(NOW(), INTERVAL 28 DAY)") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysql_num_rows($res) > 0) { $msg = "Congratulations, you have been Auto-Promoted to [b]Power User[/b]. :)\n You can enter the casino your account wont get deleted automatically and you get one extra invite :).\n"; while ($arr = mysql_fetch_assoc($res)) { $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3); $modcomment = sqlesc(gmdate("Y-m-d H:i") . " - Promoted to Power User by System (UL=" . prefixed($arr['uploaded']) . ", DL=" . prefixed($arr['downloaded']) . ", R=" . $ratio . ") \n"); $msgs_buffer[] = '(0,' . $arr['id'] . ',NOW(), ' . sqlesc($msg) . ', \'Promotion\')'; $users_buffer[] = '(' . $arr['id'] . ',1,1,' . $modcomment . ')'; } if (sizeof($msgs_buffer) > 0) { sql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO users (id, class, invites, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class), invites = invites+values(invites), modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); $count = mysql_affected_rows(); write_log("promotion", "Delayed Cleanup: Promoted " . $count / 2 . " member(s) from User to Power User"); } unset($users_buffer); unset($msgs_buffer); status_change($arr['id']); } // == Updated demote power users $res = sql_query("SELECT id, uploaded, downloaded FROM users WHERE class = 1 AND uploaded / downloaded < {$ad_ratio}") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysql_num_rows($res) > 0) { $msg = "You have been auto-demoted from [b]Power User[/b] to [b]User[/b] because your share ratio has dropped below < {$ad_ratio}.\n"; while ($arr = mysql_fetch_assoc($res)) { $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3); $modcomment = sqlesc(gmdate("Y-m-d H:i") . " - Demoted To User by System (UL=" . prefixed($arr['uploaded']) . ", DL=" . prefixed($arr['downloaded']) . ", R=" . $ratio . ") \n"); $msgs_buffer[] = '(0,' . $arr['id'] . ',NOW(), ' . sqlesc($msg) . ', \'Demotion\')'; $users_buffer[] = '(' . $arr['id'] . ',0,' . $modcomment . ')'; } if (sizeof($msgs_buffer) > 0) { sql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO users (id, class, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class),\nmodcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); $count = mysql_affected_rows(); write_log("demotion", "Delayed Cleanup: Demoted " . $count / 2 . " member(s) from Power User to User"); status_change($arr['id']); } unset($users_buffer); unset($msgs_buffer); } // ////////////////////end// // ///////////////////////happyhour//// $f = "{$CACHE}/happyhour.txt"; //$f = "C://AppServ/www/happyhour.txt"; $happy = unserialize(file_get_contents($f)); $happyHour = strtotime($happy["time"]); $curDate = time(); $happyEnd = $happyHour + 3600; if ($happy["status"] == 0) { write_log("happyhour", "Happy hour was @ " . date("Y-m-d H:i", $happyHour) . " and Catid " . $happy["catid"] . " "); happyFile("set"); } elseif ($curDate > $happyEnd && $happy["status"] == 1) { happyFile("reset"); } // ////////////end/////// // Remove userprofile views $days = 7; $dt = sqlesc(get_date_time(gmtime() - $days * 68400)); mysql_query("DELETE FROM userhits WHERE added < {$dt}"); // //////////////////reset ips///// $secs = 24 * 60 * 60; // 24Hours * 60 minutes * 60 seconds... $dt = sqlesc(get_date_time(gmtime() - $secs)); mysql_query("UPDATE users SET ip = '' WHERE last_access < {$dt}"); // Remove expired readposts... $dt = sqlesc(get_date_time(gmtime() - $READPOST_EXPIRY)); sql_query("DELETE readposts FROM readposts " . "LEFT JOIN posts ON readposts.lastpostread = posts.id " . "R .added < {$dt}"); write_log("slowautoclean", " -------------------- Delayed cleanup Complete using {$queries} queries --------------------"); }
function doslowcleanup() { global $INSTALLER09, $queries, $mc1; set_time_limit(1200); $result = sql_query("show processlist") or sqlerr(__FILE__, __LINE__); while ($row = mysql_fetch_array($result)) { if ($row["Time"] > 100 || $row["Command"] == "Sleep") { $sql = "kill " . $row["Id"] . ""; sql_query($sql) or sqlerr(__FILE__, __LINE__); } } ignore_user_abort(1); //== Delete expired announcements and processors sql_query("DELETE announcement_process FROM announcement_process LEFT JOIN users ON announcement_process.user_id = users.id WHERE users.id IS NULL"); sql_query("DELETE FROM announcement_main WHERE expires < " . sqlesc(time())); sql_query("DELETE announcement_process FROM announcement_process LEFT JOIN announcement_main ON announcement_process.main_id = announcement_main.main_id WHERE announcement_main.main_id IS NULL"); // Remove expired readposts... $dt = time() - $INSTALLER09["readpost_expiry"]; sql_query("DELETE readposts FROM readposts " . "LEFT JOIN posts ON readposts.lastpostread = posts.id " . "WHERE posts.added < {$dt}"); //==Putyns HappyHour $f = $INSTALLER09['happyhour']; $happy = unserialize(file_get_contents($f)); $happyHour = strtotime($happy["time"]); $curDate = time(); $happyEnd = $happyHour + 3600; if ($happy["status"] == 0) { write_log("Happy hour was @ " . get_date($happyHour, 'LONG', 1, 0) . " and Catid " . $happy["catid"] . " "); happyFile("set"); } elseif ($curDate > $happyEnd && $happy["status"] == 1) { happyFile("reset"); } //== End //=== Updated remove custom smilies by Bigjoos/pdq:) $res = sql_query("SELECT id, modcomment FROM users WHERE smile_until < " . TIME_NOW . " AND smile_until <> '0'") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysql_num_rows($res) > 0) { $subject = "Custom smilies expired."; $msg = "Your Custom smilies have timed out and has been auto-removed by the system. If you would like to have them again, exchange some Karma Bonus Points again. Cheers!\n"; while ($arr = mysql_fetch_assoc($res)) { $modcomment = $arr['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - Custom smilies Automatically Removed By System.\n" . $modcomment; $modcom = sqlesc($modcomment); $msgs_buffer[] = '(0,' . $arr['id'] . ',' . TIME_NOW . ', ' . sqlesc($msg) . ', ' . sqlesc($subject) . ' )'; $users_buffer[] = '(' . $arr['id'] . ', \'0\', ' . $modcom . ')'; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('smile_until' => 0, 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('smile_until' => 0)); $mc1->commit_transaction(900); } $count = count($users_buffer); if ($count > 0) { sql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO users (id, smile_until, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE smile_until=values(smile_until),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup - Removed Custom smilies from " . $count . " members"); } unset($users_buffer, $msgs_buffer, $count); } //=== Updated remove karma vip by Bigjoos/pdq - change class number '1' in the users_buffer and $update[class'] to whatever is under your vip class number $res = sql_query("SELECT id, modcomment FROM users WHERE vip_added='yes' AND vip_until < " . TIME_NOW . "") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysql_num_rows($res) > 0) { $subject = "VIP status expired."; $msg = "Your VIP status has timed out and has been auto-removed by the system. Become a VIP again by donating to {$INSTALLER09['site_name']} , or exchanging some Karma Bonus Points. Cheers !\n"; while ($arr = mysql_fetch_assoc($res)) { $modcomment = $arr['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - Vip status Automatically Removed By System.\n" . $modcomment; $modcom = sqlesc($modcomment); $msgs_buffer[] = '(0,' . $arr['id'] . ',' . TIME_NOW . ', ' . sqlesc($msg) . ', ' . sqlesc($subject) . ')'; $users_buffer[] = '(' . $arr['id'] . ',1, \'no\', \'0\' , ' . $modcom . ')'; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('class' => 1, 'vip_added' => 'no', 'vip_until' => 0, 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('class' => 1, 'vip_added' => 'no', 'vip_until' => 0)); $mc1->commit_transaction(900); } $count = count($users_buffer); if ($count > 0) { sql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO users (id, class, vip_added, vip_until, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class),vip_added=values(vip_added),vip_until=values(vip_until),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup - Karma Vip status expired on - " . $count . " Member(s)"); } unset($users_buffer, $msgs_buffer, $count); status_change($arr['id']); //== For Retros announcement mod } //=== Anonymous profile by Bigjoos/pdq:) $res = sql_query("SELECT id, modcomment FROM users WHERE anonymous_until < " . TIME_NOW . " AND anonymous_until <> '0'") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysql_num_rows($res) > 0) { $subject = "Anonymous profile expired."; $msg = "Your Anonymous profile has timed out and has been auto-removed by the system. If you would like to have it again, exchange some Karma Bonus Points again. Cheers!\n"; while ($arr = mysql_fetch_assoc($res)) { $modcomment = $arr['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - Anonymous profile Automatically Removed By System.\n" . $modcomment; $modcom = sqlesc($modcomment); $msgs_buffer[] = '(0,' . $arr['id'] . ',' . TIME_NOW . ', ' . sqlesc($msg) . ', ' . sqlesc($subject) . ' )'; $users_buffer[] = '(' . $arr['id'] . ', \'0\', \'no\', ' . $modcom . ')'; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('anonymous_until' => 0, 'anonymous' => 'no', 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('anonymous_until' => 0, 'anonymous' => 'no')); $mc1->commit_transaction(900); } $count = count($users_buffer); if ($count > 0) { sql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO users (id, anonymous_until, anonymous, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE anonymous_until=values(anonymous_until),anonymous=values(anonymous), modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup - Removed Anonymous profile from " . $count . " members"); } unset($users_buffer, $msgs_buffer, $count); } //==End //==delete torrents by putyn $days = 30; $dt = TIME_NOW - $days * 86400; $res = sql_query("SELECT id, name FROM torrents WHERE added < {$dt} AND seeders='0' AND leechers='0'"); while ($arr = mysql_fetch_assoc($res)) { sql_query("DELETE peers.*, files.*,comments.*,snatched.*, thanks.*, bookmarks.*, coins.*, ratings.*, torrents.* FROM torrents \r\n\t\t\t\t LEFT JOIN peers ON peers.torrent = torrents.id\r\n\t\t\t\t LEFT JOIN files ON files.torrent = torrents.id\r\n\t\t\t\t LEFT JOIN comments ON comments.torrent = torrents.id\r\n\t\t\t\t LEFT JOIN thanks ON thanks.torrentid = torrents.id\r\n\t\t\t\t LEFT JOIN bookmarks ON bookmarks.torrentid = torrents.id\r\n\t\t\t\t LEFT JOIN coins ON coins.torrentid = torrents.id\r\n\t\t\t\t LEFT JOIN ratings ON ratings.torrent = torrents.id\r\n\t\t\t\t LEFT JOIN snatched ON snatched.torrentid = torrents.id\r\n\t\t\t\t WHERE torrents.id = {$arr['id']}") or sqlerr(__FILE__, __LINE__); @unlink("{$INSTALLER09['torrent_dir']}/{$arr['id']}.torrent"); write_log("Torrent {$arr['id']} ({$arr['name']}) was deleted by system (older than {$days} days and no seeders)"); } // ===Clear funds after one month $secs = 30 * 86400; $dt = sqlesc(time() - $secs); sql_query("DELETE FROM funds WHERE added < {$dt}"); $mc1->delete_value('totalfunds_'); // ===End //== Donation Progress Mod Updated For Tbdev 2009/2010 by Bigjoos/pdq $res = sql_query("SELECT id, modcomment, vipclass_before FROM users WHERE donor='yes' AND donoruntil < " . TIME_NOW . " AND donoruntil <> '0'") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysql_num_rows($res) > 0) { $subject = "Donor status removed by system."; $msg = "Your Donor status has timed out and has been auto-removed by the system, and your Vip status has been removed. We would like to thank you once again for your support to {$INSTALLER09['site_name']}. If you wish to re-new your donation, Visit the site paypal link. Cheers!\n"; while ($arr = mysql_fetch_assoc($res)) { $modcomment = $arr['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - Donation status Automatically Removed By System.\n" . $modcomment; $modcom = sqlesc($modcomment); $msgs_buffer[] = '(0,' . $arr['id'] . ',' . TIME_NOW . ', ' . sqlesc($msg) . ',' . sqlesc($subject) . ')'; $users_buffer[] = '(' . $arr['id'] . ',' . $arr['vipclass_before'] . ',\'no\',\'0\', ' . $modcom . ')'; $update['class'] = $arr['vipclass_before']; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('class' => $update['class'], 'donor' => 'no', 'donor_until' => 0, 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('class' => $update['class'], 'donor' => 'no', 'donor_until' => 0)); $mc1->commit_transaction(900); } $count = count($users_buffer); if ($count > 0) { sql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO users (id, class, donor, donoruntil, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class),\r\n donor=values(donor),donoruntil=values(donoruntil),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup: Donation status expired - " . $count . " Member(s)"); } unset($users_buffer, $msgs_buffer, $update, $count); } //===End===// //== 09 Auto leech warn by Bigjoos/pdq //== Updated/modified autoleech warning script $minratio = 0.3; // ratio < 0.4 $downloaded = 10 * 1024 * 1024 * 1024; // + 10 GB $length = 3 * 7; // Give 3 weeks to let them sort there shit $res = sql_query("SELECT id, modcomment FROM users WHERE enabled='yes' AND class = " . UC_USER . " AND leechwarn = '0' AND uploaded / downloaded < {$minratio} AND downloaded >= {$downloaded} AND immunity = '0'") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysql_num_rows($res) > 0) { $dt = sqlesc(time()); $subject = "Auto leech warned"; $msg = "You have been warned and your download rights have been removed due to your low ratio. You need to get a ratio of 0.5 within the next 3 weeks or your Account will be disabled."; $leechwarn = TIME_NOW + $length * 86400; while ($arr = mysql_fetch_assoc($res)) { $modcomment = $arr['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - Automatically Leech warned and downloads disabled By System.\n" . $modcomment; $modcom = sqlesc($modcomment); $msgs_buffer[] = '(0,' . $arr['id'] . ', ' . TIME_NOW . ', ' . sqlesc($msg) . ', ' . sqlesc($subject) . ')'; $users_buffer[] = '(' . $arr['id'] . ',' . $leechwarn . ',\'0\', ' . $modcom . ')'; $update['leechwarn'] = $leechwarn; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('leechwarn' => $update['leechwarn'], 'downloadpos' => 0, 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('leechwarn' => $update['leechwarn'], 'downloadpos' => 0)); $mc1->commit_transaction(900); } $count = count($users_buffer); if ($count > 0) { sql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO users (id, leechwarn, downloadpos, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE leechwarn=values(leechwarn),downloadpos=values(downloadpos),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup: System applied auto leech Warning(s) to " . $count . " Member(s)"); } unset($users_buffer, $msgs_buffer, $update, $count); } //End //== 09 Auto leech warn by Bigjoos/pdq //== Updated/Modified autoleech warn system - Remove warning and enable downloads $minratio = 0.5; // ratio > 0.5 $res = sql_query("SELECT id, modcomment FROM users WHERE downloadpos = '0' AND leechwarn > '1' AND uploaded / downloaded >= {$minratio}") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysql_num_rows($res) > 0) { $subject = "Auto leech warning removed"; $msg = "Your warning for a low ratio has been removed and your downloads enabled. We highly recommend you to keep your ratio positive to avoid being automatically warned again.\n"; while ($arr = mysql_fetch_assoc($res)) { $modcomment = $arr['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - Leech warn removed and download enabled By System.\n" . $modcomment; $modcom = sqlesc($modcomment); $msgs_buffer[] = '(0,' . $arr['id'] . ',' . TIME_NOW . ', ' . sqlesc($msg) . ', ' . sqlesc($subject) . ')'; $users_buffer[] = '(' . $arr['id'] . ', \'0\', \'1\', ' . $modcom . ')'; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('leechwarn' => 0, 'downloadpos' => 0, 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('leechwarn' => 0, 'downloadpos' => 0)); $mc1->commit_transaction(900); } $count = count($users_buffer); if ($count > 0) { sql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO users (id, leechwarn, downloadpos, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE leechwarn=values(leechwarn),downloadpos=values(downloadpos),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup: System removed auto leech Warning(s) and renabled download(s) - " . $count . " Member(s)"); } unset($users_buffer, $msgs_buffer, $count); } //==End //== 09 Auto leech warn by Bigjoos/pdq //== Disabled expired leechwarns $res = sql_query("SELECT id, modcomment FROM users WHERE leechwarn > '1' AND leechwarn < " . TIME_NOW . " AND leechwarn <> '0' ") or sqlerr(__FILE__, __LINE__); $users_buffer = array(); if (mysql_num_rows($res) > 0) { while ($arr = mysql_fetch_assoc($res)) { $modcomment = $arr['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - User disabled - Low ratio.\n" . $modcomment; $modcom = sqlesc($modcomment); $users_buffer[] = '(' . $arr['id'] . ' , \'0\', \'no\', ' . $modcom . ')'; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('leechwarn' => 0, 'enabled' => 'no', 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('leechwarn' => 0, 'enabled' => 'no')); $mc1->commit_transaction(900); } $count = count($users_buffer); if ($count > 0) { sql_query("INSERT INTO users (id, leechwarn, enabled, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class),leechwarn=values(leechwarn),enabled=values(enabled),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup: Disabled " . $count . " Member(s) - Leechwarns expired"); } unset($users_buffer, $count); } //==End //== 09 Auto invite by Bigjoos/pdq $ratiocheck = 1.0; $joined = time() - 86400 * 90; $res = sql_query("SELECT id, uploaded, invites, downloaded, modcomment FROM users WHERE invites='1' AND class = " . UC_USER . " AND uploaded / downloaded <= {$ratiocheck} AND enabled='yes' AND added < {$joined}") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysql_num_rows($res) > 0) { $subject = "Auto Invites"; $msg = "Congratulations, your user group met a set out criteria therefore you have been awarded 2 invites :)\n Please use them carefully. Cheers " . $INSTALLER09['site_name'] . " staff.\n"; while ($arr = mysql_fetch_assoc($res)) { $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3); $modcomment = $arr['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - Awarded 2 bonus invites by System (UL=" . mksize($arr['uploaded']) . ", DL=" . mksize($arr['downloaded']) . ", R=" . $ratio . ") .\n" . $modcomment; $modcom = sqlesc($modcomment); $msgs_buffer[] = '(0,' . $arr['id'] . ', ' . TIME_NOW . ', ' . sqlesc($msg) . ', ' . sqlesc($subject) . ')'; $users_buffer[] = '(' . $arr['id'] . ', 2, ' . $modcom . ')'; //== 2 in the user_buffer is award amount :) $update['invites'] = $arr['invites'] + 2; //== 2 in the user_buffer is award amount :) $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('invites' => $update['invites'], 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('invites' => $update['invites'])); $mc1->commit_transaction(900); } $count = count($users_buffer); if ($count > 0) { sql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__); sql_query("INSERT INTO users (id, invites, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE invites = invites+values(invites), modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup: Awarded 2 bonus invites to " . $count . " member(s) "); } unset($users_buffer, $msgs_buffer, $update, $count); } //== ////== Delete ips $dt = TIME_NOW - 62 * 86400; sql_query("DELETE FROM ips WHERE access < {$dt}"); write_log("Slowautoclean -------------------- Delayed cleanup Complete using {$queries} queries --------------------"); }