1 |
<?php |
2 |
/* This file is part of BBClone (A PHP based Web Counter on Steroids) |
3 |
* |
4 |
* SVN FILE $Id$ |
5 |
* |
6 |
* Copyright (C) 2001-2014, the BBClone Team (see doc/authors.txt for details) |
7 |
* |
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 Detailed Stats // |
23 |
///////////////////////// |
24 |
|
25 |
if(!defined("_BBC_PAGE_NAME")){define("_BBC_PAGE_NAME", "BBClone - Show Detailed");} |
26 |
|
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 |
// Functions to generate Stats for each row |
43 |
function bbc_show_connect_field($connect, $field, $lng, $titles = false) { |
44 |
global $BBC_WHOIS, $BBC_IMAGES_PATH, $BBC_LIB_PATH, $BBC_HTML, $extensions, $translation; |
45 |
|
46 |
$id = empty($connect['id']) ? 0 : $connect['id']; |
47 |
|
48 |
switch ($field) { |
49 |
case "id": |
50 |
return "<div align=\"center\">".$connect['id']." </div>\n"; |
51 |
|
52 |
case "time": |
53 |
return "<div align=\"center\">".str_replace(" ", " ", date_format_translated($translation["global_time_format"], $connect['time']))." </div>\n"; |
54 |
|
55 |
case "visits": |
56 |
return "<div align=\"center\"><a href=\"show_views.php?id=$id&lng=$lng\">".$connect['visits']."</a> </div>\n"; |
57 |
|
58 |
case "ext": |
59 |
if (isset($extensions[$connect['ext']])) $label = $extensions[$connect['ext']]; |
60 |
else $label = $connect['ext']; |
61 |
return "<div align=\"left\"> <img src=\"".$BBC_IMAGES_PATH."ext/".$connect['ext'].".png\" class=\"icon\" alt=\"".$label."\" title=\"".$label."\" /> ".$label."</div>"; |
62 |
|
63 |
case "dns": |
64 |
if (strlen($connect['dns']) > 50) $connect['dns'] = "...".substr($connect['dns'], -47); |
65 |
if (strlen($connect['dns']) < 2) $connect['dns'] = $connect['ip']; // Invalid dns => take IP |
66 |
$dns_str = $connect['dns']; |
67 |
$ip_str = $connect['ip']; |
68 |
if (!strcasecmp ($dns_str, $ip_str)) |
69 |
if ($BBC_WHOIS) return "<div align=\"left\"> ".$connect[$field]." <a href=\"".$BBC_WHOIS.$dns_str."\" target=\"blank\" title=\"".$translation['dstat_whois_information']."\">(?)</a></div>"; |
70 |
return "<div align=\"left\"> ".$connect['dns']."</div>"; |
71 |
|
72 |
case "referer": |
73 |
if (strpos($connect['referer'], "://") === false) return " "; |
74 |
|
75 |
$url = substr(strstr($connect['referer'], "://"), 3); |
76 |
$str = (($slash = strpos($url, "/")) !== false) ? substr($url, 0, $slash) : $url; |
77 |
$str = (strlen($str) > 50) ? "...".substr($str, -47) : $str; |
78 |
|
79 |
return "<div align=\"left\"> \n" |
80 |
."<script type=\"text/javascript\">\n" |
81 |
."<!--\n" |
82 |
."document.write('<a href=\"http://$url\" rel=\"nofollow\" title=\"$str\">$str<\/a>');\n" |
83 |
."-->\n" |
84 |
."</script>\n" |
85 |
."<noscript><span title=\"$str\">$str</span></noscript>\n" |
86 |
."</div>\n"; |
87 |
|
88 |
case "browser": |
89 |
if (!empty($connect['robot'])) return bbc_show_connect_field($connect, "robot", $lng); |
90 |
elseif (is_readable($BBC_LIB_PATH."browser.php")) require($BBC_LIB_PATH."browser.php"); |
91 |
else return bbc_msg($BBC_LIB_PATH."browser.php"); |
92 |
|
93 |
if (!$match = (!isset($browser[$connect[$field]]) ? false : $browser[$connect[$field]])) return " "; |
94 |
|
95 |
$title = str_replace("other", $translation['misc_other'], $match['title']); |
96 |
|
97 |
return "<div align=\"left\"> <img src=\"".$BBC_IMAGES_PATH."browser/".$match['icon'].".png\" class=\"icon\" alt=\"$title\" title=\"$title\" />" |
98 |
." ".str_replace(" ", " ", $title) |
99 |
.(empty($connect['browser_note']) ? "" : " ".$connect['browser_note'])."</div>"; |
100 |
|
101 |
case "os": |
102 |
if (!empty($connect['robot'])) return bbc_show_connect_field($connect,"robot", $lng); |
103 |
elseif (is_readable($BBC_LIB_PATH."os.php")) require($BBC_LIB_PATH."os.php"); |
104 |
else return bbc_msg($BBC_LIB_PATH."os.php"); |
105 |
|
106 |
if (!$match = (!isset($os[$connect[$field]]) ? false : $os[$connect[$field]])) return " "; |
107 |
|
108 |
$title = str_replace("other", $translation['misc_other'], $match['title']); |
109 |
if (isset($connect['screen_res'])) $res_str = "(".$connect['screen_res'].")"; |
110 |
|
111 |
return "<div align=\"left\"> <img src=\"".$BBC_IMAGES_PATH."os/".$match['icon'].".png\" class=\"icon\" alt=\"$title\" title=\"$title\" />" |
112 |
." ".str_replace(" ", " ", $title) |
113 |
.(empty($connect['os_note']) ? "" : " ".$connect['os_note']).(isset($res_str) ? " ".$res_str : "")."</div>"; |
114 |
|
115 |
case "robot": |
116 |
if (is_readable($BBC_LIB_PATH."robot.php")) require($BBC_LIB_PATH."robot.php"); |
117 |
else return bbc_msg($BBC_LIB_PATH."robot.php"); |
118 |
|
119 |
if (!$match = (!isset($robot[$connect[$field]]) ? false : $robot[$connect[$field]])) return " "; |
120 |
|
121 |
$title = str_replace("other", $translation['misc_other'], $match['title']); |
122 |
|
123 |
return "<div align=\"left\"> <img src=\"".$BBC_IMAGES_PATH."robot/".$match['icon'].".png\" class=\"icon\" alt=\"$title\" title=\"$title\" />" |
124 |
." ".str_replace(" ", " ", $title) |
125 |
.(empty($connect['robot_note']) ? "" : " ".$connect['robot_note'])."</div>"; |
126 |
|
127 |
case "page": |
128 |
if (!isset($connect['page'])) return " "; |
129 |
|
130 |
$last_page = $titles[($connect['page'])]; |
131 |
$last_page = ($last_page == "index") ? $translation["navbar_main_site"] : $last_page; |
132 |
|
133 |
return "<div align=\"left\"> $last_page</div>"; |
134 |
|
135 |
default: |
136 |
if (!isset($connect[$field]) || ($connect[$field] == "-")) return " "; |
137 |
return "<div align=\"left\"> ".$connect[$field]."</div>"; |
138 |
} |
139 |
} |
140 |
|
141 |
// Main functions to generate Stats |
142 |
function bbc_rows_gen() { |
143 |
global $BBC_DETAILED_STAT_FIELDS, $BBC_MAXVISIBLE, $BBC_HTML, $translation, $last; |
144 |
|
145 |
$fields_title = array( |
146 |
"browser" => $translation['dstat_browser'], |
147 |
"dns" => $translation['dstat_dns'], |
148 |
"ext" => $translation['dstat_extension'], |
149 |
"id" => $translation['dstat_id'], |
150 |
"ip" => $translation['dstat_ip'], |
151 |
"os" => $translation['dstat_os'], |
152 |
"page" => $translation['dstat_last_page'], |
153 |
"prx_ip" => $translation['dstat_prx'], |
154 |
"referer" => $translation['dstat_from'], |
155 |
"search" => $translation['dstat_search'], |
156 |
"time" => $translation['dstat_time'], |
157 |
"visits" => $translation['dstat_visits'], |
158 |
); |
159 |
|
160 |
$fields = explode(",", str_replace(" ", "", $BBC_DETAILED_STAT_FIELDS)); |
161 |
$nb_access = isset($last['traffic']) ? count($last['traffic']) : 0; |
162 |
$str = "<tr>\n"; |
163 |
|
164 |
foreach ($fields as $val) $str .= "<td class=\"label\">".$fields_title[$val]."</td>\n"; |
165 |
|
166 |
$str .= "</tr>\n"; |
167 |
|
168 |
for ($k = $nb_access - 1; $k >= max(0, $nb_access - $BBC_MAXVISIBLE); $k--) { |
169 |
$style_class = $BBC_HTML->connect_color_class($last['traffic'][$k]); |
170 |
$str .= "<tr class=\"$style_class hover_white\">\n"; |
171 |
reset($fields); |
172 |
while (list(, $val) = each($fields)) { |
173 |
$cell = bbc_show_connect_field($last['traffic'][$k], $val, $BBC_HTML->lng, $last['pages']); |
174 |
$str .= "<td class=\"cell\">".(empty($cell) ? " " : $cell)."</td>\n"; |
175 |
} |
176 |
$str .= "</tr>\n"; |
177 |
} |
178 |
return $str; |
179 |
} |
180 |
|
181 |
// Generate page (with use of the functions above) |
182 |
echo $BBC_HTML->html_begin() |
183 |
.$BBC_HTML->topbar() |
184 |
.$BBC_HTML->color_explain() |
185 |
."<table class=\"centerdata\">\n" |
186 |
."<tr><td class=\"labelbox\">\n" |
187 |
."<table class=\"centerdata\">\n" |
188 |
.bbc_rows_gen() |
189 |
."</table>\n" |
190 |
."</td></tr></table>\n" |
191 |
.$BBC_HTML->copyright() |
192 |
.$BBC_HTML->topbar(0, 1); |
193 |
|
194 |
// END + DISPLAY Time Measuring, load-time of the page (see config) |
195 |
global $BBC_LOADTIME; |
196 |
|
197 |
if (!empty($BBC_LOADTIME)) { |
198 |
$time = microtime(); |
199 |
$time = explode(' ', $time); |
200 |
$time = $time[1] + $time[0]; |
201 |
$finish = $time; |
202 |
$total_time = round(($finish - $start), 4); |
203 |
echo "<div class=\"loadtime\">".$translation['generated'].$total_time.$translation['seconds']."</div>\n"; |
204 |
} |
205 |
|
206 |
// End of HTML |
207 |
echo $BBC_HTML->html_end() |
208 |
?> |