function docleanup($data) { global $INSTALLER09, $queries, $mc1; set_time_limit(1200); ignore_user_abort(1); //== Updated promote power users $limit = 25 * 1024 * 1024 * 1024; $minratio = 1.05; $maxdt = TIME_NOW - 86400 * 28; $res = sql_query("SELECT id, uploaded, downloaded, invites, modcomment FROM users WHERE class = " . UC_USER . " AND uploaded >= {$limit} AND uploaded / downloaded >= {$minratio} AND enabled='yes' AND added < {$maxdt}") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysqli_num_rows($res) > 0) { $subject = "Auto Promotion"; $msg = "Congratulations, you have been Auto-Promoted to [b]Power User[/b]. :)\n You get one extra invite.\n"; while ($arr = mysqli_fetch_assoc($res)) { $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3); $modcomment = $arr['modcomment']; $modcomment = get_date(TIME_NOW, 'DATE', 1) . " - Promoted to Power User 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'] . ', 1, 1, ' . $modcom . ')'; $update['invites'] = $arr['invites'] + 1; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('class' => 1, 'invites' => $update['invites'])); $mc1->commit_transaction($INSTALLER09['expires']['user_cache']); $mc1->begin_transaction('user_stats_' . $arr['id']); $mc1->update_row(false, array('modcomment' => $modcomment)); $mc1->commit_transaction($INSTALLER09['expires']['user_stats']); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('class' => 1, 'invites' => $update['invites'])); $mc1->commit_transaction($INSTALLER09['expires']['curuser']); $mc1->delete_value('inbox_new_' . $arr['id']); $mc1->delete_value('inbox_new_sb_' . $arr['id']); } $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, 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__); write_log("Cleanup: Promoted " . $count . " member(s) from User to Power User"); } unset($users_buffer, $msgs_buffer, $update, $count); status_change($arr['id']); //== For Retros announcement mod } //== if ($queries > 0) { write_log("Power User Updates -------------------- Power User Updates Clean 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 docleanup($data) { global $INSTALLER09, $queries, $mc1; set_time_limit(1200); ignore_user_abort(1); //== Updated demote power users $minratio = 0.85; $res = sql_query("SELECT id, uploaded, downloaded, modcomment FROM users WHERE class = " . UC_POWER_USER . " AND uploaded / downloaded < {$minratio}") or sqlerr(__FILE__, __LINE__); $subject = "Auto Demotion"; $msgs_buffer = $users_buffer = array(); if (mysqli_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 {$minratio}.\n"; while ($arr = mysqli_fetch_assoc($res)) { $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3); $modcomment = $arr['modcomment']; $modcomment = get_date(TIME_NOW, 'DATE', 1) . " - Demoted To User 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'] . ', 0, ' . $modcom . ')'; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('class' => 0)); $mc1->commit_transaction($INSTALLER09['expires']['user_cache']); $mc1->begin_transaction('user_stats_' . $arr['id']); $mc1->update_row(false, array('modcomment' => $modcomment)); $mc1->commit_transaction($INSTALLER09['expires']['user_stats']); $mc1->begin_transaction('MYuser_' . $arr['id']); $mc1->update_row(false, array('class' => 0)); $mc1->commit_transaction($INSTALLER09['expires']['curuser']); $mc1->delete_value('inbox_new_' . $arr['id']); $mc1->delete_value('inbox_new_sb_' . $arr['id']); } $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, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup: Demoted " . $count . " member(s) from Power User to User"); status_change($arr['id']); } unset($users_buffer, $msgs_buffer, $count); status_change($arr['id']); //== For Retros announcement mod } //==End if ($queries > 0) { write_log("Power User Demote Updates -------------------- Power User Demote Updates Clean 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); } }
/** |--------------------------------------------------------------------------| | 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(1200); ignore_user_abort(1); //=== 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 (mysqli_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 = mysqli_fetch_assoc($res)) { $modcomment = $arr['modcomment']; $modcomment = get_date(TIME_NOW, '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)); $mc1->commit_transaction($INSTALLER09['expires']['user_cache']); $mc1->begin_transaction('user_stats' . $arr['id']); $mc1->update_row(false, array('modcomment' => $modcomment)); $mc1->commit_transaction($INSTALLER09['expires']['user_stats']); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('class' => 1, 'vip_added' => 'no', 'vip_until' => 0)); $mc1->commit_transaction($INSTALLER09['expires']['curuser']); $mc1->delete_value('inbox_new_' . $arr['id']); $mc1->delete_value('inbox_new_sb_' . $arr['id']); } $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=values(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 } //== if ($queries > 0) { write_log("Karma Vip Clean -------------------- Karma Vip 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); } }
<?php $a = loadVariable("a", ''); $v = loadVariable("v", ""); $page_type = loadVariable("page_type", ""); $id = loadVariable("id", "0"); if ($a != '') { switch ($a) { case "get_link_content": echo get_link_content($v); break; case 'delete': delete_row($page_type, $id); break; case 'status': status_change($page_type, $id); break; default: echo "Error"; } } function delete_row($page_type, $id) { if (empty($page_type)) { die(json_encode(array("error" => "Page Type not declared!!!"))); } else { //Table information declaration $table_info['site menu']['tbl'] = "site_menu"; $table_info['site menu']['key'] = "menu_id"; $table_info['site content']['tbl'] = "site_content"; $table_info['site content']['key'] = "content_id";
function docleanup($data) { global $INSTALLER09, $queries, $mc1; set_time_limit(1200); ignore_user_abort(1); //== Updated promote power users /* WANT TO CHANGE THIS. LOOK FOR CLASS'S UNDER VIP OR A SET GROUP THE ADMIN CAN SELECT, THEN FOREACH?? THROUGH THEM, OPTIONS CAN BE SET BY ADMINS ON WHEN PEOPLE GET PROMOTED TO THE NEXT CLASS NEED RATIO TIME ON SITE (MAXDT) UPLOADED AMOUNT ($LIMIT) */ //Get promotion rules from DB// $pconf = sql_query('SELECT * FROM class_promo ORDER BY id ASC ') or sqlerr(__FILE__, __LINE__); while ($ac = mysqli_fetch_assoc($pconf)) { $class_config[$ac['name']]['id'] = $ac['id']; $class_config[$ac['name']]['name'] = $ac['name']; $class_config[$ac['name']]['min_ratio'] = $ac['min_ratio']; $class_config[$ac['name']]['uploaded'] = $ac['uploaded']; $class_config[$ac['name']]['time'] = $ac['time']; $class_config[$ac['name']]['low_ratio'] = $ac['low_ratio']; // Set rules to easier to handle vars// $limit = $class_config[$ac['name']]['uploaded'] * 1024 * 1024 * 1024; $minratio = $class_config[$ac['name']]['min_ratio']; $maxdt = TIME_NOW - 86400 * $class_config[$ac['name']]['time']; //Get the class value we are working on //AND Set the next class value to + 1 $class_value = $class_config[$ac['name']]['name']; $res1 = sql_query("SELECT * from class_config WHERE value = '{$class_value}' "); while ($arr1 = mysqli_fetch_assoc($res1)) { //Changed for testing // As we are working on the class name which is being promoted to, we need to -1 from it, to get the class the users are currently in // i.e UC_POWER_USER = 1, but we are promoting UC_USER = 0 to POWER_USER. $class_name = $arr1['classname']; $prev_class = $class_value - 1; /* $class = $arr1['value']; $next_class = $class + 1; */ } // Get the class name and value of the previous class // $res2 = sql_query("SELECT * from class_config WHERE value = '{$prev_class}' "); while ($arr2 = mysqli_fetch_assoc($res2)) { $prev_class_name = $arr2['classname']; } //Search for users to be updated// $res = sql_query("SELECT id, uploaded, downloaded, invites, modcomment FROM users WHERE class = '{$prev_class}' AND uploaded >= {$limit} AND uploaded / downloaded >= {$minratio} AND enabled='yes' AND added < {$maxdt}") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysqli_num_rows($res) > 0) { $subject = "Class Promotion"; $msg = "Congratulations, you have been promoted to [b]" . $class_name . "[/b]. :)\n You get one extra invite.\n"; while ($arr = mysqli_fetch_assoc($res)) { $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3); $modcomment = $arr['modcomment']; $modcomment = get_date(TIME_NOW, 'DATE', 1) . " - Promoted to " . $class_name . " 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'] . ', ' . $class_value . ', 1, ' . $modcom . ')'; $update['invites'] = $arr['invites'] + 1; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('class' => $class_value, 'invites' => $update['invites'])); $mc1->commit_transaction($INSTALLER09['expires']['user_cache']); $mc1->begin_transaction('user_stats_' . $arr['id']); $mc1->update_row(false, array('modcomment' => $modcomment)); $mc1->commit_transaction($INSTALLER09['expires']['user_stats']); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('class' => $class_value, 'invites' => $update['invites'])); $mc1->commit_transaction($INSTALLER09['expires']['curuser']); $mc1->delete_value('inbox_new_' . $arr['id']); $mc1->delete_value('inbox_new_sb_' . $arr['id']); } $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, invites, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class), invites = invites+values(invites), modcomment=values(modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup: Promoted " . $count . " member(s) from " . $prev_class_name . " to " . $class_name . ""); } unset($users_buffer, $msgs_buffer, $update, $count); status_change($arr['id']); //== For Retros announcement mod } //== if ($queries > 0) { write_log("{$class_name} Updates -------------------- Power User Updates Clean 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 --------------------"); }
if (isset($_POST['yahoo']) && ($yahoo = $_POST['yahoo']) != $user['yahoo']) { $modcomment = get_date(time(), 'DATE', 1) . " - yahoo changed to '" . strip_tags($_POST['yahoo']) . "' from '" . htmlspecialchars($user['yahoo']) . "' by " . $CURUSER['username'] . ".\n" . $modcomment; $updateset[] = 'yahoo = ' . sqlesc($yahoo); $useredit['update'][] = 'Yahoo address changed'; } //=== icq if (isset($_POST['icq']) && ($icq = $_POST['icq']) != $user['icq']) { $modcomment = get_date(time(), 'DATE', 1) . " - icq changed to '" . strip_tags($_POST['icq']) . "' from '" . htmlspecialchars($user['icq']) . "' by " . $CURUSER['username'] . ".\n" . $modcomment; $updateset[] = 'icq = ' . sqlesc($icq); $useredit['update'][] = 'ICQ address changed'; } //== Add ModComment... (if we changed stuff we update otherwise we dont include this..) if ($CURUSER['class'] == UC_MAX && ($user['modcomment'] != $_POST['modcomment'] || $modcomment != $_POST['modcomment']) || $CURUSER['class'] < UC_MAX && $modcomment != $user['modcomment']) { $updateset[] = "modcomment = " . sqlesc($modcomment); } if (sizeof($updateset) > 0) { sql_query("UPDATE users SET " . implode(", ", $updateset) . " WHERE id=" . sqlesc($userid)) or sqlerr(__FILE__, __LINE__); } status_change($userid); //== 09 Updated Sysop log - thanks to pdq write_info("User account {$userid} (<a href='userdetails.php?id={$userid}'>{$user['username']}</a>)\nThings edited: " . join(', ', $useredit['update']) . " by <a href='userdetails.php?id={$CURUSER['id']}'>{$CURUSER['username']}</a>"); //== Memcache - delete the keys $mc1->delete_value('inbox_new_' . $userid); $mc1->delete_value('inbox_new_sb_' . $userid); $mc1->delete_value('user' . $userid); $mc1->delete_value('MyUser_' . $userid); $returnto = $_POST["returnto"]; header("Location: {$INSTALLER09['baseurl']}/{$returnto}"); stderr("{$lang['modtask_user_error']}", "{$lang['modtask_try_again']}"); } stderr("{$lang['modtask_user_error']}", "{$lang['modtask_no_idea']}");
function doslowcleanup2() { 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); //===09 hnr by sir_snugglebunny //=== hit and run part... after 3 days, add the mark of Cain... adjust $secs value if you wish $secs = 3 * 86400; $hnr = time() - $secs; $res = sql_query('SELECT id FROM snatched WHERE hit_and_run <> \'0\' AND hit_and_run < ' . sqlesc($hnr) . '') or sqlerr(__FILE__, __LINE__); while ($arr = mysql_fetch_assoc($res)) { sql_query('UPDATE snatched SET mark_of_cain = \'yes\' WHERE id=' . sqlesc($arr['id'])) or sqlerr(__FILE__, __LINE__); } //=== hit and run... disable Downloading rights if they have 3 marks of cain $res_fuckers = sql_query('SELECT COUNT(*) AS poop, snatched.userid, users.username, users.modcomment, users.hit_and_run_total, users.downloadpos FROM snatched LEFT JOIN users ON snatched.userid = users.id WHERE snatched.mark_of_cain = \'yes\' AND users.hnrwarn = \'no\' AND users.immunity = \'0\' GROUP BY snatched.userid') or sqlerr(__FILE__, __LINE__); while ($arr_fuckers = mysql_fetch_assoc($res_fuckers)) { if ($arr_fuckers['poop'] > 3 && $arr_fuckers['downloadpos'] == 1) { //=== set them to no DLs $subject = sqlesc('Download disabled by System'); $msg = sqlesc("Sorry " . $arr_fuckers['username'] . ",\n Because you have 3 or more torrents that have not been seeded to either a 1:1 ratio, or for the expected seeding time, your downloading rights have been disabled by the Auto system !\nTo get your Downloading rights back is simple,\n just start seeding the torrents in your profile [ click your username, then click your [url=" . $INSTALLER09['baseurl'] . "/userdetails.php?id=" . $arr_fuckers['userid'] . "&completed=1]Completed Torrents[/url] link to see what needs seeding ] and your downloading rights will be turned back on by the Auto system after the next clean-time [ updates 4 times per hour ].\n\nDownloads are disabled after a member has three or more torrents that have not been seeded to either a 1 to 1 ratio, OR for the required seed time [ please see the [url=" . $INSTALLER09['baseurl'] . "/faq.php]FAQ[/url] or [url=" . $INSTALLER09['baseurl'] . "/rules.php]Site Rules[/url] for more info ]\n\nIf this message has been in error, or you feel there is a good reason for it, please feel free to PM a staff member with your concerns.\n\n we will do our best to fix this situation.\n\nBest of luck!\n " . $INSTALLER09['site_name'] . " staff.\n"); $modcomment = $arr_fuckers['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - Download rights removed for H and R - AutoSystem.\n" . $modcomment; $modcom = sqlesc($modcomment); sql_query("INSERT INTO messages (sender, receiver, added, msg, subject, poster) VALUES(0, {$arr_fuckers['userid']}, " . TIME_NOW . ", {$msg}, {$subject}, 0)") or sqlerr(__FILE__, __LINE__); sql_query('UPDATE users SET hit_and_run_total = hit_and_run_total + ' . $arr_fuckers['poop'] . ', downloadpos = \'0\', hnrwarn = \'yes\', modcomment = ' . $modcom . ' WHERE downloadpos = \'1\' AND id=' . sqlesc($arr_fuckers['userid'])) or sqlerr(__FILE__, __LINE__); $update['hit_and_run_total'] = $arr_fuckers['hit_and_run_total'] + $arr_fuckers['poop']; $mc1->begin_transaction('user' . $arr_fuckers['userid']); $mc1->update_row(false, array('hit_and_run_total' => $update['hit_and_run_total'], 'downloadpos' => 0, 'hnrwarn' => 'yes', 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MyUser_' . $arr_fuckers['userid']); $mc1->update_row(false, array('hit_and_run_total' => $update['hit_and_run_total'], 'downloadpos' => 0, 'hnrwarn' => 'yes')); $mc1->commit_transaction(900); } } //=== hit and run... turn their DLs back on if they start seeding again $res_good_boy = sql_query('SELECT id, username, modcomment FROM users WHERE hnrwarn = \'yes\' AND downloadpos = \'0\'') or sqlerr(__FILE__, __LINE__); while ($arr_good_boy = mysql_fetch_assoc($res_good_boy)) { $res_count = sql_query('SELECT COUNT(*) FROM snatched WHERE userid = ' . sqlesc($arr_good_boy['id']) . ' AND mark_of_cain = \'yes\'') or sqlerr(__FILE__, __LINE__); $arr_count = mysql_fetch_row($res_count); if ($arr_count[0] < 3) { //=== set them to yes DLs $subject = sqlesc('Download restored by System'); $msg = sqlesc("Hi " . $arr_good_boy['username'] . ",\n Congratulations ! Because you have seeded the torrents that needed seeding, your downloading rights have been restored by the Auto System !\n\nhave fun !\n " . $INSTALLER09['site_name'] . " staff.\n"); $modcomment = $arr_good_boy['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - Download rights restored from H and R - AutoSystem.\n" . $modcomment; $modcom = sqlesc($modcomment); sql_query("INSERT INTO messages (sender, receiver, added, msg, subject, poster) VALUES(0, " . sqlesc($arr_good_boy['id']) . ", " . TIME_NOW . ", {$msg}, {$subject}, 0)") or sqlerr(__FILE__, __LINE__); sql_query('UPDATE users SET downloadpos = \'1\', hnrwarn = \'no\', modcomment = ' . $modcom . ' WHERE id = ' . sqlesc($arr_good_boy['id'])) or sqlerr(__FILE__, __LINE__); $mc1->begin_transaction('user' . $arr_good_boy['id']); $mc1->update_row(false, array('downloadpos' => 1, 'hnrwarn' => 'no', 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MyUser_' . $arr_good_boy['id']); $mc1->update_row(false, array('downloadpos' => 1, 'hnrwarn' => 'no')); $mc1->commit_transaction(900); } } //==End sql_query("UPDATE `freeslots` SET `double` = 0 WHERE `double` != 0 AND `double` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); sql_query("UPDATE `freeslots` SET `free` = 0 WHERE `free` != 0 AND `free` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); sql_query("DELETE FROM `freeslots` WHERE `double` = 0 AND `free` = 0") or sqlerr(__FILE__, __LINE__); sql_query("UPDATE `users` SET `free_switch` = 0 WHERE `free_switch` > 1 AND `free_switch` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); sql_query("UPDATE `torrents` SET `free` = 0 WHERE `free` > 1 AND `free` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); sql_query("UPDATE `users` SET `downloadpos` = 1 WHERE `downloadpos` > 1 AND `downloadpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); sql_query("UPDATE `users` SET `uploadpos` = 1 WHERE `uploadpos` > 1 AND `uploadpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); sql_query("UPDATE `users` SET `chatpost` = 1 WHERE `chatpost` > 1 AND `chatpost` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); sql_query("UPDATE `users` SET `avatarpos` = 1 WHERE `avatarpos` > 1 AND `avatarpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); sql_query("UPDATE `users` SET `immunity` = 0 WHERE `immunity` > 1 AND `immunity` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); sql_query("UPDATE `users` SET `warned` = 0 WHERE `warned` > 1 AND `warned` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); sql_query("UPDATE `users` SET `pirate` = 0 WHERE `pirate` > 1 AND `pirate` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); sql_query("UPDATE `users` SET `king` = 0 WHERE `king` > 1 AND `king` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__); //== Delete old backup's $days = 7; $res = sql_query("SELECT id, name FROM dbbackup WHERE added < " . sqlesc(time() - $days * 86400)) or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { $ids = array(); while ($arr = mysql_fetch_assoc($res)) { $ids[] = (int) $arr['id']; $filename = $INSTALLER09['backup_dir'] . '/' . $arr['name']; if (is_file($filename)) { unlink($filename); } } sql_query('DELETE FROM dbbackup WHERE id IN (' . implode(', ', $ids) . ')') or sqlerr(__FILE__, __LINE__); } //== end //== Delete inactive user accounts $secs = 350 * 86400; $dt = time() - $secs; $maxclass = UC_POWER_USER; sql_query("DELETE FROM users WHERE parked='no' AND status='confirmed' AND class <= {$maxclass} AND last_access < {$dt}"); //== Delete parked user accounts $secs = 175 * 86400; // change the time to fit your needs $dt = time() - $secs; $maxclass = UC_POWER_USER; sql_query("DELETE FROM users WHERE parked='yes' AND status='confirmed' AND class <= {$maxclass} AND last_access < {$dt}"); //== Delete shout $secs = 2 * 86400; $dt = sqlesc(time() - $secs); sql_query("DELETE FROM shoutbox WHERE " . time() . " - date > {$secs}") or sqlerr(__FILE__, __LINE__); //== Updated promote power users $limit = 25 * 1024 * 1024 * 1024; $minratio = 1.05; $maxdt = time() - 86400 * 28; $res = sql_query("SELECT id, uploaded, downloaded, invites, modcomment FROM users WHERE class = " . UC_USER . " AND uploaded >= {$limit} AND uploaded / downloaded >= {$minratio} AND enabled='yes' AND added < {$maxdt}") or sqlerr(__FILE__, __LINE__); $msgs_buffer = $users_buffer = array(); if (mysql_num_rows($res) > 0) { $subject = "Auto Promotion"; $msg = "Congratulations, you have been Auto-Promoted to [b]Power User[/b]. :)\n You get one extra invite.\n"; while ($arr = mysql_fetch_assoc($res)) { $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3); $modcomment = $arr['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - Promoted to Power User 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'] . ', 1, 1, ' . $modcom . ')'; $update['invites'] = $arr['invites'] + 1; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('class' => 1, 'invites' => $update['invites'], 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MyUser_' . $arr['id']); $mc1->update_row(false, array('class' => 1, '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, 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__); write_log("Cleanup: Promoted " . $count . " member(s) from User to Power User"); } unset($users_buffer, $msgs_buffer, $update, $count); status_change($arr['id']); //== For Retros announcement mod } //== Updated demote power users $minratio = 0.85; $res = sql_query("SELECT id, uploaded, downloaded, modcomment FROM users WHERE class = " . UC_POWER_USER . " AND uploaded / downloaded < {$minratio}") or sqlerr(__FILE__, __LINE__); $subject = "Auto Demotion"; $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 {$minratio}.\n"; while ($arr = mysql_fetch_assoc($res)) { $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3); $modcomment = $arr['modcomment']; $modcomment = get_date(time(), 'DATE', 1) . " - Demoted To User 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'] . ', 0, ' . $modcom . ')'; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('class' => 0, 'modcomment' => $modcomment)); $mc1->commit_transaction(900); $mc1->begin_transaction('MYuser_' . $arr['id']); $mc1->update_row(false, array('class' => 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, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup: Demoted " . $count . " member(s) from Power User to User"); status_change($arr['id']); } unset($users_buffer, $msgs_buffer, $count); status_change($arr['id']); //== For Retros announcement mod } //==End //sql_query("UPDATE avps SET value_i = 0, value_s = '0' WHERE arg = 'sitepot' AND value_u < ".TIME_NOW." AND value_s = '1'") or sqlerr(__file__, __line__); write_log("Slowautoclean2 -------------------- Delayed cleanup 2 Complete using {$queries} queries--------------------"); }
function docleanup($data) { global $INSTALLER09, $queries, $mc1; set_time_limit(1200); ignore_user_abort(1); //== Updated demote power users //Get promotion rules from DB// $pconf = sql_query('SELECT * FROM class_promo ORDER BY id ASC ') or sqlerr(__FILE__, __LINE__); while ($ac = mysqli_fetch_assoc($pconf)) { $class_config[$ac['name']]['id'] = $ac['id']; $class_config[$ac['name']]['name'] = $ac['name']; $class_config[$ac['name']]['min_ratio'] = $ac['min_ratio']; $class_config[$ac['name']]['uploaded'] = $ac['uploaded']; $class_config[$ac['name']]['time'] = $ac['time']; $class_config[$ac['name']]['low_ratio'] = $ac['low_ratio']; //Sets the Min ratio for demoting a class. $minratio = $class_config[$ac['name']]['low_ratio']; //Get the class value we are working on //AND Set the next class value to - 1 $class_value = $class_config[$ac['name']]['name']; $res1 = sql_query("SELECT * from class_config WHERE value = '{$class_value}' "); while ($arr1 = mysqli_fetch_assoc($res1)) { //Changed for testing // As we are working on the class name which is being demoted, we need to -1 from it, to get the class the users are going in // i.e UC_POWER_USER = 1, but we are demoting UC_USER = 0. $class_name = $arr1['classname']; $prev_class = $class_value - 1; /* $class = $arr1['value']; $next_class = $class + 1; */ } // Get the class name and value of the previous class // $res2 = sql_query("SELECT * from class_config WHERE value = '{$prev_class}' "); while ($arr2 = mysqli_fetch_assoc($res2)) { $prev_class_name = $arr2['classname']; } $res = sql_query("SELECT id, uploaded, downloaded, modcomment FROM users WHERE class = {$class_value} AND uploaded / downloaded < {$minratio}") or sqlerr(__FILE__, __LINE__); $subject = "Auto Demotion"; $msgs_buffer = $users_buffer = array(); if (mysqli_num_rows($res) > 0) { $msg = "You have been auto-demoted from [b]{$class_name}[/b] to [b]{$prev_class_name}[/b] because your share ratio has dropped below {$minratio}.\n"; while ($arr = mysqli_fetch_assoc($res)) { $ratio = number_format($arr['uploaded'] / $arr['downloaded'], 3); $modcomment = $arr['modcomment']; $modcomment = get_date(TIME_NOW, 'DATE', 1) . " - Demoted To " . $prev_class_name . " 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'] . ', ' . $prev_class . ', ' . $modcom . ')'; $mc1->begin_transaction('user' . $arr['id']); $mc1->update_row(false, array('class' => $prev_class)); $mc1->commit_transaction($INSTALLER09['expires']['user_cache']); $mc1->begin_transaction('user_stats_' . $arr['id']); $mc1->update_row(false, array('modcomment' => $modcomment)); $mc1->commit_transaction($INSTALLER09['expires']['user_stats']); $mc1->begin_transaction('MYuser_' . $arr['id']); $mc1->update_row(false, array('class' => $prev_class)); $mc1->commit_transaction($INSTALLER09['expires']['curuser']); $mc1->delete_value('inbox_new_' . $arr['id']); $mc1->delete_value('inbox_new_sb_' . $arr['id']); } $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, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE class=values(class),modcomment=values(modcomment)") or sqlerr(__FILE__, __LINE__); write_log("Cleanup: Demoted " . $count . " member(s) from {$class_name} to {$prev_class_name}"); status_change($arr['id']); } unset($users_buffer, $msgs_buffer, $count); status_change($arr['id']); //== For Retros announcement mod } //==End if ($queries > 0) { write_log("{$prev_class_name} Updates -------------------- Power User Demote Updates Clean 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); } } }