-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpostsbythread.php
85 lines (71 loc) · 2.58 KB
/
postsbythread.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
<?php
require 'lib/function.php';
$_GET['id'] = filter_int($_GET['id']);
$qstrings = array();
if ($_GET['id']) {
$qstrings[] = "p.user = {$_GET['id']}";
$by = 'by '.$sql->resultq("SELECT name FROM users WHERE id = {$_GET['id']}");
} else {
$by = "";
}
$_GET['posttime'] = isset($_GET['posttime']) ? (int) $_GET['posttime'] : 86400;
if (!$_GET['id'] && (!$_GET['posttime'] || $_GET['posttime'] > 2592000)) // All posts
$_GET['posttime'] = 2592000;
if ($_GET['posttime']) {
$qstrings[] = "p.date > ".(ctime()-$_GET['posttime']);
$during = ' during the last '.timeunits2($_GET['posttime']);
} else {
$during = "";
}
if (empty($qstrings)) $qwhere = '1';
else $qwhere = implode(' AND ', $qstrings);
$posters = $sql->query(
"SELECT t.id, t.replies, t.title, t.forum, f.minpower, f.title ftitle, f.login, COUNT(p.id) cnt ".
"FROM threads t ".
"LEFT JOIN forums f ON f.id = t.forum ".
"LEFT JOIN posts p ON t.id = p.thread ".
"WHERE {$qwhere} AND ($ismod OR !ISNULL(f.id)) ".
"GROUP BY t.id ".
"ORDER BY cnt DESC, t.firstpostdate DESC ".
"LIMIT 1000");
pageheader();
?>
<span class="fonts">
<a href='postsbythread.php?id=<?=$_GET['id']?>&posttime=3600'>During last hour</a> |
<a href='postsbythread.php?id=<?=$_GET['id']?>&posttime=86400'>During last day</a> |
<a href='postsbythread.php?id=<?=$_GET['id']?>&posttime=604800'>During last week</a> |
<a href='postsbythread.php?id=<?=$_GET['id']?>&posttime=2592000'>During last 30 days</a>
<?=((!$_GET['id']) ? "" : " | <a href='postsbythread.php?id={$_GET['id']}&posttime=0'>Total</a>")?>
<br>
</span>
<span class="font"> Posts <?=$by?> in threads<?=$during?>:</span>
<table class='table'>
<tr>
<td class='tdbgh center' width=30> </td>
<td class='tdbgh center' width=300>Forum</td>
<td class='tdbgh center'>Thread</td>
<td class='tdbgh center' width=70>Posts</td>
<td class='tdbgh center' width=90>Thread total</td>
</tr>
<?php
for ($i = 1; $t=$sql->fetch($posters); ++$i) {
if (!can_view_forum($t)) {
$forum = '(restricted forum)';
$thread = '(private thread)';
} else {
$forum = "<a href='forum.php?id={$t['forum']}'>".htmlspecialchars($t['ftitle'])."</a>";
$thread = "<a href='thread.php?id={$t['id']}'>".htmlspecialchars($t['title'])."</a>";
}
?>
<tr>
<td class='tdbg2 center'><?=$i?></td>
<td class='tdbg2 center'><?=$forum?></td>
<td class='tdbg1'><?=$thread?></td>
<td class='tdbg1 center' style='font-weight:bold;'><b><?=$t['cnt']?></td>
<td class='tdbg1 center'><?=($t['replies']+1)?></td>
</tr>
<?php
}
?> </table>
<?php
pagefooter();