-
Notifications
You must be signed in to change notification settings - Fork 10
/
hot_topics.php
73 lines (68 loc) · 2.57 KB
/
hot_topics.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
<?php
require './includes/bootstrap.php';
update_activity('hot_topics', 1);
$template->title = 'Hot topics';
$all_time = $db->q('SELECT headline, id, time, replies FROM topics WHERE deleted = 0 ORDER BY replies DESC LIMIT 50', $_SERVER['REQUEST_TIME']);
$last_hour = $db->q('SELECT headline, id, time, replies FROM topics WHERE time > (? - 3600) AND deleted = 0 ORDER BY replies DESC LIMIT 10', $_SERVER['REQUEST_TIME']);
$last_24_hours = $db->q('SELECT headline, id, time, replies FROM topics WHERE time > (? - 86400) AND deleted = 0 ORDER BY replies DESC LIMIT 10', $_SERVER['REQUEST_TIME']);
$this_week = $db->q('SELECT headline, id, time, replies FROM topics WHERE time > (? - 604800) AND deleted = 0 ORDER BY replies DESC LIMIT 10', $_SERVER['REQUEST_TIME']);
$this_month = $db->q('SELECT headline, id, time, replies FROM topics WHERE time > (? - 2629743) AND deleted = 0 ORDER BY replies DESC LIMIT 10', $_SERVER['REQUEST_TIME']);
?>
<div style="float: left; width: 50%;">
<h2>Last hour:</h2>
<ol>
<?php
while (list($hot_headline, $hot_id, $hot_time, $hot_replies) = $last_hour->fetch()):
?>
<li><a href="<?php echo DIR ?>topic/<?php echo $hot_id ?>"><?php echo htmlspecialchars($hot_headline) ?></a> (<?php echo number_format($hot_replies) ?>)</li>
<?php
endwhile;
?>
</ol>
<h2>Last 24 hours:</h2>
<ol>
<?php
while (list($hot_headline, $hot_id, $hot_time, $hot_replies) = $last_24_hours->fetch()):
?>
<li><a href="<?php echo DIR ?>topic/<?php echo $hot_id ?>"><?php echo htmlspecialchars($hot_headline) ?></a> (<?php echo number_format($hot_replies) ?>)</li>
<?php
endwhile;
?>
</ol>
<h2>This week:</h2>
<ol>
<?php
while (list($hot_headline, $hot_id, $hot_time, $hot_replies) = $this_week->fetch()):
?>
<li><a href="<?php echo DIR ?>topic/<?php echo $hot_id ?>"><?php echo htmlspecialchars($hot_headline) ?></a> (<?php echo number_format($hot_replies) ?>)</li>
<?php
endwhile;
?>
</ol>
<h2>This month:</h2>
<ol>
<?php
while (list($hot_headline, $hot_id, $hot_time, $hot_replies) = $this_month->fetch()):
?>
<li><a href="<?php echo DIR ?>topic/<?php echo $hot_id ?>"><?php echo htmlspecialchars($hot_headline) ?></a> (<?php echo number_format($hot_replies) ?>)</li>
<?php
endwhile;
?>
</ol>
</div>
<div style="float: right; width: 50%;">
<h2>All time:</h2>
<ol>
<?php
while (list($hot_headline, $hot_id, $hot_time, $hot_replies) = $all_time->fetch()):
?>
<li><a href="<?php echo DIR ?>topic/<?php echo $hot_id ?>"><?php echo htmlspecialchars($hot_headline) ?></a> (<?php echo number_format($hot_replies) ?>)</li>
<?php
endwhile;
?>
</ol>
</div>
</div>
<?php
$template->render();
?>