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 |
394 |
* Copyright (C) 2001-2021, 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 Views Stats // |
23 |
|
|
////////////////////// |
24 |
|
|
|
25 |
matthys |
208 |
if(!defined("_BBC_PAGE_NAME")){define("_BBC_PAGE_NAME", "BBClone - Show Views");} |
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_LAST_FILE) as $i) { |
38 |
|
|
if (is_readable($i)) require_once($i); |
39 |
|
|
else exit(bbc_msg($i)); |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
function bbc_visit_time($this_time, $next_time, $nr = 0) { |
43 |
|
|
$diff = ($next_time !== false) ? ($next_time - $this_time) : 0; |
44 |
|
|
|
45 |
|
|
if ($diff < 1) return false; |
46 |
|
|
elseif ($diff >= 3600) { |
47 |
|
|
$h = floor($diff / 3600); |
48 |
|
|
$m = floor((($mod = $diff % 3600) / 60)); |
49 |
|
|
$s = $mod % 60; |
50 |
|
|
|
51 |
|
|
return "$h h ".(($m < 10) ? "0".$m : $m)." m ".(($s < 10) ? "0".$s : $s)." s "; |
52 |
|
|
} |
53 |
|
|
elseif (($diff > 60) && ($diff < 3600)) { |
54 |
|
|
return ((($rnd = floor(($diff / 60))) < 10) ? "0".$rnd : $rnd)." m ".((($mod = $diff % 60) < 10) ? |
55 |
|
|
"0".$mod : $mod)." s"; |
56 |
|
|
} |
57 |
|
|
else return (($diff < 10) ? "0".$diff : $diff)." s"; |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
function bbc_list_visits() { |
61 |
|
|
global $BBC_MAXVISIBLE, $BBC_HTML, $translation, $last; |
62 |
|
|
if (_BBC_PHP < 410) global $HTTP_GET_VARS; |
63 |
|
|
|
64 |
|
|
$fields_title = array( |
65 |
|
|
"id" => $translation['dstat_id'], |
66 |
|
|
"prx_ip" => $translation['dstat_prx'], |
67 |
|
|
"ip" => $translation['dstat_ip'], |
68 |
|
|
"user_agent" => $translation['dstat_user_agent'], |
69 |
|
|
"nr" => $translation['dstat_nr'], |
70 |
|
|
"pages" => $translation['dstat_pages'], |
71 |
|
|
"visit_length" => $translation['dstat_visit_length'], |
72 |
|
|
"reloads" => $translation['dstat_reloads'], |
73 |
|
|
); |
74 |
|
|
|
75 |
|
|
$str = "<tr>\n"; |
76 |
|
|
|
77 |
|
|
foreach (array_keys($fields_title) as $val) $str .= "<td class=\"label\">".$fields_title[$val]."</td>\n"; |
78 |
|
|
|
79 |
|
|
$str .= "</tr>\n"; |
80 |
|
|
|
81 |
|
|
|
82 |
|
|
$is_id = 0; |
83 |
|
|
|
84 |
|
|
if (((_BBC_PHP < 410) ? !isset($HTTP_GET_VARS['id']) : !isset($_GET['id'])) || |
85 |
|
|
!preg_match(":^[\d]+$:", ((_BBC_PHP < 410) ? $HTTP_GET_VARS['id'] : $_GET['id'])) || |
86 |
|
|
!is_array($last['traffic']) || empty($last['traffic'])) { |
87 |
|
|
return $translation['dstat_no_data']."."; |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
reset($last['traffic']); |
91 |
|
|
|
92 |
|
|
// Search for traffic row with selected id, result in $connect |
93 |
|
|
while (list(, $connect) = each($last['traffic'])) { |
94 |
|
|
if ((isset($connect['id'])) && ($connect['id'] == ((_BBC_PHP < 410) ? $HTTP_GET_VARS['id'] : $_GET['id']))) { |
95 |
|
|
$is_id = 1; |
96 |
|
|
break; |
97 |
|
|
} |
98 |
|
|
} |
99 |
|
|
if (!$is_id) { |
100 |
|
|
$str .= "<tr><td colspan=8>" . $translation['dstat_no_data'].".</td></tr>"; |
101 |
|
|
return $str; |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
$prx_ip = (($connect['prx_ip'] == "unknown") || ($connect['prx_ip'] == $connect['ip'])) ? $translation['global_no'] : $connect['prx_ip']; |
105 |
|
|
$previous_visit_count = $connect['visits'] - ($BBC_MAXVISIBLE + (isset($connect['off']) ? $connect['off'] : 0)); |
106 |
|
|
|
107 |
|
|
$viewcount = count($connect['views']); |
108 |
|
|
|
109 |
|
|
$style_class = $BBC_HTML->connect_color_class($connect); |
110 |
|
|
|
111 |
|
|
$str .= "<tr class=\"$style_class\">\n"; |
112 |
|
|
$str .= "<td class=\"cell valigntop\" align=\"center\" rowspan=\"$viewcount\">".$connect['id']."</td>\n" |
113 |
|
|
."<td class=\"cell valigntop\" align=\"center\" rowspan=\"$viewcount\">".$prx_ip."</td>\n" |
114 |
|
|
."<td class=\"cell valigntop\" align=\"center\" rowspan=\"$viewcount\">".$connect['ip']."</td>\n" |
115 |
|
|
."<td class=\"cell valigntop\" align=\"left\" rowspan=\"$viewcount\"> " |
116 |
|
|
.(($connect['agent'] == "unknown") ? $translation['unknown'] : $connect['agent'])."</td>\n"; |
117 |
|
|
|
118 |
|
|
for ($i = 0; $i < $viewcount; $i++) { |
119 |
|
|
if ($i != 0) { |
120 |
|
|
$str .= "<tr class=\"$style_class\">"; |
121 |
|
|
} |
122 |
|
|
|
123 |
|
|
$page = substr($connect['views'][$i], (strpos($connect['views'][$i], "|") + 1)); |
124 |
|
|
$page = substr($page, 0, strpos($page, "|")); |
125 |
|
|
$page = ($last['pages'][$page] == "index") ? $translation['navbar_main_site'] : $last['pages'][$page]; |
126 |
|
|
$reload = substr($connect['views'][$i], (strrpos($connect['views'][$i], "|") + 1)) - 1; |
127 |
|
|
$this_time = substr($connect['views'][$i], 0, strpos($connect['views'][$i], "|")); |
128 |
|
|
$next_time = !isset($connect['views'][($i + 1)]) ? $connect['time'] : |
129 |
|
|
substr($connect['views'][($i + 1)], 0, strpos($connect['views'][($i + 1)], "|")); |
130 |
|
|
$length = bbc_visit_time($this_time, $next_time, $i); |
131 |
|
|
$length = (($i + 1 !== $viewcount) && ($length === false)) ? "00 s" : $length; |
132 |
|
|
$visit_count = ($i + (($previous_visit_count > 0) ? ($previous_visit_count + 1) : 1)); |
133 |
|
|
|
134 |
|
|
$str .= "<td class=\"cell\" align=\"center\">".$visit_count."</td>\n" |
135 |
|
|
."<td class=\"cell\" align=\"left\"> ".$page."</td>" |
136 |
|
|
."<td class=\"cell\" align=\"right\">".$length." </td>\n" |
137 |
|
|
."<td class=\"cell\" align=\"center\">".(($reload > 0) ? $reload : "")."</td>" |
138 |
|
|
."</tr>\n"; |
139 |
|
|
} |
140 |
|
|
|
141 |
|
|
$str .= "</table>"; |
142 |
|
|
|
143 |
|
|
return $str; |
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
// Generate page (with use of the functions above) |
147 |
|
|
echo $BBC_HTML->html_begin() |
148 |
|
|
.$BBC_HTML->topbar() |
149 |
|
|
.$BBC_HTML->color_explain() |
150 |
|
|
."<table class=\"centerdata\">\n" |
151 |
|
|
."<tr><td class=\"labelbox\">\n" |
152 |
|
|
."<table class=\"centerdata\">\n" |
153 |
|
|
.bbc_list_visits() |
154 |
|
|
."</td></tr></table>\n" |
155 |
|
|
.$BBC_HTML->copyright() |
156 |
|
|
.$BBC_HTML->topbar(0, 1); |
157 |
|
|
|
158 |
|
|
// END + DISPLAY Time Measuring, load-time of the page (see config) |
159 |
|
|
global $BBC_LOADTIME; |
160 |
|
|
|
161 |
|
|
if (!empty($BBC_LOADTIME)) { |
162 |
|
|
$time = microtime(); |
163 |
|
|
$time = explode(' ', $time); |
164 |
|
|
$time = $time[1] + $time[0]; |
165 |
|
|
$finish = $time; |
166 |
|
|
$total_time = round(($finish - $start), 4); |
167 |
|
|
echo "<div class=\"loadtime\">".$translation['generated'].$total_time.$translation['seconds']."</div>\n"; |
168 |
|
|
} |
169 |
|
|
|
170 |
|
|
// End of HTML |
171 |
|
|
echo $BBC_HTML->html_end() |
172 |
matthys |
18 |
?> |