Special Ops 2.50
[specialops2.git] / stuff.php
blob1aa111e4a610b6929f5f6dab5fc62f73d8821bf9
1 <?php
2 /**
3 * Statistics, FAQ & TOS
5 * @author Ant P <p@cpi.merseine.nu>
6 * @license file://COPYING
7 * @version 2.15
8 */
10 require 'con.php';
12 SO2::$Page->title = 'The other stuff';
13 SO2::$Page->pageheader();
15 // Stats columns
16 $date = array (
17 'Today' => mktime(0, 0, 0),
18 'This week' => mktime(0, 0, 0) - date('w')*86400,
19 'This month' => mktime(0, 0, 0, date('m'), 1),
20 'Last 24 hours' => (T_NOW - 86400),
21 'Last 7 days' => (T_NOW - 86400*7),
22 'Last 30 days' => (T_NOW - 86400*30),
23 'Total' => 0
26 // Stats rows
27 $table = array (
28 'All Posts' => 'SELECT COUNT(*) FROM messages WHERE mtime > ?',
29 'Replies' => 'SELECT COUNT(*) FROM messages WHERE replyto IS NOT NULL AND mtime > ?',
30 'Topics' => 'SELECT COUNT(DISTINCT(topicid)) FROM messages WHERE mtime > ?',
31 'Registered Users' => 'SELECT COUNT(*) FROM users WHERE register_date > ?',
32 'Online Users' => 'SELECT COUNT(userid) FROM users WHERE last_active_date > register_date AND last_active_date > ?',
33 'Active Users' => 'SELECT COUNT(DISTINCT(users.userid)) FROM users NATURAL LEFT JOIN messages WHERE messages.mtime > ?'
37 <table id="board_stats">
38 <caption>Board Statistics</caption>
39 <colgroup title="Row headers">
40 <col class="num"/>
41 </colgroup>
42 <colgroup title="Fuzzy statistics">
43 <col class="num"/>
44 <col class="num"/>
45 <col class="num"/>
46 </colgroup>
47 <colgroup title="Raw statistics">
48 <col class="num"/>
49 <col class="num"/>
50 <col class="num"/>
51 <col class="num"/>
52 </colgroup>
53 <thead>
54 <tr>
55 <td/>
56 <?php foreach ( $date as $th => $time ) echo " <th>$th</th>\n"; ?>
57 </tr>
58 </thead>
59 <tbody>
60 <?php
61 $a = 1;
63 foreach ( $table as $rowth => $sql ) {
64 $q = SO2::$DB->prepare($sql);
65 echo ' <tr class="content c',(++$a&1),"\">\n",
66 ' <th scope="row">',$rowth,"</th>\n";
67 foreach ($date as $num) {
68 $q->execute( array($num) );
69 echo
70 ' <td>'.$q->fetchColumn(0)."</td>\n";
72 $q = null;
73 echo " </tr>\n";
76 </tbody>
77 </table>
78 <hr/>
79 <?php readfile('res/faq.xml') ?>
80 <hr/>
81 <?php readfile('res/tos.xml') ?>