1 |
joku |
63 |
<?php |
2 |
|
|
/* This file is part of BBClone (A PHP based Web Counter on Steroids) |
3 |
|
|
* |
4 |
|
|
* SVN FILE $Id$ |
5 |
|
|
* |
6 |
joku |
312 |
* Copyright (C) 2001-2015, the BBClone Team (see doc/authors.txt for details) |
7 |
joku |
63 |
* |
8 |
|
|
* This program is free software: you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License as published by |
10 |
|
|
* the Free Software Foundation, either version 3 of the License, or |
11 |
|
|
* (at your option) any later version. |
12 |
|
|
* |
13 |
|
|
* This program is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
|
* GNU General Public License for more details. |
17 |
|
|
* |
18 |
|
|
* See doc/copying.txt for details |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
/////////////////////// |
22 |
|
|
// Show Global Stats // |
23 |
|
|
/////////////////////// |
24 |
|
|
|
25 |
matthys |
208 |
if(!defined("_BBC_PAGE_NAME")){define("_BBC_PAGE_NAME", "BBClone - Show Global");} |
26 |
joku |
63 |
|
27 |
|
|
// START Time Measuring, load-time of the page (see config) |
28 |
|
|
$time = microtime(); |
29 |
|
|
$time = explode(' ', $time); |
30 |
|
|
$time = $time[1] + $time[0]; |
31 |
|
|
$start = $time; |
32 |
|
|
|
33 |
|
|
// Read constants |
34 |
|
|
if (is_readable("constants.php")) require_once("constants.php"); |
35 |
|
|
else exit("ERROR: Unable to open constants.php"); |
36 |
|
|
|
37 |
|
|
foreach (array($BBC_CONFIG_FILE, $BBC_LIB_PATH."selectlang.php", $BBC_ACCESS_FILE) as $i) { |
38 |
|
|
if (is_readable($i)) require_once($i); |
39 |
|
|
else exit(bbc_msg($i)); |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
// Functions to calculate Stats |
43 |
|
|
function bbc_histcalc($array) { |
44 |
|
|
$result = 0; |
45 |
|
|
|
46 |
|
|
if (is_array($array)) { |
47 |
|
|
foreach ($array as $val) $result += $val; |
48 |
|
|
} |
49 |
|
|
return $result; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
function bbc_rank_head($cat, $i18n, $flag = 0) { |
53 |
|
|
global $translation; |
54 |
|
|
|
55 |
|
|
return "<table class=\"centerdata\">\n" |
56 |
|
|
."<tr>\n" |
57 |
|
|
."<td colspan=\"".(!empty($flag) ? 3 : 4)."\" class=\"label\">".sprintf($translation[$i18n], $cat)."</td>\n" |
58 |
|
|
."</tr>\n"; |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
function bbc_list_item($icon, $item, $item_score, $total_score) { |
62 |
|
|
global $BBC_IMAGES_PATH; |
63 |
|
|
|
64 |
|
|
return "<tr>\n" |
65 |
|
|
.(!empty($icon) ? "<td align=\"left\"><img src=\"".$BBC_IMAGES_PATH.$icon |
66 |
|
|
."\" class=\"icon\" alt=\"$item\" title=\"$item\" /> </td>\n" : "") |
67 |
|
|
."<td align=\"left\">$item </td>\n" |
68 |
|
|
."<td align=\"right\"> $item_score</td>\n" |
69 |
|
|
."<td align=\"right\"> ".sprintf("%.2f%%", (round(10000 * $item_score / $total_score) / 100))."</td>\n" |
70 |
|
|
."</tr>\n"; |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
function bbc_rank_sum($cat, $flag = 0) { |
74 |
|
|
global $translation; |
75 |
|
|
|
76 |
|
|
return "<tr>\n" |
77 |
|
|
.(!empty($flag) ? "" : "<td> </td>\n") |
78 |
|
|
."<td align=\"left\"><b>".$translation['gstat_total']."</b> </td>\n" |
79 |
|
|
."<td align=\"right\"> <b>$cat</b></td>\n" |
80 |
|
|
."</tr></table>\n"; |
81 |
|
|
} |
82 |
|
|
|
83 |
|
|
function bbc_refgen($ref) { |
84 |
|
|
global $translation; |
85 |
|
|
|
86 |
joku |
243 |
if ($ref == "ignored") return "<i>".$translation['misc_ignored']."</i>"; |
87 |
|
|
if ($ref == "not_specified") return "<i>".$translation['gstat_not_specified']."</i>"; |
88 |
|
|
|
89 |
joku |
63 |
$ref_name = (($slash = strpos($ref, "/")) !== false) ? substr($ref, 0, $slash) : $ref; |
90 |
|
|
|
91 |
|
|
return "<script type=\"text/javascript\">\n" |
92 |
|
|
."<!--\n" |
93 |
|
|
."document.write('<a href=\"http://$ref\" rel=\"nofollow\" title=\"$ref_name\">$ref_name<\/a>');\n" |
94 |
|
|
."-->\n" |
95 |
|
|
."</script>\n" |
96 |
|
|
."<noscript><span title=\"$ref_name\">$ref_name</span></noscript>\n"; |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
function bbc_sort_page_count($page_a, $page_b) { |
100 |
|
|
if ($page_a['count'] === $page_b['count']) return 0; |
101 |
|
|
return (($page_a['count'] > $page_b['count']) ? -1 : 1); |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
// Main functions to generate Stats |
105 |
|
|
function bbc_show_browser() { |
106 |
|
|
global $BBC_IMAGES_PATH, $BBC_LIB_PATH, $BBC_MAXBROWSER, $translation, $access; |
107 |
|
|
|
108 |
|
|
if (is_readable($BBC_LIB_PATH."browser.php")) require($BBC_LIB_PATH."browser.php"); |
109 |
|
|
else return bbc_msg($BBC_LIB_PATH."browser.php"); |
110 |
|
|
|
111 |
|
|
$browser_tab = isset($access['stat']['browser']) ? $access['stat']['browser'] : array(); |
112 |
|
|
|
113 |
|
|
for ($browser_total = 0; list(, $browser_score) = each($browser_tab); $browser_total += $browser_score); |
114 |
|
|
|
115 |
|
|
arsort($browser_tab); |
116 |
|
|
reset($browser_tab); |
117 |
|
|
|
118 |
|
|
$str = bbc_rank_head($BBC_MAXBROWSER, "gstat_browsers"); |
119 |
|
|
|
120 |
|
|
for ($k = 0; (list($browser_type, $browser_score) = each($browser_tab)) && ($k < $BBC_MAXBROWSER); $k++) { |
121 |
|
|
if (!isset($browser[$browser_type])) { |
122 |
|
|
$str.= bbc_list_item("browser/question.png", $browser_type, $browser_score, $browser_total, 'browser'); |
123 |
|
|
continue; |
124 |
|
|
} |
125 |
|
|
|
126 |
|
|
$browser[$browser_type]['title'] = str_replace("other", $translation['misc_other'], $browser[$browser_type]['title']); |
127 |
|
|
|
128 |
|
|
$str.= bbc_list_item("browser/".$browser[$browser_type]['icon'].".png", $browser[$browser_type]['title'], |
129 |
|
|
$browser_score, $browser_total, 'browser'); |
130 |
|
|
} |
131 |
|
|
|
132 |
|
|
$str .= bbc_rank_sum($browser_total); |
133 |
|
|
return $str; |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
function bbc_show_os() { |
137 |
|
|
global $BBC_IMAGES_PATH, $BBC_LIB_PATH, $BBC_MAXOS, $translation, $access; |
138 |
|
|
|
139 |
|
|
if (is_readable($BBC_LIB_PATH."os.php")) require($BBC_LIB_PATH."os.php"); |
140 |
|
|
else return bbc_msg($BBC_LIB_PATH."os.php"); |
141 |
|
|
|
142 |
|
|
$os_tab = isset($access['stat']['os']) ? $access['stat']['os'] : array(); |
143 |
|
|
|
144 |
|
|
for ($os_total = 0; list(, $os_score) = each($os_tab); $os_total += $os_score); |
145 |
|
|
|
146 |
|
|
arsort($os_tab); |
147 |
|
|
reset($os_tab); |
148 |
|
|
|
149 |
|
|
$str = bbc_rank_head($BBC_MAXOS, "gstat_operating_systems"); |
150 |
|
|
|
151 |
|
|
for ($k = 0; (list($os_type, $os_score) = each($os_tab)) && ($k < $BBC_MAXOS); $k++) { |
152 |
|
|
if (!isset($os[$os_type])) { |
153 |
|
|
$str.= bbc_list_item("os/question.png", $os_type, $os_score, $os_total, 'os'); |
154 |
|
|
continue; |
155 |
|
|
} |
156 |
|
|
|
157 |
|
|
$os[$os_type]['title'] = str_replace("other", $translation['misc_other'], $os[$os_type]['title']); |
158 |
|
|
|
159 |
|
|
$str .= bbc_list_item("os/".$os[$os_type]['icon'].".png", $os[$os_type]['title'], $os_score, $os_total, 'os'); |
160 |
|
|
} |
161 |
|
|
|
162 |
|
|
$str .= bbc_rank_sum($os_total); |
163 |
|
|
return $str; |
164 |
|
|
} |
165 |
|
|
|
166 |
|
|
function bbc_show_extension() { |
167 |
|
|
global $access, $BBC_IMAGES_PATH, $BBC_MAXEXTENSION, $extensions, $translation; |
168 |
|
|
|
169 |
|
|
$ext_tab = isset($access['stat']['ext']) ? $access['stat']['ext'] : array(); |
170 |
|
|
|
171 |
|
|
for ($ext_total = 0; list(, $ext_score) = each($ext_tab); $ext_total += $ext_score); |
172 |
|
|
|
173 |
|
|
arsort($ext_tab); |
174 |
|
|
reset($ext_tab); |
175 |
|
|
|
176 |
|
|
$str = bbc_rank_head($BBC_MAXEXTENSION, "gstat_extensions"); |
177 |
|
|
|
178 |
|
|
for ($k = 0; (list($ext, $ext_score) = each($ext_tab)) && ($k < $BBC_MAXEXTENSION); $k++) { |
179 |
|
|
if (isset($extensions[$ext])) $label = $extensions[$ext]; |
180 |
|
|
else $label = $ext; |
181 |
|
|
$str .= bbc_list_item("ext/".$ext.".png", $label, $ext_score, $ext_total, 'ext'); |
182 |
|
|
} |
183 |
|
|
|
184 |
|
|
$str .= bbc_rank_sum($ext_total); |
185 |
|
|
return $str; |
186 |
|
|
} |
187 |
|
|
|
188 |
|
|
function bbc_show_robot() { |
189 |
|
|
global $access, $BBC_IMAGES_PATH, $BBC_LIB_PATH, $BBC_MAXROBOT, $translation; |
190 |
|
|
|
191 |
|
|
if (is_readable($BBC_LIB_PATH."robot.php")) require($BBC_LIB_PATH."robot.php"); |
192 |
|
|
else return bbc_msg($BBC_LIB_PATH."robot.php"); |
193 |
|
|
|
194 |
|
|
$robot_tab = isset($access['stat']['robot']) ? $access['stat']['robot'] : array(); |
195 |
|
|
|
196 |
|
|
for ($robot_total = 0; list(,$robot_score) = each($robot_tab); $robot_total += $robot_score); |
197 |
|
|
|
198 |
|
|
arsort($robot_tab); |
199 |
|
|
reset($robot_tab); |
200 |
|
|
|
201 |
|
|
$str = bbc_rank_head($BBC_MAXROBOT, "gstat_robots"); |
202 |
|
|
|
203 |
|
|
for ($k = 0; (list($robot_type, $robot_score) = each($robot_tab)) && ($k < $BBC_MAXROBOT); $k++) { |
204 |
|
|
if (!isset($robot[$robot_type])) { |
205 |
|
|
$str.= bbc_list_item("robot/robot.png", $robot_type, $robot_score, $robot_total, 'robot'); |
206 |
|
|
continue; |
207 |
|
|
} |
208 |
|
|
|
209 |
|
|
$str .= bbc_list_item("robot/".$robot[$robot_type]['icon'].".png", $robot[$robot_type]['title'], $robot_score, $robot_total, 'robot'); |
210 |
|
|
} |
211 |
|
|
|
212 |
|
|
$str .= bbc_rank_sum($robot_total); |
213 |
|
|
return $str; |
214 |
|
|
} |
215 |
|
|
|
216 |
|
|
function bbc_show_top_hosts() { |
217 |
|
|
global $access, $BBC_MAXHOST; |
218 |
|
|
|
219 |
|
|
$host_tab = isset($access['host']) ? $access['host'] : array(); |
220 |
|
|
|
221 |
|
|
for ($host_total = 0; list(, $host_score) = each($host_tab); $host_total += $host_score); |
222 |
|
|
|
223 |
|
|
arsort($host_tab); |
224 |
|
|
reset($host_tab); |
225 |
|
|
|
226 |
|
|
$str = bbc_rank_head($BBC_MAXHOST, "gstat_hosts", 1); |
227 |
|
|
|
228 |
|
|
for ($k = 0; ($k < $BBC_MAXHOST) && (list($host_name, $host_score) = each($host_tab)); $k++) { |
229 |
|
|
$str .= bbc_list_item("", $host_name, $host_score, $host_total, 'hosts'); |
230 |
|
|
} |
231 |
|
|
|
232 |
|
|
$str .= bbc_rank_sum($host_total, 1); |
233 |
|
|
return $str; |
234 |
|
|
} |
235 |
|
|
|
236 |
|
|
function bbc_show_top_pages() { |
237 |
|
|
global $BBC_MAXPAGE, $translation, $access; |
238 |
|
|
|
239 |
|
|
$page_tab = isset($access['page']) ? $access['page'] : array(); |
240 |
|
|
|
241 |
|
|
for ($page_total = 0; list(, $page_elem) = each($page_tab); $page_total += $page_elem['count']); |
242 |
|
|
|
243 |
|
|
uasort($page_tab, "bbc_sort_page_count"); |
244 |
|
|
reset($page_tab); |
245 |
|
|
|
246 |
|
|
$str = bbc_rank_head($BBC_MAXPAGE, "gstat_pages", 1); |
247 |
|
|
|
248 |
|
|
for ($k = 0; (list($page_name, $page_elem) = each($page_tab)) && ($k < $BBC_MAXPAGE); $k++) { |
249 |
|
|
$page_name = ($page_name == "index") ? $translation['navbar_main_site'] : $page_name; |
250 |
|
|
|
251 |
|
|
$str .= bbc_list_item("", "<a href=\"".$page_elem['uri']."\">$page_name</a>", $page_elem['count'], $page_total, 'pages'); |
252 |
|
|
} |
253 |
|
|
|
254 |
|
|
$str .= bbc_rank_sum($page_total, 1); |
255 |
|
|
return $str; |
256 |
|
|
} |
257 |
|
|
|
258 |
|
|
function bbc_show_top_origins() { |
259 |
|
|
global $BBC_MAXORIGIN, $translation, $access; |
260 |
|
|
|
261 |
|
|
$referer_tab = isset($access['referer']) ? $access['referer'] : array(); |
262 |
|
|
|
263 |
|
|
for ($referer_total = 0; list(, $referer_score) = each($referer_tab); $referer_total += $referer_score); |
264 |
|
|
|
265 |
|
|
arsort($referer_tab); |
266 |
|
|
reset($referer_tab); |
267 |
|
|
|
268 |
|
|
$str = bbc_rank_head($BBC_MAXORIGIN, "gstat_origins", 1); |
269 |
|
|
|
270 |
|
|
for ($k = 0; ($k < $BBC_MAXORIGIN) && (list($referer_name, $referer_score) = each($referer_tab)); $k++) { |
271 |
|
|
$str .= bbc_list_item("", bbc_refgen($referer_name), $referer_score, $referer_total, 'origins'); |
272 |
|
|
} |
273 |
|
|
|
274 |
|
|
$str .= bbc_rank_sum($referer_total, 1); |
275 |
|
|
return $str; |
276 |
|
|
} |
277 |
|
|
|
278 |
|
|
function bbc_show_top_keys() { |
279 |
|
|
global $BBC_MAXKEY, $translation, $access; |
280 |
|
|
|
281 |
|
|
$key_tab = isset($access['key']) ? $access['key'] : array(); |
282 |
|
|
|
283 |
|
|
for ($key_total = 0; list(, $key_score) = each($key_tab); $key_total += $key_score); |
284 |
|
|
|
285 |
|
|
arsort($key_tab); |
286 |
|
|
reset($key_tab); |
287 |
|
|
|
288 |
|
|
$str = bbc_rank_head($BBC_MAXKEY, "gstat_keys", 1); |
289 |
|
|
|
290 |
|
|
for ($k = 0; ($k < $BBC_MAXKEY) && (list($key_name, $key_score) = each($key_tab)); $k++) { |
291 |
|
|
$str .= bbc_list_item("", $key_name, $key_score, $key_total, 'keys'); |
292 |
|
|
} |
293 |
|
|
|
294 |
|
|
$str .= bbc_rank_sum($key_total, 1); |
295 |
|
|
return $str; |
296 |
|
|
} |
297 |
|
|
|
298 |
|
|
function bbc_show_access() { |
299 |
|
|
global $translation, $access; |
300 |
|
|
|
301 |
|
|
return "<table class=\"center\">\n" |
302 |
|
|
."<tr>\n" |
303 |
|
|
."<td colspan=\"11\" class=\"label\">".$translation['gstat_accesses']."</td></tr>\n" |
304 |
|
|
."<tr>\n" |
305 |
|
|
."<td align=\"left\">".$translation['tstat_last_year']." </td>\n" |
306 |
|
|
."<td align=\"right\">".(!empty($access['time']['month']) ? bbc_histcalc($access['time']['month']) : "0") |
307 |
|
|
."</td>\n" |
308 |
|
|
."<td>".str_repeat(" ", 6)."</td>\n" |
309 |
|
|
."<td align=\"left\">".$translation['tstat_last_month']." </td>\n" |
310 |
|
|
."<td align=\"right\">".((!empty($access['time']['month'])) ? bbc_histcalc($access['time']['day']) : "0") |
311 |
|
|
."</td>\n" |
312 |
|
|
."<td>".str_repeat(" ", 6)."</td>\n" |
313 |
|
|
."<td align=\"left\">".$translation['tstat_last_week']." </td>\n" |
314 |
|
|
."<td align=\"right\">".(!empty($access['time']['wday']) ? bbc_histcalc($access['time']['wday']) : "0") |
315 |
|
|
."</td>\n" |
316 |
|
|
."<td>".str_repeat(" ", 6)."</td>\n" |
317 |
|
|
."<td align=\"left\">".$translation['tstat_last_day']." </td>\n" |
318 |
|
|
."<td align=\"right\">".(!empty($access['time']['wday']) ? bbc_histcalc($access['time']['hour']) : "0") |
319 |
|
|
."</td></tr>\n" |
320 |
|
|
."<tr>\n" |
321 |
|
|
."<td colspan=\"3\"> </td>\n" |
322 |
|
|
."<td align=\"left\"><b>".$translation['gstat_total_visits']."</b> "."</td>\n" |
323 |
|
|
."<td align=\"right\">" |
324 |
|
|
."<b>".(!empty($access['stat']['totalvisits']) ? $access['stat']['totalvisits'] : "0")."</b>" |
325 |
|
|
."</td>\n" |
326 |
|
|
."<td>".str_repeat(" ", 6)."</td>\n" |
327 |
|
|
."<td align=\"left\"><b>".$translation['gstat_total_unique']."</b> </td>\n" |
328 |
|
|
."<td align=\"right\">" |
329 |
|
|
."<b>".(!empty($access['stat']['totalcount']) ? $access['stat']['totalcount'] : "0")."</b>" |
330 |
|
|
."</td>\n" |
331 |
|
|
."<td colspan=\"3\"> </td>\n" |
332 |
|
|
."</tr></table>\n"; |
333 |
|
|
} |
334 |
|
|
|
335 |
|
|
// Generate page (with use of the functions above) |
336 |
|
|
echo $BBC_HTML->html_begin() |
337 |
|
|
.$BBC_HTML->topbar() |
338 |
|
|
// .$BBC_HTML->last_reset() |
339 |
|
|
."<table class=\"center\">\n" |
340 |
|
|
."<tr><td class=\"padding\">\n" |
341 |
|
|
."<table class=\"centerbox\">\n" |
342 |
|
|
."<tr>\n" |
343 |
|
|
."<td class=\"padding top\">\n" |
344 |
|
|
.bbc_show_browser() |
345 |
|
|
."</td>\n" |
346 |
|
|
."<td class=\"padding top\">\n" |
347 |
|
|
.bbc_show_os() |
348 |
|
|
."</td>\n" |
349 |
|
|
."<td class=\"padding top\">\n" |
350 |
|
|
.bbc_show_extension() |
351 |
|
|
."</td>\n"; |
352 |
|
|
|
353 |
|
|
if (!empty($BBC_IGNORE_BOTS) && ($BBC_IGNORE_BOTS == 2)) { |
354 |
|
|
echo "</tr></table>\n" |
355 |
|
|
."</td>\n"; |
356 |
|
|
} |
357 |
|
|
else { |
358 |
|
|
echo "<td class=\"padding top\">\n" |
359 |
|
|
.bbc_show_robot() |
360 |
|
|
."</td></tr></table>\n" |
361 |
|
|
."</td>\n"; |
362 |
|
|
} |
363 |
|
|
|
364 |
|
|
echo "</tr>\n" |
365 |
|
|
."<tr>\n" |
366 |
|
|
."<td class=\"padding\">\n" |
367 |
|
|
."<table class=\"centerbox\">\n" |
368 |
|
|
."<tr>\n" |
369 |
|
|
."<td class=\"padding top\">\n" |
370 |
|
|
.bbc_show_top_hosts() |
371 |
|
|
."</td>\n" |
372 |
|
|
."<td class=\"padding top\">\n" |
373 |
|
|
.bbc_show_top_pages() |
374 |
|
|
."</td>\n" |
375 |
|
|
."<td class=\"padding top\">\n" |
376 |
|
|
.bbc_show_top_origins() |
377 |
|
|
."</td>\n" |
378 |
|
|
."<td class=\"padding top\">\n" |
379 |
|
|
.bbc_show_top_keys() |
380 |
|
|
."</td></tr></table>\n" |
381 |
|
|
."</td></tr>\n" |
382 |
|
|
."<tr>\n" |
383 |
|
|
."<td class=\"padding\">\n" |
384 |
|
|
."<table class=\"centerbox\">\n" |
385 |
|
|
."<tr>\n" |
386 |
|
|
."<td class=\"padding\">\n" |
387 |
|
|
.bbc_show_access() |
388 |
|
|
."</td></tr></table>\n" |
389 |
|
|
."</td></tr></table>\n" |
390 |
|
|
.$BBC_HTML->copyright() |
391 |
|
|
.$BBC_HTML->topbar(0, 1); |
392 |
|
|
|
393 |
|
|
// END + DISPLAY Time Measuring, load-time of the page (see config) |
394 |
|
|
global $BBC_LOADTIME; |
395 |
|
|
|
396 |
|
|
if (!empty($BBC_LOADTIME)) { |
397 |
|
|
$time = microtime(); |
398 |
|
|
$time = explode(' ', $time); |
399 |
|
|
$time = $time[1] + $time[0]; |
400 |
|
|
$finish = $time; |
401 |
|
|
$total_time = round(($finish - $start), 4); |
402 |
|
|
echo "<div class=\"loadtime\">".$translation['generated'].$total_time.$translation['seconds']."</div>\n"; |
403 |
|
|
} |
404 |
|
|
|
405 |
|
|
// End of HTML |
406 |
|
|
echo $BBC_HTML->html_end() |
407 |
joku |
243 |
?> |