From a6a22e7ea9b30c9b9a83b9566cb0fdf768e601a2 Mon Sep 17 00:00:00 2001 From: Xkeeper Date: Sun, 14 Jan 2018 18:37:39 -0800 Subject: [PATCH] Fix the threadfix pages --- admin-threads.php | 40 +++++++++++++++++----------------------- admin-threads2.php | 17 ++++++++--------- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/admin-threads.php b/admin-threads.php index 326ac60..34f6a12 100644 --- a/admin-threads.php +++ b/admin-threads.php @@ -6,10 +6,10 @@ require 'lib/layout.php'; print "$header
"; - + if (!$isadmin) { - print " + print " $tblstart $tccell1>This feature is restricted. $tblend @@ -24,7 +24,7 @@ print adminlinkbar("admin-threads.php"); if (!$_POST['run']) { - print "
+ print " $tblstart $tccellh>Thread Repair System $tccell1>  @@ -57,7 +57,7 @@ "; - $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()); $count = ""; @@ -65,33 +65,28 @@ $status = ""; - if ($data['offset'] != 0) { + if ($data['offset'] != 0 || $data['offset'] === null) { - if ($data['offset'] >= 10000000) { - $data['offset'] = ($data['real'] - 1) - $data['replies']; -// $status = "First post missing or otherwise broken"; -// $data['offset'] = " "; - } - - if (!$status) { + if ($data['replies'] === null) { + $status = "Invalid thread"; + } else { $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 - "; + $tccell1>". $data['thread'] ." + $tccell2l>". ($data['threadname'] !== null ? $data['threadname'] : "(Deleted thread)") ." + $tccell1>". ($data['replies'] !== null ? $data['replies'] + 1 : "—") ." + $tccell1>". ($data['real']) ." + $tccell2>". ($data['offset'] !== null ? $data['offset'] : "—") ." + $tccell1>$status + "; } else { - break; + continue; } } @@ -106,9 +101,8 @@ } } - + print "$tblend $footer "; printtimedif($startingtime); -?> diff --git a/admin-threads2.php b/admin-threads2.php index 8b9a2f6..b089a51 100644 --- a/admin-threads2.php +++ b/admin-threads2.php @@ -6,10 +6,10 @@ require 'lib/layout.php'; print "$header
"; - + if (!$isadmin) { - print " + print " $tblstart $tccell1>This feature is restricted. $tblend @@ -23,7 +23,7 @@ print adminlinkbar("admin-threads2.php"); if (!$_POST['run']) { - print " + print " $tblstart $tccellh>Thread Repair System II $tccell1>  @@ -57,8 +57,8 @@ "; - - $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()); $count = ""; @@ -68,7 +68,7 @@ if ($data['lastpostdate'] != $data['realdate']) { - if ($data['lastpostdate'] == "0" && $data['realdate'] == NULL) { + if ($data['lastpostdate'] == "0" && $data['realdate'] === null) { $status = "Broken thread"; } else { @@ -89,7 +89,7 @@ $tccell1>". ($data['realdate'] ? date($dateformat, $data['realdate'] + $tzoff) : "-") ." $tccell1>". timeunits2($data['lastpostdate'] - $data['realdate']) ." $tccell2l>$status - "; + "; } } @@ -100,9 +100,8 @@ } } - + print "$tblend $footer "; printtimedif($startingtime); -?>