Rewrote every file for readability,
[specialops2.git] / stuff.php
blob26762aafdaa0c476cf73e9a2855fc4dda21d335c
1 <?php
2 // $Id$
4 require 'con.php';
6 usleep(100000); //DoS protection, the stats code is shitty
8 $page->title = 'Stats and Stuff';
10 $user->userheader();
12 $a = 1;
14 $date = array(
15 'today' => mktime(0, 0, 0),
16 'week' => mktime(0, 0, 0) - 86400*(gmdate('w')-1),
17 'month' => mktime(0, 0, 0, gmdate('m'), 1),
18 '24h' => (time()-86400),
19 '7d' => (time()-86400*7),
20 '30d' => (time()-86400*30)
23 /* this does stuff */
24 function getrow($sql)
26 global $DB, $date;
27 $return = '';
28 foreach ($date as $num)
29 $return .= '<td>'.$DB->query(sprintf($sql, $num))->fetch_object()->result.'</td> ';
31 return $return;
35 <table id="board_stats" style="empty-cells: hide">
36 <caption>Board Statistics</caption>
38 <colgroup title="Row headers">
39 <col title="Type of data"/>
40 </colgroup>
41 <colgroup title="Fuzzy statistics">
42 <col/><col/><col/>
43 </colgroup>
44 <colgroup title="Raw statistics">
45 <col/><col/><col/><col/>
46 </colgroup>
48 <thead>
49 <tr>
50 <td/>
51 <th scope="col">Today</th>
52 <th scope="col">This week</th>
53 <th scope="col">This month</th>
54 <th scope="col">Last 24 hours</th>
55 <th scope="col">Last 7 days</th>
56 <th scope="col">Last 30 days</th>
57 <th scope="col">Total</th>
58 </tr>
59 </thead>
61 <tbody>
63 <?php echo
64 '<tr class="content c',(++$a&1),'">
65 <th scope="row" title="Count of all messages">Posts</th>
66 ',getrow('SELECT COUNT(*) AS `result` FROM `messages` WHERE `mtime` > %d'),'
67 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `messages`')->fetch_object()->result,'</td>
68 </tr>
70 <tr class="content c',(++$a&1),'">
71 <th scope="row" title="Any post in direct reply to someone else\'s">Replies</th>
72 ',getrow('SELECT COUNT(*) AS `result` FROM `messages` WHERE `replyto` IS NOT NULL AND `mtime` > %d'),'
73 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `messages`
74 WHERE `replyto` IS NOT NULL')->fetch_object()->result,'</td>
75 </tr>
77 <tr class="content c',(++$a&1),'">
78 <th scope="row" title="Count of all topics">Topics</th>
79 ',getrow('SELECT COUNT(DISTINCT(`topicid`)) AS `result` FROM `messages` WHERE `mtime` > %d'),'
80 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `topics`')->fetch_object()->result,'</td>
81 </tr>
83 <tr class="content c',(++$a&1),'">
84 <th scope="row" title="Number of new users in a time period">Users</th>
85 ',getrow('SELECT COUNT(*) AS `result` FROM `users` WHERE `register_date` > %d'),'
86 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users`')->fetch_object()->result,'</td>
87 </tr>
89 <tr class="content c',(++$a&1),'">
90 <th scope="row" title="Users who\'ve logged in within this time">Online Users</th>
91 ',getrow('SELECT COUNT(`userid`) AS `result` FROM `users`
92 WHERE `last_active_date` > `register_date` AND `last_active_date` > %d'),'
93 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users`
94 WHERE `last_active_date` > `register_date`')->fetch_object()->result,'</td>
95 </tr>
97 <tr class="content c',(++$a&1),'">
98 <th scope="row" title="Users who\'ve posted at least once">Active Users</th>
99 ',getrow('SELECT COUNT(DISTINCT(`users`.`userid`)) AS `result` FROM `users` NATURAL LEFT JOIN `messages`
100 WHERE `messages`.`mtime` > %d'),'
101 <td>',$DB->query('SELECT COUNT(DISTINCT(`users`.`userid`)) AS `result`
102 FROM `users` NATURAL LEFT JOIN `messages`')->fetch_object()->result; ?></td>
103 </tr>
104 </tbody>
106 </table>
108 <h2>Stuff</h2>
109 <h3>Terms of Service</h3>
110 <ul>
111 <li>Don't be a fucking idiot.</li>
112 <li>Anyone caught screwing with the registration system is in full violation of the above rule,
113 and will be forcibly kept out of the site. Same goes for persistent invite-beggers.</li>
114 </ul>
116 <?php
117 $page->pagefooter();