Skip to content

Commit a6a22e7

Browse files
committed
Fix the threadfix pages
1 parent 2f1bc75 commit a6a22e7

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

Diff for: admin-threads.php

+17-23
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
require 'lib/layout.php';
77

88
print "$header<br>";
9-
9+
1010
if (!$isadmin) {
1111

12-
print "
12+
print "
1313
$tblstart
1414
$tccell1>This feature is restricted.</td>
1515
$tblend
@@ -24,7 +24,7 @@
2424
print adminlinkbar("admin-threads.php");
2525

2626
if (!$_POST['run']) {
27-
print "<form action=\"admin-threads.php\" method=\"post\">
27+
print "<form action=\"admin-threads.php\" method=\"post\">
2828
$tblstart
2929
<tr>$tccellh>Thread Repair System</td></tr>
3030
<tr>$tccell1>&nbsp;
@@ -57,41 +57,36 @@
5757
</tr>
5858
";
5959

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";
6161
$sql = mysql_query($q) or die(mysql_error());
6262

6363
$count = "";
6464
while ($data = mysql_fetch_array($sql, MYSQL_ASSOC)) {
6565

6666
$status = "";
6767

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'] = "&nbsp;";
74-
}
68+
if ($data['offset'] != 0 || $data['offset'] === null) {
7569

76-
if (!$status) {
70+
if ($data['replies'] === null) {
71+
$status = "<font color=\"#ff8080\">Invalid thread</font>";
72+
} else {
7773
$status = mysql_query("UPDATE `threads` SET `replies` = '". ($data['real'] - 1) ."' WHERE `id` = '". $data['thread'] ."'") or "<font color=#ff0000>Error</font>: ". mysql_error();
7874
if ($status == 1) $status = "<font color=#80ff80>Updated</font>";
79-
// $status = "Not updated";
8075
$count++;
8176
}
8277

8378
print "
8479
<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 : "&mdash;") ."</td>
83+
$tccell1>". ($data['real']) ."</td>
84+
$tccell2><b>". ($data['offset'] !== null ? $data['offset'] : "&mdash;") ."</b></td>
85+
$tccell1>$status</td>
86+
</tr>";
9287

9388
} else {
94-
break;
89+
continue;
9590
}
9691
}
9792

@@ -106,9 +101,8 @@
106101
}
107102
}
108103

109-
104+
110105
print "$tblend
111106
$footer
112107
";
113108
printtimedif($startingtime);
114-
?>

Diff for: admin-threads2.php

+8-9
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
require 'lib/layout.php';
77

88
print "$header<br>";
9-
9+
1010
if (!$isadmin) {
1111

12-
print "
12+
print "
1313
$tblstart
1414
$tccell1>This feature is restricted.</td>
1515
$tblend
@@ -23,7 +23,7 @@
2323
print adminlinkbar("admin-threads2.php");
2424

2525
if (!$_POST['run']) {
26-
print "<form action=\"admin-threads2.php\" method=\"post\">
26+
print "<form action=\"admin-threads2.php\" method=\"post\">
2727
$tblstart
2828
<tr>$tccellh>Thread Repair System II</td></tr>
2929
<tr>$tccell1>&nbsp;
@@ -57,8 +57,8 @@
5757
";
5858

5959

60-
61-
$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";
60+
61+
$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";
6262
$sql = mysql_query($q) or die(mysql_error());
6363

6464
$count = "";
@@ -68,7 +68,7 @@
6868

6969
if ($data['lastpostdate'] != $data['realdate']) {
7070

71-
if ($data['lastpostdate'] == "0" && $data['realdate'] == NULL) {
71+
if ($data['lastpostdate'] == "0" && $data['realdate'] === null) {
7272
$status = "<font color=#ff8888>Broken thread</font>";
7373
} else {
7474

@@ -89,7 +89,7 @@
8989
$tccell1>". ($data['realdate'] ? date($dateformat, $data['realdate'] + $tzoff) : "-") ."</td>
9090
$tccell1>". timeunits2($data['lastpostdate'] - $data['realdate']) ."</td>
9191
$tccell2l>$status</td>
92-
</tr>";
92+
</tr>";
9393
}
9494
}
9595

@@ -100,9 +100,8 @@
100100
}
101101
}
102102

103-
103+
104104
print "$tblend
105105
$footer
106106
";
107107
printtimedif($startingtime);
108-
?>

0 commit comments

Comments
 (0)