Made scaly theme less crap, set it as default
[specialops2.git] / stuff.php
blob6debe157b96627e639b2c90391a6061ef1cb3c04
1 <?php
2 /**
3 * Statistics, FAQ & TOS
5 * @author Anthony Parsons (xmpp:ant@specialops.ath.cx)
6 * @license file://COPYING
7 * @version $Id$
8 */
10 require 'conf.php';
12 $page->title = 'Stats and Stuff';
13 $user->userheader();
15 /* FIXME: Make these first 3 work for user timezone, not just for UTC */
16 $date = array(
17 'today' => mktime(0, 0, 0),
18 'week' => mktime(0, 0, 0) - 86400 * (gmdate('w')-1),
19 'month' => mktime(0, 0, 0, gmdate('m'), 1),
20 '24h' => (time()-86400),
21 '7d' => (time()-86400*7),
22 '30d' => (time()-86400*30)
25 /* this does stuff */
26 function getrow($sql)
28 global $DB, $date;
29 $return = '';
30 foreach ($date as $num) {
31 $return .= '<td>'.$DB->query(sprintf($sql, $num))->fetch_object()->result.'</td> ';
34 return $return;
38 <table id="board_stats" style="empty-cells: hide">
39 <caption>Board Statistics</caption>
41 <colgroup title="Row headers">
42 <col/>
43 </colgroup>
44 <colgroup title="Fuzzy statistics">
45 <col/><col/><col/>
46 </colgroup>
47 <colgroup title="Raw statistics">
48 <col/><col/><col/><col/>
49 </colgroup>
51 <thead>
52 <tr>
53 <td/>
54 <th title="Since 00:00 UTC">Today</th>
55 <th title="Since 00:00 UTC this Monday">This week</th>
56 <th title="Since 00:00 UTC on the 1st">This month</th>
57 <th>Last 24 hours</th>
58 <th>Last 7 days</th>
59 <th>Last 30 days</th>
60 <th>Total</th>
61 </tr>
62 </thead>
64 <tbody>
66 <?php
67 $a = 1;
69 echo
70 '<tr class="content c',(++$a&1),'">
71 <th scope="row">Posts</th>
72 ',getrow('SELECT COUNT(*) AS `result` FROM `messages` WHERE `mtime` > %d'),'
73 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `messages`')->fetch_object()->result,'</td>
74 </tr>
76 <tr class="content c',(++$a&1),'">
77 <th scope="row">Replies only</th>
78 ',getrow('SELECT COUNT(*) AS `result` FROM `messages` WHERE `replyto` IS NOT NULL AND `mtime` > %d'),'
79 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `messages`
80 WHERE `replyto` IS NOT NULL')->fetch_object()->result,'</td>
81 </tr>
83 <tr class="content c',(++$a&1),'">
84 <th scope="row">Topics</th>
85 ',getrow('SELECT COUNT(DISTINCT(`topicid`)) AS `result` FROM `messages` WHERE `mtime` > %d'),'
86 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `topics`')->fetch_object()->result,'</td>
87 </tr>
89 <tr class="content c',(++$a&1),'">
90 <th scope="row">Total users</th>
91 ',getrow('SELECT COUNT(*) AS `result` FROM `users` WHERE `register_date` > %d'),'
92 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users`')->fetch_object()->result,'</td>
93 </tr>
95 <tr class="content c',(++$a&1),'">
96 <th scope="row">Online users</th>
97 ',getrow('SELECT COUNT(`userid`) AS `result` FROM `users`
98 WHERE `last_active_date` > `register_date` AND `last_active_date` > %d'),'
99 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users`
100 WHERE `last_active_date` > `register_date`')->fetch_object()->result,'</td>
101 </tr>
103 <tr class="content c',(++$a&1),'">
104 <th scope="row">Active users</th>
105 ',getrow('SELECT COUNT(DISTINCT(`users`.`userid`)) AS `result` FROM `users`
106 NATURAL LEFT JOIN `messages` WHERE `messages`.`mtime` > %d'),'
107 <td>',$DB->query('SELECT COUNT(DISTINCT(`users`.`userid`)) AS `result`
108 FROM `users` NATURAL LEFT JOIN `messages`')->fetch_object()->result ?></td>
109 </tr>
110 </tbody>
112 </table>
114 <h2>Terms of Service</h2>
115 <ul>
116 <li>Don't be a fucking idiot.</li>
117 <li>Don't invite them.</li>
118 <li>This site is not affiliated with AOL. Don't behave like an AOLer here.</li>
119 </ul>
121 <?php
122 $page->pagefooter();