Initial commit.
[atbbs.git] / statistics.php
blobe984f7c79a7a6ac4ae62f371e6bbf5d639a2677f
1 <?php
3 require('includes/header.php');
4 force_id();
5 update_activity('statistics');
6 $page_title = 'Statistics';
8 $statistics = array();
10 $query = 'SELECT count(*) FROM topics;';
11 $query .= 'SELECT count(*) FROM replies;';
12 $query .= 'SELECT count(*) FROM uid_bans;';
13 $query .= "SELECT count(*) FROM topics WHERE author = '" . $link->real_escape_string($_SESSION['UID']) . "';";
14 $query .= "SELECT count(*) FROM replies WHERE author = '" . $link->real_escape_string($_SESSION['UID']) . "';";
15 $query .= 'SELECT count(*) FROM ip_bans;';
17 $link->multi_query($query);
18 do {
19 $result = $link->store_result();
20 while ($row = $result->fetch_row())
22 $statistics[] = $row[0];
24 $result->free();
25 } while ($link->next_result());
27 $num_topics = $statistics[0];
28 $num_replies = $statistics[1];
29 $replies_per_topic = round($num_replies / $num_topics);
30 $num_bans = $statistics[2];
31 $your_topics = $statistics[3];
32 $your_replies = $statistics[4];
33 $your_posts = $your_topics + $your_replies;
34 $num_ip_bans = $statistics[5];
36 $total_posts = $num_topics + $num_replies;
37 $days_since_start = floor(( $_SERVER['REQUEST_TIME'] - SITE_FOUNDED ) / 86400);
38 $posts_per_day = round($total_posts / $days_since_start);
39 $topics_per_day = round($num_topics / $days_since_start);
40 $replies_per_day = round($num_replies / $days_since_start);
44 <table>
45 <tr>
46 <th></th>
47 <th class="minimal">Amount</th>
48 <th>Comment</th>
49 </tr>
51 <tr class="odd">
52 <th class="minimal">Total existing posts</th>
53 <td class="minimal"><?php echo format_number($total_posts) ?></td>
54 <td>-</td>
55 </tr>
57 <tr>
58 <th class="minimal">Existing topics</th>
59 <td class="minimal"><?php echo format_number($num_topics) ?></td>
60 <td>-</td>
61 </tr>
63 <tr class="odd">
64 <th class="minimal">Existing replies</th>
65 <td class="minimal"><?php echo format_number($num_replies) ?></td>
66 <td>That's ~<?php echo $replies_per_topic ?> replies/topic.</td>
67 </tr>
69 <tr>
70 <th class="minimal">Posts/day</th>
71 <td class="minimal">~<?php echo format_number($posts_per_day) ?></td>
72 <td>-</td>
73 </tr>
75 <tr class="odd">
76 <th class="minimal">Topics/day</th>
77 <td class="minimal">~<?php echo format_number($topics_per_day) ?></td>
78 <td>-</td>
79 </tr>
81 <tr>
82 <th class="minimal">Replies/day</th>
83 <td class="minimal">~<?php echo format_number($replies_per_day) ?></td>
84 <td>-</td>
85 </tr>
87 <tr class="odd">
88 <th class="minimal">Temporarily banned IDs</th>
89 <td class="minimal"><?php echo format_number($num_bans) ?></td>
90 <td>-</td>
91 </tr>
93 <tr>
94 <th class="minimal">Banned IP addresses</th>
95 <td class="minimal"><?php echo format_number($num_ip_bans) ?></td>
96 <td>-</td>
97 </tr>
99 <tr class="odd">
100 <th class="minimal">Days since launch</th>
101 <td class="minimal"><?php echo number_format($days_since_start) ?></td>
102 <td>Went live on <?php echo date('Y-m-d', SITE_FOUNDED) . ', ' . calculate_age(SITE_FOUNDED) ?> ago.</td>
103 </tr>
104 </table>
106 <table>
107 <tr>
108 <th></th>
109 <th>Amount</th>
110 </tr>
112 <tr class="odd">
113 <th class="minimal">Total posts by you</th>
114 <td><?php echo format_number($your_posts) ?></td>
115 </tr>
117 <tr>
118 <th class="minimal">Topics started by you</th>
119 <td><?php echo format_number($your_topics) ?></td>
120 </tr>
122 <tr class="odd">
123 <th class="minimal">Replies by you</th>
124 <td><?php echo format_number($your_replies) ?></td>
125 </tr>
126 </table>
128 <?php
130 require('includes/footer.php');