-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpostsbytime.php
57 lines (48 loc) · 1.57 KB
/
postsbytime.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
<?php
require 'lib/function.php';
$windowtitle = "Posts by time of day";
require 'lib/layout.php';
if (!isset($_GET['posttime'])) $posttime = 86400;
else $posttime = intval($_GET['posttime']);
if($id) {
$qstrings[] = "user={$id}";
$from = " from ".$sql->resultq("SELECT name FROM users WHERE id=$id");
}
else $from = ' on the board';
if ($posttime !== 0) {
$qstrings[] = "date > ".(ctime()-$posttime);
$during = ' during the last '.timeunits2($posttime);
}
if (empty($qstrings)) $qwhere = '1';
else $qwhere = implode(' AND ', $qstrings);
$posts = $sql->query("SELECT count(*) AS cnt, FROM_UNIXTIME(date,'%k') AS hour FROM posts WHERE {$qwhere} GROUP BY hour");
$link = "<a href=postsbytime.php?" . (($id) ? "id=$id&" : "") . "posttime";
print "$header$smallfont
Timeframe:
$link=86400>Last day</a> |
$link=604800>Last week</a> |
$link=2592000>Last 30 days</a> |
$link=31536000>Last year</a> |
$link=0>All-time</a><br>
$fonttag Posts$from by time of day$during:
$tblstart
$tccellh width=100>Time</td>
$tccellh width=50>Posts</td>
$tccellh> </tr>";
$postshour = array_fill(0, 24, 0);
$max = 0;
while($h=$sql->fetch($posts))
if (($postshour[$h['hour']] = $h['cnt']) > $max)
$max = $h['cnt'];
for($i=0;$i<24;$i++) {
$time = sprintf('%1$02d:00 - %1$02d:59', $i);
$bar = "<img src=images/$numdir".'bar-on.gif width='.(@floor($postshour[$i]/$max*10000)/100).'% height=8>';
print "<tr>
$tccell2s>$time</td>
$tccell2s>$postshour[$i]</td>
$tccell1ls width=*>$bar</td>
</tr>";
}
print $tblend.$footer;
printtimedif($startingtime);
?>