DB update + fixed messagelist
[specialops2.git] / stuff.php
blob7dc8169b29c9643502f21b20509d418d3b3009f0
1 <?php
2 // $Id$
4 require 'con.php';
6 usleep(100000); //DoS protection
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 <h2>Stats</h2>
37 <table id="board_stats" style="empty-cells: hide">
38 <caption><?php echo _('Board Statistics') ?></caption>
40 <colgroup title="<?php echo _('Row headers') ?>">
41 <col title="<?php echo _('Type of data') ?>"/>
42 </colgroup>
43 <colgroup title="<?php echo _('Fuzzy statistics') ?>">
44 <col/><col/><col/>
45 </colgroup>
46 <colgroup title="<?php echo _('Raw statistics') ?>">
47 <col/><col/><col/><col/>
48 </colgroup>
50 <thead>
51 <tr>
52 <td/>
53 <th scope="col"><?php echo _('Today') ?></th>
54 <th scope="col"><?php echo _('This week') ?></th>
55 <th scope="col"><?php echo _('This month') ?></th>
56 <th scope="col"><?php echo _('Last 24 hours') ?></th>
57 <th scope="col"><?php echo _('Last 7 days') ?></th>
58 <th scope="col"><?php echo _('Last 30 days') ?></th>
59 <th scope="col"><?php echo _('Total') ?></th>
60 </tr>
61 </thead>
63 <tbody>
65 <?php echo
66 '<tr class="content c',(++$a&1),'">
67 <th scope="row" title="',_('Count of all messages'),'">',_('Posts'),'</th>
68 ',getrow('SELECT COUNT(*) AS `result` FROM `messages` WHERE `mtime` > %d'),'
69 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `messages`')->fetch_object()->result,'</td>
70 </tr>
72 <tr class="content c',(++$a&1),'">
73 <th scope="row" title="',_('Any post in direct reply to someone else\'s'),'">',_('Replies'),'</th>
74 ',getrow('SELECT COUNT(*) AS `result` FROM `messages` WHERE `replyto` IS NOT NULL AND `mtime` > %d'),'
75 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `messages` WHERE `replyto` IS NOT NULL')->fetch_object()->result,'</td>
76 </tr>
78 <tr class="content c',(++$a&1),'">
79 <th scope="row" title="',_('Count of all topics'),'">',_('Topics'),'</th>
80 ',getrow('SELECT COUNT(DISTINCT(`topicid`)) AS `result` FROM `messages` WHERE `mtime` > %d'),'
81 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `topics`')->fetch_object()->result,'</td>
82 </tr>
84 <tr class="content c',(++$a&1),'">
85 <th scope="row" title="',_('Number of new users in a time period'),'">',_('Users'),'</th>
86 ',getrow('SELECT COUNT(*) AS `result` FROM `users` WHERE `register_date` > %d'),'
87 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users`')->fetch_object()->result,'</td>
88 </tr>
90 <tr class="content c',(++$a&1),'">
91 <th scope="row" title="',_('Users who\'ve logged in within this time'),'">',_('Online Users'),'</th>
92 ',getrow('SELECT COUNT(`userid`) AS `result` FROM `users`
93 WHERE `last_active_date` > `register_date` AND `last_active_date` > %d'),'
94 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users`
95 WHERE `last_active_date` > `register_date`')->fetch_object()->result,'</td>
96 </tr>
98 <tr class="content c',(++$a&1),'">
99 <th scope="row" title="',_('Users who\'ve posted at least once'),'">',_('Active Users'),'</th>
100 ',getrow('SELECT COUNT(DISTINCT(`users`.`userid`)) AS `result` FROM `users` NATURAL LEFT JOIN `messages`
101 WHERE `messages`.`mtime` > %d'),'
102 <td>',$DB->query('SELECT COUNT(DISTINCT(`users`.`userid`)) AS `result`
103 FROM `users` NATURAL LEFT JOIN `messages`')->fetch_object()->result; ?></td>
104 </tr>
105 </tbody>
107 </table>
109 <h2>Stuff</h2>
110 <h3>Terms of Service</h3>
111 <ul>
112 <li>Don't be a fucking idiot.</li>
113 <li>Anyone caught screwing with the registration system is in full violation of the above rule,
114 and will be forcibly kept out of the site. Same goes for persistent invite-beggers.</li>
115 </ul>
117 <?php
118 $page->pagefooter();