Make the userlist do the right thing with a lot of users
[specialops2.git] / stuff.php
blob8720a811a531c7c47b3f00896709d1c65f0a5694
1 <?php
2 // $Id$
4 require 'con.php';
6 $page->title = 'Stats and Stuff';
7 $user->userheader();
9 $date = array(
10 'today' => mktime(0, 0, 0),
11 'week' => mktime(0, 0, 0) - 86400*(gmdate('w')-1),
12 'month' => mktime(0, 0, 0, gmdate('m'), 1),
13 '24h' => (time()-86400),
14 '7d' => (time()-86400*7),
15 '30d' => (time()-86400*30)
18 /* this does stuff */
19 function getrow($sql)
21 global $DB, $date;
22 $return = '';
23 foreach ($date as $num)
24 $return .= '<td>'.$DB->query(sprintf($sql, $num))->fetch_object()->result.'</td> ';
26 return $return;
30 <table id="board_stats" style="empty-cells: hide">
31 <caption>Board Statistics</caption>
33 <colgroup title="Row headers">
34 <col/>
35 </colgroup>
36 <colgroup title="Fuzzy statistics">
37 <col/><col/><col/>
38 </colgroup>
39 <colgroup title="Raw statistics">
40 <col/><col/><col/><col/>
41 </colgroup>
43 <thead>
44 <tr>
45 <td/>
46 <th>Today</th>
47 <th>This week</th>
48 <th>This month</th>
49 <th>Last 24 hours</th>
50 <th>Last 7 days</th>
51 <th>Last 30 days</th>
52 <th>Total</th>
53 </tr>
54 </thead>
56 <tbody>
58 <?php
59 $a = 1;
61 echo
62 '<tr class="content c',(++$a&1),'">
63 <th scope="row">Posts</th>
64 ',getrow('SELECT COUNT(*) AS `result` FROM `messages` WHERE `mtime` > %d'),'
65 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `messages`')->fetch_object()->result,'</td>
66 </tr>
68 <tr class="content c',(++$a&1),'">
69 <th scope="row">Replies only</th>
70 ',getrow('SELECT COUNT(*) AS `result` FROM `messages` WHERE `replyto` IS NOT NULL AND `mtime` > %d'),'
71 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `messages`
72 WHERE `replyto` IS NOT NULL')->fetch_object()->result,'</td>
73 </tr>
75 <tr class="content c',(++$a&1),'">
76 <th scope="row">Topics</th>
77 ',getrow('SELECT COUNT(DISTINCT(`topicid`)) AS `result` FROM `messages` WHERE `mtime` > %d'),'
78 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `topics`')->fetch_object()->result,'</td>
79 </tr>
81 <tr class="content c',(++$a&1),'">
82 <th scope="row">Total users</th>
83 ',getrow('SELECT COUNT(*) AS `result` FROM `users` WHERE `register_date` > %d'),'
84 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users`')->fetch_object()->result,'</td>
85 </tr>
87 <tr class="content c',(++$a&1),'">
88 <th scope="row">Online users</th>
89 ',getrow('SELECT COUNT(`userid`) AS `result` FROM `users`
90 WHERE `last_active_date` > `register_date` AND `last_active_date` > %d'),'
91 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users`
92 WHERE `last_active_date` > `register_date`')->fetch_object()->result,'</td>
93 </tr>
95 <tr class="content c',(++$a&1),'">
96 <th scope="row">Active users</th>
97 ',getrow('SELECT COUNT(DISTINCT(`users`.`userid`)) AS `result` FROM `users`
98 NATURAL LEFT JOIN `messages`
99 WHERE `messages`.`mtime` > %d'),'
100 <td>',$DB->query('SELECT COUNT(DISTINCT(`users`.`userid`)) AS `result`
101 FROM `users` NATURAL LEFT JOIN `messages`')->fetch_object()->result ?></td>
102 </tr>
103 </tbody>
105 </table>
107 <h2>Terms of Service</h2>
108 <ul>
109 <li>Don't be a fucking idiot.</li>
110 <li>Don't invite them. Usermap axes are more aggressive here.</li>
111 <li>This board is not AIM. We do not appreciate when people post here using leet-speak, shorthand (eg. "plz", "u"),
112 sentences with no capitalization, etc. Typing in this manner makes you sound like a retarded high-school dropout,
113 and will only draw rude/sarcastic replies.</li>
114 </ul>
116 <?php
117 $page->pagefooter();