Add User::toString, get rid of unnecessary crap in User_Anon
[specialops2.git] / stuff.php
blob8090a7420f3b58305e1ddacaf74128ec4368b4a9
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 'con.php';
12 $page->title = 'The other 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>Stats</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>
65 <?php
66 $a = 1;
68 echo
69 '<tr class="content c',(++$a&1),'">
70 <th scope="row">Posts</th>
71 ',getrow('SELECT COUNT(*) AS `result` FROM `messages` WHERE `mtime` > %d'),'
72 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `messages`')->fetch_object()->result,'</td>
73 </tr>
75 <tr class="content c',(++$a&1),'">
76 <th scope="row">Replies only</th>
77 ',getrow('SELECT COUNT(*) AS `result` FROM `messages` WHERE `replyto` IS NOT NULL AND `mtime` > %d'),'
78 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `messages`
79 WHERE `replyto` IS NOT NULL')->fetch_object()->result,'</td>
80 </tr>
82 <tr class="content c',(++$a&1),'">
83 <th scope="row">Topics</th>
84 ',getrow('SELECT COUNT(DISTINCT(`topicid`)) AS `result` FROM `messages` WHERE `mtime` > %d'),'
85 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `topics`')->fetch_object()->result,'</td>
86 </tr>
88 <tr class="content c',(++$a&1),'">
89 <th scope="row">Total users</th>
90 ',getrow('SELECT COUNT(*) AS `result` FROM `users` WHERE `register_date` > %d'),'
91 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users`')->fetch_object()->result,'</td>
92 </tr>
94 <tr class="content c',(++$a&1),'">
95 <th scope="row">Online users</th>
96 ',getrow('SELECT COUNT(`userid`) AS `result` FROM `users`
97 WHERE `last_active_date` > `register_date` AND `last_active_date` > %d'),'
98 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users`
99 WHERE `last_active_date` > `register_date`')->fetch_object()->result,'</td>
100 </tr>
102 <tr class="content c',(++$a&1),'">
103 <th scope="row">Active users</th>
104 ',getrow('SELECT COUNT(DISTINCT(`users`.`userid`)) AS `result` FROM `users`
105 NATURAL LEFT JOIN `messages` WHERE `messages`.`mtime` > %d'),'
106 <td>',$DB->query('SELECT COUNT(DISTINCT(`users`.`userid`)) AS `result`
107 FROM `users` NATURAL LEFT JOIN `messages`')->fetch_object()->result ?></td>
108 </tr>
109 </tbody>
110 </table>
112 <h2>Board Rules</h2>
113 <ul>
114 <li>Inactive accounts get deleted.</li>
115 <li>Inviting idiots will result in a verbal warning and those accounts being deleted without refund.
116 Persisting will get your own account deleted.</li>
117 </ul>
119 <?php
120 $page->pagefooter();