"; if (!$isadmin) { print " $tblstart $tccell1>This feature is restricted. $tblend $footer "; printtimedif($startingtime); die(); } print adminlinkbar("admin-threads.php"); if (!$_POST['run']) { print "
$tblstart $tccellh>Thread Repair System $tccell1> 
This page is intended to repair threads with broken reply counts. Please don't flood it with requests.
This problem causes \"phantom pages\" (e.g., too few or too many pages displayed).
 
$inps=\"run\" value=\"Start\">
  $tblend
"; } else { print " $tblstart $tccellh>Thread Repair System $tccell1>Now running. $tblend
$tblstart $tccellh>id# $tccellh>Name $tccellh>Reports $tccellh>Real $tccellh>Err $tccellh>Status "; $q = "SELECT `posts`.`thread`, (COUNT(`posts`.`id`)) AS 'real', ((COUNT(`posts`.`id`) - 1) - `threads`.`replies`) AS 'offset', `threads`.`replies`, `threads`.`title` AS `threadname` FROM `posts` LEFT JOIN `threads` ON `posts`.`thread` = `threads`.`id` GROUP BY `thread` ORDER BY `offset` DESC"; $sql = mysql_query($q) or die(mysql_error()); $count = ""; while ($data = mysql_fetch_array($sql, MYSQL_ASSOC)) { $status = ""; if ($data['offset'] != 0) { if ($data['offset'] >= 10000000) { $data['offset'] = ($data['real'] - 1) - $data['replies']; // $status = "First post missing or otherwise broken"; // $data['offset'] = " "; } if (!$status) { $status = mysql_query("UPDATE `threads` SET `replies` = '". ($data['real'] - 1) ."' WHERE `id` = '". $data['thread'] ."'") or "Error: ". mysql_error(); if ($status == 1) $status = "Updated"; // $status = "Not updated"; $count++; } print " $tccell1>". $data['thread'] ." $tccell2l>". $data['threadname'] ." $tccell1r>". $data['replies'] ." $tccell1r>". $data['real'] ." $tccell2r>". $data['offset'] ." $tccell1l>$status "; } else { break; } } if ($count) { print "$tccellc colspan=6>$count thread". ($count != 1 ? "s" : "") ." updated."; } else { print " $tccell1 colspan=6> 
No problems found.
  "; } } print "$tblend $footer "; printtimedif($startingtime); ?>