-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatistics.php
More file actions
157 lines (118 loc) · 4.93 KB
/
statistics.php
File metadata and controls
157 lines (118 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
/*
Copyright (C) 2008-2009 Gilles Dubuc (www.kouiskas.com - gilles@dubuc.fr)
General statistics about the website
*/
require_once(dirname(__FILE__).'/entities/competitionlist.php');
require_once(dirname(__FILE__).'/entities/user.php');
require_once(dirname(__FILE__).'/entities/userlevellist.php');
require_once(dirname(__FILE__).'/entities/userlist.php');
require_once(dirname(__FILE__).'/utilities/cache.php');
require_once(dirname(__FILE__).'/utilities/page.php');
require_once(dirname(__FILE__).'/constants.php');
require_once(dirname(__FILE__).'/settings.php');
require_once(dirname(__FILE__).'/libraries/open_flash_chart_object.php');
$user = User::getSessionUser();
$levels = UserLevelList::getByUid($user->getUid());
if (!in_array($USER_LEVEL['ADMINISTRATOR'], $levels)) {
header('Location: '.$PAGE['404']);
exit(0);
}
$page = new Page('STATISTICS', 'HOME', $user);
$page->startHTML();
$competitionlist = CompetitionList::getByStatus($COMPETITION_STATUS['CLOSED']);
$competitionentrycount = array();
arsort($competitionlist);
$competitionlist = array_slice($competitionlist, 0, 300, true);
foreach ($competitionlist as $cid => $start_time) {
$competitionentrycount[$cid] = count(EntryList::getByCid($cid));
}
echo 'Average entries per competition = '.(array_sum($competitionentrycount) / count($competitionentrycount));
$users = UserList::getByStatus($USER_STATUS['ACTIVE']);
$recent_users = UserList::getRegistered24Hours();
echo '<div class="hint hintmargin">';
echo '<div class="hint_title">';
echo '<translate id="STATISTICS_USERS">';
echo 'Users statistics';
echo '</translate>';
echo '</div> <!-- hint_title -->';
echo '</div> <!-- hint -->';
echo '<div>';
echo '<translate id="STATISTICS_TOTAL_REGISTERED">';
echo 'There are <integer value="'.count($users).'"/> registered users (<integer value="'.count($recent_users).'"/> in the last 24 hours)';
echo '</translate>';
echo '</div>';
unset($users);
unset($recent_users);
$active_users_30_days = UserList::getActive30Days();
$users = User::getArray(array_keys($active_users_30_days));
$points = array();
$morethanx = 0;
foreach ($users as $uid => $user) {
$points[$uid] = $user->getPoints();
if ($points[$uid] > 100) $morethanx++;
}
echo 'Average points per user = '.(array_sum($points)/count($points)).' '.((100 *$morethanx)/count($points)).'% have more than 100';
echo '<div>';
echo '<translate id="STATISTICS_ACTIVE_30_DAYS">';
echo '<integer value="'.count($active_users_30_days).'"/> monthly active users (used the website over the last 30 days)';
echo '</translate>';
echo '</div>';
unset($active_users_30_days);
$active_users_24_hours = UserList::getActive24Hours();
echo '<div class="hintmargin">';
echo '<translate id="STATISTICS_ACTIVE_24_HOURS">';
echo '<integer value="'.count($active_users_24_hours).'"/> daily active users (used the website over the last 24 hours)';
echo '</translate>';
echo '</div>';
echo '<div class="hint hintmargin">';
echo '<div class="hint_title">';
echo 'Active members';
echo '</div> <!-- hint_title -->';
echo '</div> <!-- hint -->';
echo '<div class="statistic_chart">';
open_flash_chart_object(930, 250, $REQUEST['STATISTIC_DATA'].'?sid='.$STATISTIC['ACTIVE_MEMBERS'], false);
echo '</div> <!-- statistic_chart -->';
echo '<div class="hint hintmargin">';
echo '<div class="hint_title">';
echo 'Registrations';
echo '</div> <!-- hint_title -->';
echo '</div> <!-- hint -->';
echo '<div class="statistic_chart">';
open_flash_chart_object(930, 250, $REQUEST['STATISTIC_DATA'].'?sid='.$STATISTIC['REGISTRATIONS'], false);
echo '</div> <!-- statistic_chart -->';
echo '<div class="hint hintmargin">';
echo '<div class="hint_title">';
echo 'Entries uploaded';
echo '</div> <!-- hint_title -->';
echo '</div> <!-- hint -->';
echo '<div class="statistic_chart">';
open_flash_chart_object(930, 250, $REQUEST['STATISTIC_DATA'].'?sid='.$STATISTIC['ENTRIES'], false);
echo '</div> <!-- statistic_chart -->';
echo '<div class="hint hintmargin">';
echo '<div class="hint_title">';
echo 'Votes cast';
echo '</div> <!-- hint_title -->';
echo '</div> <!-- hint -->';
echo '<div class="statistic_chart">';
open_flash_chart_object(930, 250, $REQUEST['STATISTIC_DATA'].'?sid='.$STATISTIC['VOTES'], false);
echo '</div> <!-- statistic_chart -->';
echo '<div class="hint hintmargin">';
echo '<div class="hint_title">';
echo 'Comments word count';
echo '</div> <!-- hint_title -->';
echo '</div> <!-- hint -->';
echo '<div class="statistic_chart">';
open_flash_chart_object(930, 250, $REQUEST['STATISTIC_DATA'].'?sid='.$STATISTIC['COMMENTS_WORDCOUNT'], false);
echo '</div> <!-- statistic_chart -->';
echo '<div class="hint hintmargin">';
echo '<div class="hint_title">';
echo 'Average comment word count per entry';
echo '</div> <!-- hint_title -->';
echo '</div> <!-- hint -->';
echo '<div class="statistic_chart">';
open_flash_chart_object(930, 250, $REQUEST['STATISTIC_DATA'].'?sid='.$STATISTIC['COMMENTS_ENTRIES_RATIO'], false);
echo '</div> <!-- statistic_chart -->';
$page->endHTML();
$page->render();
?>