Fix the threadfix pages

This commit is contained in:
Xkeeper 2018-01-14 18:37:39 -08:00
parent 2f1bc75f2b
commit a6a22e7ea9
2 changed files with 25 additions and 32 deletions

View File

@ -57,7 +57,7 @@
</tr> </tr>
"; ";
$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"; $q = "SELECT `posts`.`thread`, (COUNT(`posts`.`id`)) AS 'real', ((CAST(COUNT(`posts`.`id`) AS SIGNED) - 1) - CAST(`threads`.`replies` AS SIGNED)) AS 'offset', `threads`.`replies`, `threads`.`title` AS `threadname` FROM `posts` LEFT JOIN `threads` ON `posts`.`thread` = `threads`.`id` GROUP BY `thread` HAVING `offset` <> 0 OR `offset` IS NULL ORDER BY ISNULL(`threadname`) ASC, `thread` DESC";
$sql = mysql_query($q) or die(mysql_error()); $sql = mysql_query($q) or die(mysql_error());
$count = ""; $count = "";
@ -65,33 +65,28 @@
$status = ""; $status = "";
if ($data['offset'] != 0) { if ($data['offset'] != 0 || $data['offset'] === null) {
if ($data['offset'] >= 10000000) { if ($data['replies'] === null) {
$data['offset'] = ($data['real'] - 1) - $data['replies']; $status = "<font color=\"#ff8080\">Invalid thread</font>";
// $status = "<font color=\"#ff8080\">First post missing or otherwise broken</font>"; } else {
// $data['offset'] = "&nbsp;";
}
if (!$status) {
$status = mysql_query("UPDATE `threads` SET `replies` = '". ($data['real'] - 1) ."' WHERE `id` = '". $data['thread'] ."'") or "<font color=#ff0000>Error</font>: ". mysql_error(); $status = mysql_query("UPDATE `threads` SET `replies` = '". ($data['real'] - 1) ."' WHERE `id` = '". $data['thread'] ."'") or "<font color=#ff0000>Error</font>: ". mysql_error();
if ($status == 1) $status = "<font color=#80ff80>Updated</font>"; if ($status == 1) $status = "<font color=#80ff80>Updated</font>";
// $status = "Not updated";
$count++; $count++;
} }
print " print "
<tr> <tr>
$tccell1>". $data['thread'] ."</td> $tccell1><a href=\"thread.php?id=". $data['thread'] ."\">". $data['thread'] ."</a></td>
$tccell2l><a href=\"thread.php?id=". $data['thread'] ."\">". $data['threadname'] ."</a></td> $tccell2l><a href=\"thread.php?id=". $data['thread'] ."\">". ($data['threadname'] !== null ? $data['threadname'] : "<em>(Deleted thread)</em>") ."</a></td>
$tccell1r>". $data['replies'] ."</td> $tccell1>". ($data['replies'] !== null ? $data['replies'] + 1 : "&mdash;") ."</td>
$tccell1r>". $data['real'] ."</td> $tccell1>". ($data['real']) ."</td>
$tccell2r><b>". $data['offset'] ."</b></td> $tccell2><b>". ($data['offset'] !== null ? $data['offset'] : "&mdash;") ."</b></td>
$tccell1l>$status</td> $tccell1>$status</td>
</tr>"; </tr>";
} else { } else {
break; continue;
} }
} }
@ -111,4 +106,3 @@
$footer $footer
"; ";
printtimedif($startingtime); printtimedif($startingtime);
?>

View File

@ -58,7 +58,7 @@
$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"; $q = "SELECT `threads`.`id`, `threads`.`title` , `threads`.`lastpostdate` , `posts`.`date` as realdate FROM `threads` LEFT JOIN (SELECT MAX(`date`) as `date`, `thread` FROM `posts` GROUP BY `thread`) as `posts` ON `posts`.`thread` = `threads`.`id` ORDER BY `threads`.`id` DESC";
$sql = mysql_query($q) or die(mysql_error()); $sql = mysql_query($q) or die(mysql_error());
$count = ""; $count = "";
@ -68,7 +68,7 @@
if ($data['lastpostdate'] != $data['realdate']) { if ($data['lastpostdate'] != $data['realdate']) {
if ($data['lastpostdate'] == "0" && $data['realdate'] == NULL) { if ($data['lastpostdate'] == "0" && $data['realdate'] === null) {
$status = "<font color=#ff8888>Broken thread</font>"; $status = "<font color=#ff8888>Broken thread</font>";
} else { } else {
@ -105,4 +105,3 @@
$footer $footer
"; ";
printtimedif($startingtime); printtimedif($startingtime);
?>