|
6 | 6 | require 'lib/layout.php';
|
7 | 7 |
|
8 | 8 | print "$header<br>";
|
9 |
| - |
| 9 | + |
10 | 10 | if (!$isadmin) {
|
11 | 11 |
|
12 |
| - print " |
| 12 | + print " |
13 | 13 | $tblstart
|
14 | 14 | $tccell1>This feature is restricted.</td>
|
15 | 15 | $tblend
|
|
24 | 24 | print adminlinkbar("admin-threads.php");
|
25 | 25 |
|
26 | 26 | if (!$_POST['run']) {
|
27 |
| - print "<form action=\"admin-threads.php\" method=\"post\"> |
| 27 | + print "<form action=\"admin-threads.php\" method=\"post\"> |
28 | 28 | $tblstart
|
29 | 29 | <tr>$tccellh>Thread Repair System</td></tr>
|
30 | 30 | <tr>$tccell1>
|
|
57 | 57 | </tr>
|
58 | 58 | ";
|
59 | 59 |
|
60 |
| - $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"; |
| 60 | + $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"; |
61 | 61 | $sql = mysql_query($q) or die(mysql_error());
|
62 | 62 |
|
63 | 63 | $count = "";
|
64 | 64 | while ($data = mysql_fetch_array($sql, MYSQL_ASSOC)) {
|
65 | 65 |
|
66 | 66 | $status = "";
|
67 | 67 |
|
68 |
| - if ($data['offset'] != 0) { |
69 |
| - |
70 |
| - if ($data['offset'] >= 10000000) { |
71 |
| - $data['offset'] = ($data['real'] - 1) - $data['replies']; |
72 |
| -// $status = "<font color=\"#ff8080\">First post missing or otherwise broken</font>"; |
73 |
| -// $data['offset'] = " "; |
74 |
| - } |
| 68 | + if ($data['offset'] != 0 || $data['offset'] === null) { |
75 | 69 |
|
76 |
| - if (!$status) { |
| 70 | + if ($data['replies'] === null) { |
| 71 | + $status = "<font color=\"#ff8080\">Invalid thread</font>"; |
| 72 | + } else { |
77 | 73 | $status = mysql_query("UPDATE `threads` SET `replies` = '". ($data['real'] - 1) ."' WHERE `id` = '". $data['thread'] ."'") or "<font color=#ff0000>Error</font>: ". mysql_error();
|
78 | 74 | if ($status == 1) $status = "<font color=#80ff80>Updated</font>";
|
79 |
| -// $status = "Not updated"; |
80 | 75 | $count++;
|
81 | 76 | }
|
82 | 77 |
|
83 | 78 | print "
|
84 | 79 | <tr>
|
85 |
| - $tccell1>". $data['thread'] ."</td> |
86 |
| - $tccell2l><a href=\"thread.php?id=". $data['thread'] ."\">". $data['threadname'] ."</a></td> |
87 |
| - $tccell1r>". $data['replies'] ."</td> |
88 |
| - $tccell1r>". $data['real'] ."</td> |
89 |
| - $tccell2r><b>". $data['offset'] ."</b></td> |
90 |
| - $tccell1l>$status</td> |
91 |
| - </tr>"; |
| 80 | + $tccell1><a href=\"thread.php?id=". $data['thread'] ."\">". $data['thread'] ."</a></td> |
| 81 | + $tccell2l><a href=\"thread.php?id=". $data['thread'] ."\">". ($data['threadname'] !== null ? $data['threadname'] : "<em>(Deleted thread)</em>") ."</a></td> |
| 82 | + $tccell1>". ($data['replies'] !== null ? $data['replies'] + 1 : "—") ."</td> |
| 83 | + $tccell1>". ($data['real']) ."</td> |
| 84 | + $tccell2><b>". ($data['offset'] !== null ? $data['offset'] : "—") ."</b></td> |
| 85 | + $tccell1>$status</td> |
| 86 | + </tr>"; |
92 | 87 |
|
93 | 88 | } else {
|
94 |
| - break; |
| 89 | + continue; |
95 | 90 | }
|
96 | 91 | }
|
97 | 92 |
|
|
106 | 101 | }
|
107 | 102 | }
|
108 | 103 |
|
109 |
| - |
| 104 | + |
110 | 105 | print "$tblend
|
111 | 106 | $footer
|
112 | 107 | ";
|
113 | 108 | printtimedif($startingtime);
|
114 |
| -?> |
0 commit comments