-
Notifications
You must be signed in to change notification settings - Fork 0
/
counter_stats.php
234 lines (212 loc) · 7.82 KB
/
counter_stats.php
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
/*
##########################################################################
# #
# Version 4 / / / #
# -----------__---/__---__------__----__---/---/- #
# | /| / /___) / ) (_ ` / ) /___) / / #
# _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___ #
# Free Content / Management System #
# / #
# #
# #
# Copyright 2005-2015 by webspell.org #
# #
# visit webSPELL.org, webspell.info to get webSPELL for free #
# - Script runs under the GNU GENERAL PUBLIC LICENSE #
# - It's NOT allowed to remove this copyright-tag #
# -- http://www.fsf.org/licensing/licenses/gpl.html #
# #
# Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at), #
# Far Development by Development Team - webspell.org #
# #
# visit webspell.org #
# #
##########################################################################
*/
$_language->readModule('counter');
$title_counter_stats = $GLOBALS["_template"]->replaceTemplate("title_counter_stats", array());
echo $title_counter_stats;
$time = time();
$date = getformatdate($time);
$dateyesterday = getformatdate($time - (24 * 3600));
$datemonth = date(".m.Y", time());
$ergebnis = safe_query("SELECT `hits` FROM `" . PREFIX . "counter`");
$ds = mysqli_fetch_array($ergebnis);
$us = mysqli_num_rows(safe_query("SELECT `userID` FROM `" . PREFIX . "user`"));
$total = $ds[ 'hits' ];
$dt = mysqli_fetch_array(safe_query("SELECT `count` FROM `" . PREFIX . "counter_stats` WHERE `dates` = '$date'"));
if ($dt[ 'count' ]) {
$today = $dt[ 'count' ];
} else {
$today = 0;
}
$dy = mysqli_fetch_array(
safe_query(
"SELECT
`count`
FROM
`" . PREFIX . "counter_stats`
WHERE
`dates`='$dateyesterday'"
)
);
if ($dy[ 'count' ]) {
$yesterday = $dy[ 'count' ];
} else {
$yesterday = 0;
}
$month = 0;
$month_max = 0;
$monthquery = safe_query("SELECT `count` FROM `" . PREFIX . "counter_stats` WHERE `dates` LIKE '%$datemonth'");
while ($dm = mysqli_fetch_array($monthquery)) {
$month = $month + $dm[ 'count' ];
if ($dm[ 'count' ] > $month_max) {
$month_max = $dm[ 'count' ];
}
}
if ($month == 0) {
$month = 1;
}
$monatsstat = '';
for ($i = date("d", time()); $i > 0; $i--) {
$day = (mb_strlen($i) < 2) ? "0" . $i : $i;
$tmp = mysqli_fetch_array(
safe_query(
"SELECT
`count`
FROM
`" . PREFIX . "counter_stats`
WHERE
`dates` = '" . $day . $datemonth."'"
)
);
if ($tmp[ 'count' ]) {
$visits = $tmp[ 'count' ];
} else {
$visits = 0;
}
$prozent = $visits * 100 / $month_max;
$monatsstat .= '<li class="list-group-item"><span class="badge">' . $visits . '</span> ' . $day . $datemonth . '<div class="progress"><div class="progress-bar progress-bar-info" style="width: ' . (round($prozent)) . '%"></div></div></li>';
}
$tmp = mysqli_fetch_array(safe_query("SELECT `online` FROM `" . PREFIX . "counter`"));
$days_online = round((time() - $tmp[ 'online' ]) / (3600 * 24));
if (!$days_online) {
$days_online = 1;
}
$perday = round($total / $days_online, 2);
$perhour = round($total / $days_online / 24, 2);
$permonth = round($total / $days_online * 24, 2);
$tmp = mysqli_fetch_array(safe_query("SELECT max(count) as `MAXIMUM` FROM `" . PREFIX . "counter_stats`"));
$maxvisits = $tmp[ 'MAXIMUM' ];
$online_lasthour =
mysqli_num_rows(safe_query("SELECT `ip` FROM `" . PREFIX . "counter_iplist` WHERE `del` > " . (time() - 3600)));
$online = mysqli_num_rows(safe_query("SELECT `time` FROM `" . PREFIX . "whoisonline`"));
$dm = mysqli_fetch_array(safe_query("SELECT `maxonline` FROM `" . PREFIX . "counter`"));
$maxonline = $dm[ 'maxonline' ];
$guests = mysqli_num_rows(safe_query("SELECT `ip` FROM `" . PREFIX . "whoisonline` WHERE `userID` = ''"));
$user = mysqli_num_rows(safe_query("SELECT `userID` FROM `" . PREFIX . "whoisonline` WHERE `ip` = ''"));
$useronline = $guests + $user;
if ($user == 1) {
$user_on = '1 ' . $_language->module[ 'user' ];
} else {
$user_on = $user . ' ' . $_language->module[ 'users' ];
}
if ($guests == 1) {
$guests_on = '1 ' . $_language->module[ 'guest' ];
} else {
$guests_on = $guests . ' ' . $_language->module[ 'guests' ];
}
// average age of all users
$get =
mysqli_fetch_assoc(
safe_query(
"SELECT
ROUND(SUM(DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW()) - TO_DAYS(birthday)), '%y')) / COUNT(userID)) AS
`avg_age`
FROM
" . PREFIX . "user
WHERE
birthday > 0"
)
);
$avg_age_user = $get[ 'avg_age' ];
// average age of clanmembers
$avg_age_member = 0;
$get = safe_query(
"SELECT
SUM(DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW()) - TO_DAYS(u.birthday)), '%y')) / COUNT(u.userID) AS `avg_age`
FROM
" . PREFIX . "squads_members m
JOIN
" . PREFIX . "user u ON
u.userID = m.userID
WHERE
u.birthday > 0
GROUP BY
m.userID"
);
if (mysqli_num_rows($get)) {
while ($ds = mysqli_fetch_assoc($get)) {
$avg_age_member += $ds[ 'avg_age' ];
}
$avg_age_member = ROUND($avg_age_member / mysqli_num_rows($get), 0);
}
// get oldest/youngest member
$get_young = mysqli_fetch_assoc(
safe_query(
"SELECT
DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW()) - TO_DAYS(birthday)), '%y') AS `age`,
`nickname`,
`userID`
FROM
" . PREFIX . "user
WHERE
birthday > 0
ORDER BY
birthday DESC
LIMIT 0,1"
)
);
$get_old = mysqli_fetch_assoc(
safe_query(
"SELECT
DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW()) - TO_DAYS(birthday)), '%y') AS `age`,
nickname,
userID
FROM
" . PREFIX . "user
WHERE
birthday > 0
ORDER BY
birthday ASC
LIMIT 0,1"
)
);
$data_array = array();
$data_array['$today'] = $today;
$data_array['$yesterday'] = $yesterday;
$data_array['$month'] = $month;
$data_array['$total'] = $total;
$data_array['$days_online'] = $days_online;
$data_array['$permonth'] = $permonth;
$data_array['$perday'] = $perday;
$data_array['$perhour'] = $perhour;
$data_array['$maxvisits'] = $maxvisits;
$data_array['$online'] = $online;
$data_array['$user_on'] = $user_on;
$data_array['$guests_on'] = $guests_on;
$data_array['$maxonline'] = $maxonline;
$data_array['$online_lasthour'] = $online_lasthour;
$data_array['$avg_age_user'] = $avg_age_user;
$data_array['$avg_age_member'] = $avg_age_member;
$data_array['$youngest_age'] = $get_young['age'];
$data_array['$youngest_id'] = $get_young['userID'];
$data_array['$youngest_nickname'] = $get_young['nickname'];
$data_array['$oldest_age'] = $get_old['age'];
$data_array['$oldest_id'] = $get_old['userID'];
$data_array['$oldest_nickname'] = $get_old['nickname'];
$data_array['$us'] = $us;
$data_array['$monatsstat'] = $monatsstat;
$stats = $GLOBALS["_template"]->replaceTemplate("counter_stats", $data_array);
echo $stats;