Database rewrite, first half
[specialops2.git] / stuff.php
blobe8221d0eeaacde9e8d9bf91d2903150aab2513a4
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 function getrow($sql) { //getlost
24 global $DB, $date;
25 $return = '';
26 foreach ($date as $num)
27 $return .= '<td>'.$DB->query(sprintf($sql, $num))->fetch_object()->result.'</td> ';
29 return $return;
33 <h2>Stats</h2>
35 <table id="board_stats" style="empty-cells: hide">
36 <caption><?php echo _('Board Statistics') ?></caption>
38 <colgroup title="<?php echo _('Row headers') ?>">
39 <col title="<?php echo _('Type of data') ?>"/>
40 </colgroup>
41 <colgroup title="<?php echo _('Fuzzy statistics') ?>">
42 <col/><col/><col/>
43 </colgroup>
44 <colgroup title="<?php echo _('Raw statistics') ?>">
45 <col/><col/><col/><col/>
46 </colgroup>
48 <thead>
49 <tr>
50 <td/>
51 <th scope="col"><?php echo _('Today') ?></th>
52 <th scope="col"><?php echo _('This week') ?></th>
53 <th scope="col"><?php echo _('This month') ?></th>
54 <th scope="col"><?php echo _('Last 24 hours') ?></th>
55 <th scope="col"><?php echo _('Last 7 days') ?></th>
56 <th scope="col"><?php echo _('Last 30 days') ?></th>
57 <th scope="col"><?php echo _('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 `m_time` > %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 `m_replyto` IS NOT NULL AND `m_time` > %d'),'
73 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `messages` WHERE `m_replyto` IS NOT NULL')->fetch_object()->result,'</td>
74 </tr>
76 <tr class="content c',(++$a&1),'">
77 <th scope="row" title="',_('Count of all topics'),'">',_('Topics'),'</th>
78 ',getrow('SELECT COUNT(DISTINCT(`m_topic`)) AS `result` FROM `messages` WHERE `m_time` > %d'),'
79 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `topics`')->fetch_object()->result,'</td>
80 </tr>
82 <tr class="content c',(++$a&1),'">
83 <th scope="row" title="',_('Number of new users in a time period'),'">',_('Users'),'</th>
84 ',getrow('SELECT COUNT(*) AS `result` FROM `users` WHERE `u_firstactive` > %d'),'
85 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users`')->fetch_object()->result,'</td>
86 </tr>
88 <tr class="content c',(++$a&1),'">
89 <th scope="row" title="',_('Users who\'ve logged in within this time'),'">',_('Online Users'),'</th>
90 ',getrow('SELECT COUNT(`userid`) AS `result` FROM `users` WHERE `u_lastactive` > `u_firstactive` AND `u_lastactive` > %d'),'
91 <td>',$DB->query('SELECT COUNT(*) AS `result` FROM `users` WHERE `u_lastactive` > `u_firstactive`')->fetch_object()->result,'</td>
92 </tr>
94 <tr class="content c',(++$a&1),'">
95 <th scope="row" title="',_('Users who\'ve posted at least once'),'">',_('Active Users'),'</th>
96 ',getrow('SELECT COUNT(DISTINCT(`userid`)) AS `result` FROM `users`, `messages`
97 WHERE `messages`.`m_poster` = `users`.`userid` AND `messages`.`m_time` > %d'),'
98 <td>',$DB->query('SELECT COUNT(DISTINCT(`userid`)) AS `result` FROM `users`, `messages`
99 WHERE `messages`.`m_poster` = `users`.`userid`')->fetch_object()->result; ?></td>
100 </tr>
101 </tbody>
103 </table>
105 <h2>Stuff</h2>
106 <h3>Terms of Service</h3>
107 <ul>
108 <li>Don't be a fucking idiot.</li>
109 </ul>
111 <h3>Frequently Asked Questions</h3>
112 <ul>
113 <li>HOW I MINE FOR FISH??????///////////</li>
114 <li>WARE U @???</li>
115 <li>what</li>
116 </ul>
118 <?php
119 $page->pagefooter();