db_exec("delete from f_upostcount where fid <=0 || aid <= 0 || count <=0"); echo ", cleaning up tracking"; db_exec("delete from f_tracking where fid <=0 || tid <= 0 || aid <= 0 || tstamp > NOW()"); /* Grab all of the indexes for the forum */ $sth2 = db_query("select * from f_indexes where fid = ? order by iid", array($forum['fid'])); $indexes = $sth2->fetchAll(PDO::FETCH_ASSOC); $sth2->closeCursor(); /* Clear out tracking */ $sth2 = db_query("select * from f_tracking where fid = ? and TO_DAYS(NOW()) - TO_DAYS(tstamp) > 365", array($forum['fid'])); $i = 0; echo " (rows):"; while ($tracking = $sth2->fetch()) { if ($i % 100 == 0) { echo " {$i}"; } $index = find_thread_index($tracking['tid']); if ($index < 0) { echo "Tracking index < 0! (tid = " . $tracking['tid'] . ", aid = " . $tracking['aid'] . ", tstamp = " . $tracking['tstamp'] . ", options = '" . $tracking['options'] . "')\n"; $delete = 1; } else { $row = db_query_first("select tstamp from f_threads{$index} where tid = ? and TO_DAYS(NOW()) - TO_DAYS(tstamp) > 365", array($tracking['tid'])); } $delete = $row ? $row[0] : NULL; if ($delete) { db_exec("delete from f_tracking where fid = ? and tid = ? and aid = ?", array($forum['fid'], $tracking['tid'], $tracking['aid'])); } $i++; } $sth2->closeCursor(); echo " OK"; /* DONT SHARD for now */
function tid_to_iid($tid) { global $indexes; $index = find_thread_index($tid); if (!isset($index)) { return null; } return $indexes[$index]['iid']; }