"; if (!$isadmin) { print " $tblstart $tccell1>This feature is restricted. $tblend $footer "; printtimedif($startingtime); die(); } print adminlinkbar("admin-threads2.php"); if (!$_POST['run']) { print "
$tblstart $tccellh>Thread Repair System II $tccell1> 
This page is intended to repair threads with broken 'last reply' times/users.
This problem causes bumped threads that shouldn't be, especially with badly deleted posts.
 
$inps=\"run\" value=\"Start\">
  $tblend
"; } else { print " $tblstart $tccellh>Thread Repair System II $tccell1>Now running. $tblend
$tblstart $tccellh>id# $tccellh>Name $tccellh>Reported Date $tccellh>Real Date $tccellh>Difference $tccellh>Status "; $q = "SELECT `threads`.`id`, `threads`.`title` , `threads`.`lastpostdate` , `posts`.`date` as realdate, (`posts`.`date` - `threads`.`lastpostdate`) AS `diff` FROM `threads` LEFT JOIN (SELECT MAX(`date`) as `date`, `thread` FROM `posts` GROUP BY `thread`) as `posts` ON `posts`.`thread` = `threads`.`id` ORDER BY `diff` DESC"; $sql = mysql_query($q) or die(mysql_error()); $count = ""; while ($data = mysql_fetch_array($sql, MYSQL_ASSOC)) { $status = ""; if ($data['lastpostdate'] != $data['realdate']) { if ($data['lastpostdate'] == "0" && $data['realdate'] == NULL) { $status = "Broken thread"; } else { $userd = mysql_fetch_array(mysql_query("SELECT `date`, `user` FROM `posts` WHERE `thread` = '". $data['id'] ."' ORDER BY `date` DESC LIMIT 1"), MYSQL_ASSOC); $status = mysql_query("UPDATE `threads` SET `lastposter` = '". $userd['user'] ."', `lastpostdate` = '". $userd['date'] ."' WHERE `id` = '". $data['id'] ."'") or "Error: ". mysql_error(); if ($status == 1) $status = "Updated"; $count++; } } if ($status) { print " $tccell1>". $data['id'] ." $tccell2l>". $data['title'] ." $tccell1>". ($data['lastpostdate'] ? date($dateformat, $data['lastpostdate'] + $tzoff) : "-") ." $tccell1>". ($data['realdate'] ? date($dateformat, $data['realdate'] + $tzoff) : "-") ." $tccell1>". timeunits2($data['lastpostdate'] - $data['realdate']) ." $tccell2l>$status "; } } if ($count) { print "$tccellc colspan=6>$count thread". ($count != 1 ? "s" : "") ." updated."; } else { print "$tccellc colspan=6>Nothing to repair."; } } print "$tblend $footer "; printtimedif($startingtime); ?>