function manualclean() { global $params; if (function_exists('docleanup')) { stderr('ERROR', 'Another cleanup operation is already in progress. Refresh to try again.'); } $opts = array('options' => array('min_range' => 1)); $params['cid'] = filter_var($params['cid'], FILTER_VALIDATE_INT, $opts); if (!is_numeric($params['cid'])) { stderr('Error', "Bad you!"); } $params['cid'] = sqlesc($params['cid']); $sql = sql_query("SELECT * FROM cleanup WHERE clean_id = {$params['cid']}") or sqlerr(__FILE__, __LINE__); $row = mysqli_fetch_assoc($sql); if ($row['clean_id']) { $next_clean = intval(TIME_NOW + ($row['clean_increment'] ? $row['clean_increment'] : 15 * 60)); sql_query("UPDATE cleanup SET clean_time = {$next_clean} WHERE clean_id = {$row['clean_id']}") or sqlerr(__FILE__, __LINE__); if (is_file(CLEAN_DIR . '' . $row['clean_file'])) { require_once CLEAN_DIR . '' . $row['clean_file']; } if (function_exists('docleanup')) { docleanup($row); } } cleanup_show_main(); //instead of header() so can see queries in footer (using sql_query()) exit; }
function manualclean() { global $params, $lang; if (function_exists('docleanup')) { stderr($lang['cleanup_stderr'], $lang['cleanup_stderr1']); } $opts = array('options' => array('min_range' => 1)); $params['cid'] = filter_var($params['cid'], FILTER_VALIDATE_INT, $opts); if (!is_numeric($params['cid'])) { stderr($lang['cleanup_stderr'], $lang['cleanup_stderr2']); } $params['cid'] = sqlesc($params['cid']); $sql = sql_query("SELECT * FROM cleanup WHERE clean_id = " . sqlesc($params['cid'])) or sqlerr(__FILE__, __LINE__); $row = mysqli_fetch_assoc($sql); if ($row['clean_id']) { $next_clean = intval(TIME_NOW + ($row['clean_increment'] ? $row['clean_increment'] : 15 * 60)); sql_query("UPDATE cleanup SET clean_time = " . sqlesc($next_clean) . " WHERE clean_id = " . sqlesc($row['clean_id'])) or sqlerr(__FILE__, __LINE__); if (is_file(CLEAN_DIR . '' . $row['clean_file'])) { require_once CLEAN_DIR . 'clean_log.php'; require_once CLEAN_DIR . '' . $row['clean_file']; } if (function_exists('docleanup')) { docleanup($row); } } cleanup_show_main(); //instead of header() so can see queries in footer (using sql_query()) exit; }
<?php require_once "include/bittorrent.php"; dbconn(); loggedinorreturn(); if (get_user_class() != UC_SYSOP) { exit; } docleanup(); print "Done";
<?php ob_start(); header("Content-type:text/html;charset=utf-8"); require_once "include/bittorrent.php"; dbconn(); if (get_user_class() < UC_SYSOP) { die('forbidden'); } echo "<html><head><title>Do Clean-up</title></head><body>"; echo "<p>"; echo "clean-up in progress...please wait<br />"; ob_flush(); flush(); if ($_GET['forceall']) { $forceall = 1; } else { $forceall = 0; echo "you may force full clean-up by adding the parameter 'forceall=1' to URL<br />"; } echo "</p>"; $tstart = getmicrotime(); require_once "include/cleanup.php"; print "<p>" . docleanup($forceall, 1) . "</p>"; $tend = getmicrotime(); $totaltime = $tend - $tstart; printf("Time consumed: %f sec<br />", $totaltime); echo "Done<br />"; echo "</body></html>";
function autoclean() { global $TBDEV; $now = time(); //$docleanup = 0; $res = mysql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'"); $row = mysql_fetch_array($res); if (!$row) { mysql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime',{$now})"); return; } $ts = $row[0]; if ($ts + $TBDEV['autoclean_interval'] > $now) { return; } mysql_query("UPDATE avps SET value_u={$now} WHERE arg='lastcleantime' AND value_u = {$ts}"); if (!mysql_affected_rows()) { return; } docleanup(); }
function autoclean() { global $TBDEV; $now = time(); /* Better cleanup function with db-optimization and slow clean by x0r @ tbdev.net */ $w00p = sql_query("SELECT arg, value_u FROM avps") or sqlerr(__FILE__, __LINE__); while ($row = mysql_fetch_assoc($w00p)) { if ($row['arg'] == "lastcleantime" && $row['value_u'] + $TBDEV['autoclean_interval'] < $now) { sql_query("UPDATE avps SET value_u = '{$now}' WHERE arg = 'lastcleantime'") or sqlerr(__FILE__, __LINE__); require_once INCL_DIR . 'cleanup.php'; docleanup(); } else { if ($row['arg'] == "lastslowcleantime" && $row['value_u'] + $TBDEV['autoslowclean_interval'] < $now) { sql_query("UPDATE avps SET value_u = '{$now}' WHERE arg = 'lastslowcleantime'") or sqlerr(__FILE__, __LINE__); require_once INCL_DIR . 'cleanup.php'; doslowcleanup(); } else { if ($row['arg'] == "lastslowcleantime2" && $row['value_u'] + $TBDEV['autoslowclean_interval2'] < $now) { sql_query("UPDATE avps SET value_u = '{$now}' WHERE arg = 'lastslowcleantime2'") or sqlerr(__FILE__, __LINE__); require_once INCL_DIR . 'cleanup.php'; doslowcleanup2(); } else { if ($row['arg'] == "lastoptimizedbtime" && $row['value_u'] + $TBDEV['optimizedb_interval'] < $now) { sql_query("UPDATE avps SET value_u = '{$now}' WHERE arg = 'lastoptimizedbtime'") or sqlerr(__FILE__, __LINE__); require_once INCL_DIR . 'cleanup.php'; dooptimizedb(); } } } } } mysql_free_result($w00p); return; }
function autoclean() { global $autoclean_interval_one, $rootpath; $now = TIMENOW; $res = sql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'"); $row = mysql_fetch_array($res); if (!$row) { sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime',{$now})") or sqlerr(__FILE__, __LINE__); return false; } $ts = $row[0]; if ($ts + $autoclean_interval_one > $now) { return false; } sql_query("UPDATE avps SET value_u={$now} WHERE arg='lastcleantime' AND value_u = {$ts}") or sqlerr(__FILE__, __LINE__); if (!mysql_affected_rows()) { return false; } require_once $rootpath . 'include/cleanup.php'; return docleanup(); }
function autoclean() { global $autoclean_interval, $autoslowclean_interval, $s2autoslowclean_interval, $optimizedb_interval, $backupdb_interval, $autohitrun_interval; $now = gmtime(); /* Better cleanup function with db-optimization dbbackup - //==added hitandrun==// by x0r @ tbdev.net */ $w00p = sql_query("SELECT arg, value_u FROM avps") or sqlerr(__FILE__, __LINE__); while ($row = mysql_fetch_assoc($w00p)) { if ($row['arg'] == "lastcleantime" && $row['value_u'] + $autoclean_interval < $now) { sql_query("UPDATE avps SET value_u = '{$now}' WHERE arg = 'lastcleantime'") or sqlerr(__FILE__, __LINE__); docleanup(); } else { if ($row['arg'] == "lastslowcleantime" && $row['value_u'] + $autoslowclean_interval < $now) { sql_query("UPDATE avps SET value_u = '{$now}' WHERE arg = 'lastslowcleantime'") or sqlerr(__FILE__, __LINE__); doslowcleanup(); } else { if ($row['arg'] == "s2slowcleantime" && $row['value_u'] + $s2autoslowclean_interval < $now) { sql_query("UPDATE avps SET value_u = '{$now}' WHERE arg = 's2slowcleantime'") or sqlerr(__FILE__, __LINE__); dos2slowcleanup(); } else { if ($row['arg'] == "lastoptimizedbtime" && $row['value_u'] + $optimizedb_interval < $now) { sql_query("UPDATE avps SET value_u = '{$now}' WHERE arg = 'lastoptimizedbtime'") or sqlerr(__FILE__, __LINE__); dooptimizedb(); } else { if ($row['arg'] == "lastbackupdbtime" && $row['value_u'] + $backupdb_interval < $now) { sql_query("UPDATE avps SET value_u = '{$now}' WHERE arg = 'lastbackupdbtime'") or sqlerr(__FILE__, __LINE__); dobackupdb(); } else { if ($row['arg'] == "lastautohitruntime" && $row['value_u'] + $autohitrun_interval < $now) { sql_query("UPDATE avps SET value_u = '{$now}' WHERE arg = 'lastautohitruntime'") or sqlerr(__FILE__, __LINE__); doautohitrun(); } } } } } } } mysql_free_result($w00p); return; }
function autoclean() { global $INSTALLER09; /* Better cleanup function with db-optimization and slow clean by x0r @ tbdev.net */ $w00p = sql_query("SELECT arg, value_u FROM avps") or sqlerr(__FILE__, __LINE__); while ($row = mysql_fetch_assoc($w00p)) { if ($INSTALLER09['docleanup'] == 1 && $row['arg'] == "lastcleantime" && $row['value_u'] + $INSTALLER09['autoclean_interval'] < TIME_NOW) { sql_query("UPDATE avps SET value_u = " . TIME_NOW . " WHERE arg = 'lastcleantime'") or sqlerr(__FILE__, __LINE__); require_once INCL_DIR . 'cleanup.php'; docleanup(); } else { if ($INSTALLER09['doslowcleanup'] == 1 && $row['arg'] == "lastslowcleantime" && $row['value_u'] + $INSTALLER09['autoslowclean_interval'] < TIME_NOW) { sql_query("UPDATE avps SET value_u = " . TIME_NOW . " WHERE arg = 'lastslowcleantime'") or sqlerr(__FILE__, __LINE__); require_once INCL_DIR . 'cleanup.php'; doslowcleanup(); } else { if ($INSTALLER09['doslowleanup2'] == 1 && $row['arg'] == "lastslowcleantime2" && $row['value_u'] + $INSTALLER09['autoslowclean_interval2'] < TIME_NOW) { sql_query("UPDATE avps SET value_u = " . TIME_NOW . " WHERE arg = 'lastslowcleantime2'") or sqlerr(__FILE__, __LINE__); require_once INCL_DIR . 'cleanup.php'; doslowcleanup2(); } else { if ($INSTALLER09['lotterycleanup'] == 1 && $row['arg'] == "lastlottocleantime" && $row['value_u'] + $INSTALLER09['lotteryclean_interval'] < TIME_NOW) { sql_query("UPDATE avps SET value_u = " . TIME_NOW . " WHERE arg = 'lastlottocleantime'") or sqlerr(__FILE__, __LINE__); require_once INCL_DIR . 'cleanup.php'; dolotterycleanup(); } else { if ($INSTALLER09['optimizedb'] == 1 && $row['arg'] == "lastoptimizedbtime" && $row['value_u'] + $INSTALLER09['optimizedb_interval'] < TIME_NOW) { sql_query("UPDATE avps SET value_u = " . TIME_NOW . " WHERE arg = 'lastoptimizedbtime'") or sqlerr(__FILE__, __LINE__); require_once INCL_DIR . 'cleanup.php'; dooptimizedb(); } else { if ($INSTALLER09['dobackup'] == 1 && $row['arg'] == "lastbackuptime" && $row['value_u'] + $INSTALLER09['autobackup_interval'] < TIME_NOW) { sql_query("UPDATE avps SET value_u = " . TIME_NOW . " WHERE arg = 'lastbackuptime'") or sqlerr(__FILE__, __LINE__); require_once INCL_DIR . 'cleanup.php'; dobackupdb(); } } } } } } } mysql_free_result($w00p); return; }
function autoclean() { global $autoclean_interval; $now = time(); $docleanup = 0; $res = mysql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'"); $row = mysql_fetch_array($res); if (!$row) { mysql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime',$now)"); return; } $ts = $row[0]; if ($ts + $autoclean_interval > $now) return; mysql_query("UPDATE avps SET value_u=$now WHERE arg='lastcleantime' AND value_u = $ts"); if (!mysql_affected_rows()) return; docleanup(); }
function autoclean() { global $autoclean_interval, $rootpath; $now = time(); $docleanup = 0; $res = sql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'"); $row = mysql_fetch_array($res); if (!$row) { sql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime',{$now})"); return; } $ts = $row[0]; if ($ts + $autoclean_interval > $now) { return; } if ($ts > $now) { // F**k, someone has set time in future! sql_query("UPDATE avps SET value_u={$now} WHERE arg='lastcleantime' AND value_u = {$ts}"); return; } sql_query("UPDATE avps SET value_u={$now} WHERE arg='lastcleantime' AND value_u = {$ts}"); if (!mysql_affected_rows()) { return; } require_once $rootpath . 'include/cleanup.php'; docleanup(); }