-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathadmin-threads2.php
107 lines (85 loc) · 3.01 KB
/
admin-threads2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
$windowtitle = "Thread Repair System II";
require 'lib/function.php';
require 'lib/layout.php';
print "$header<br>";
if (!$isadmin) {
print "
$tblstart
$tccell1>This feature is restricted.</td>
$tblend
$footer
";
printtimedif($startingtime);
die();
}
print adminlinkbar("admin-threads2.php");
if (!$_POST['run']) {
print "<form action=\"admin-threads2.php\" method=\"post\">
$tblstart
<tr>$tccellh>Thread Repair System II</td></tr>
<tr>$tccell1>
<br>This page is intended to repair threads with broken 'last reply' times/users.
<br>This problem causes bumped threads that shouldn't be, especially with badly deleted posts.
<br>
<br>$inps=\"run\" value=\"Start\">
<br>
</td></tr>
$tblend
</form>
";
} else {
print "
$tblstart
<tr>$tccellh>Thread Repair System II</td></tr>
<tr>$tccell1>Now running.
</td></tr>
$tblend
<br>
$tblstart
<tr>
$tccellh>id#</td>
$tccellh>Name</td>
$tccellh>Reported Date</td>
$tccellh>Real Date</td>
$tccellh>Difference</td>
$tccellh>Status</td>
</tr>
";
$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 = "";
while ($data = mysql_fetch_array($sql, MYSQL_ASSOC)) {
$status = "";
if ($data['lastpostdate'] != $data['realdate']) {
if ($data['lastpostdate'] == "0" && $data['realdate'] === null) {
$status = "<font color=#ff8888>Broken thread</font>";
} 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 "<font color=#ff0000>Error</font>: ". mysql_error();
if ($status == 1) $status = "<font color=#80ff80>Updated</font>";
$count++;
}
}
if ($status) {
print "
<tr>
$tccell1>". $data['id'] ."</td>
$tccell2l><a href=\"thread.php?id=". $data['id'] ."\">". $data['title'] ."</a></td>
$tccell1>". ($data['lastpostdate'] ? date($dateformat, $data['lastpostdate'] + $tzoff) : "-") ."</td>
$tccell1>". ($data['realdate'] ? date($dateformat, $data['realdate'] + $tzoff) : "-") ."</td>
$tccell1>". timeunits2($data['lastpostdate'] - $data['realdate']) ."</td>
$tccell2l>$status</td>
</tr>";
}
}
if ($count) {
print "<tr>$tccellc colspan=6>$count thread". ($count != 1 ? "s" : "") ." updated.</td></tr>";
} else {
print "<tr>$tccellc colspan=6>Nothing to repair.</td></tr>";
}
}
print "$tblend
$footer
";
printtimedif($startingtime);