Make expire.php work seemlessly even on large workloads

This commit is contained in:
8chan 2014-10-05 17:06:39 +00:00
parent 99e95bb807
commit f42173b260

View File

@ -53,8 +53,8 @@ foreach($boards as $board) {
}
}
#if (($last_activity_date < $ago or ($last_mod_date and $last_mod_date < $mod_ago)) and (int)$count['count'] < 30) {
if (($last_activity_date < $ago or ($last_mod_date and $last_mod_date < $mod_ago)) and isset($mods[0]['id'])) {
if (($last_activity_date < $ago or ($last_mod_date and $last_mod_date < $mod_ago)) and (int)$count['count'] < 30 and isset($mods[0]['id'])) {
#if (($last_activity_date < $ago or ($last_mod_date and $last_mod_date < $mod_ago)) and isset($mods[0]['id'])) {
echo $board, ' ', $last_activity_date->format('Y-m-d H:i:s'), ' ', ($last_mod_date ? $last_mod_date->format('Y-m-d H:i:s') : 'false'), ' ', $count['count'], ' ', $mod, "\r\n";
$delete[] = array('board' => $board, 'last_activity' => $last_activity_date, 'last_mod' => $last_mod_date, 'mod' => isset($mods[0]['username']) ? $mods[0]['username'] : false, 'count' => $count['count']);
}
@ -63,6 +63,7 @@ if ($argc > 1) {
$f = fopen('rip.txt', 'a');
fwrite($f, "--\r\n".date('c')."\r\n");
foreach($delete as $i => $d){
file_get_contents('http://8chan.co/listboards.php');
$s = "RIP /".$d['board']."/, created by ".($d['mod']?$d['mod']:'?')." and last active on ".$d['last_activity']->format('Y-m-d H:i:s.').($d['last_mod'] ? ' Mod last active on ' . $d['last_mod']->format('Y-m-d H:i:s.') : ' Mod never active.') . " Number of posts: {$d['count']}." . "\r\n";
echo $s;
fwrite($f, $s);
@ -138,7 +139,7 @@ foreach($delete as $i => $d){
_syslog(LOG_NOTICE, "Board deleted: {$board['uri']}");
if ($d['mod']) {
$query = prepare('DELETE FROM ``mods`` WHERE `username` = :id');
$query = prepare('DELETE FROM ``mods`` WHERE `username` = BINARY :id');
$query->bindValue(':id', $d['mod']);
$query->execute() or error(db_error($query));
}
@ -149,4 +150,3 @@ cache::delete('all_boards_uri');
cache::delete('all_boards');
rebuildThemes('boards');
$query = query('DELETE FROM board_create WHERE uri NOT IN (SELECT uri FROM boards);') or error(db_error());
file_get_contents('http://127.0.0.1/listboards.php');