ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/BBClone/trunk/show_detailed.php
Revision: 500
Committed: Fri Dec 8 12:25:28 2023 UTC (11 months, 2 weeks ago) by joku
File size: 9856 byte(s)
Log Message:
update Copyright, added Robots

File Contents

# Content
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-2024, 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']."&nbsp;</div>\n";
51
52 case "time":
53 return "<div align=\"center\">".str_replace(" ", "&nbsp;", date_format_translated($translation["global_time_format"], $connect['time']))."&nbsp;</div>\n";
54
55 case "visits":
56 return "<div align=\"center\"><a href=\"show_views.php?id=$id&amp;lng=$lng\">".$connect['visits']."</a>&nbsp;</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\">&nbsp;<img src=\"".$BBC_IMAGES_PATH."ext/".$connect['ext'].".png\" class=\"icon\" alt=\"".$label."\" title=\"".$label."\" />&nbsp;&nbsp;".$label."</div>";
62
63 case "dns":
64 /*-------------------------------------------------------------------------------------*/
65 $dns_str = $connect['dns'];
66 $ip_str = $connect['ip'];
67 $is_num = ($dns_str == $ip_str) ? 1 : 0;
68 if ($is_num || strlen($dns_str ) < 2) {
69 // Numeric shortened
70 if (strpos($ip_str, ":") === false) {
71 // IPv4
72 $dns_str = trim(substr($ip_str, 0, strrpos($ip_str, "."))).".&nbsp;-";
73 } else {
74 // IPv6
75 $parts = explode( ":", $ip_str);
76 $parts = array_slice( $parts, 0, 4);
77 $dns_str = implode( ":", $parts) . ":&nbsp;-";
78 }
79 } else {
80 // DNS Name shortened
81 $parts = explode( ".", $dns_str);
82 $lastparts = implode( ".", array_slice( $parts, -2, 2) );
83 if (strlen($lastparts) <= 6) {
84 // Last 2 DNS name parts <= 6; take last 3 parts
85 $dns_str = implode( ".", array_slice( $parts, -3, 3) );
86 } else {
87 // Last 2 DNS name parts > 6; take last 2 parts
88 $dns_str = implode( ".", array_slice( $parts, -2, 2) );
89 }
90 }
91
92 if ($BBC_WHOIS == 1) return "<div align=\"left\">&nbsp;".$dns_str."</div>";
93 if ($BBC_WHOIS == 2) return "<div align=\"left\">&nbsp;anonymous</div>";
94 /*-------------------------------------------------------------------------------------*/
95 if (strlen($connect['dns']) > 50) $connect['dns'] = "...".substr($connect['dns'], -47);
96 if (strlen($connect['dns']) < 2) $connect['dns'] = $connect['ip']; // Invalid dns => take IP
97 $dns_str = $connect['dns'];
98 $ip_str = $connect['ip'];
99 if (!strcasecmp ($dns_str, $ip_str))
100 if ($BBC_WHOIS) return "<div align=\"left\">&nbsp;".$connect[$field]."&nbsp;<a href=\"".$BBC_WHOIS.$dns_str."\" target=\"blank\" title=\"".$translation['dstat_whois_information']."\">(?)</a></div>";
101 return "<div align=\"left\">&nbsp;".$connect['dns']."</div>";
102
103 case "referer":
104 if (strpos($connect['referer'], "://") === false) return "&nbsp;";
105
106 $url = substr(strstr($connect['referer'], "://"), 3);
107 $str = (($slash = strpos($url, "/")) !== false) ? substr($url, 0, $slash) : $url;
108 $str = (strlen($str) > 50) ? "...".substr($str, -47) : $str;
109
110 return "<div align=\"left\">&nbsp;\n"
111 ."<script type=\"text/javascript\">\n"
112 ."<!--\n"
113 ."document.write('<a href=\"http://$url\" rel=\"nofollow\" title=\"$str\">$str<\/a>');\n"
114 ."-->\n"
115 ."</script>\n"
116 ."<noscript><span title=\"$str\">$str</span></noscript>\n"
117 ."</div>\n";
118
119 case "browser":
120 if (!empty($connect['robot'])) return bbc_show_connect_field($connect, "robot", $lng);
121 elseif (is_readable($BBC_LIB_PATH."browser.php")) require($BBC_LIB_PATH."browser.php");
122 else return bbc_msg($BBC_LIB_PATH."browser.php");
123
124 if (!$match = (!isset($browser[$connect[$field]]) ? false : $browser[$connect[$field]])) return "&nbsp;";
125
126 $title = str_replace("other", $translation['misc_other'], $match['title']);
127
128 return "<div align=\"left\">&nbsp;<img src=\"".$BBC_IMAGES_PATH."browser/".$match['icon'].".png\" class=\"icon\" alt=\"$title\" title=\"$title\" />"
129 ."&nbsp;&nbsp;".str_replace(" ", "&nbsp;", $title)
130 .(empty($connect['browser_note']) ? "" : "&nbsp;".$connect['browser_note'])."</div>";
131
132 case "os":
133 if (!empty($connect['robot'])) return bbc_show_connect_field($connect,"robot", $lng);
134 elseif (is_readable($BBC_LIB_PATH."os.php")) require($BBC_LIB_PATH."os.php");
135 else return bbc_msg($BBC_LIB_PATH."os.php");
136
137 if (!$match = (!isset($os[$connect[$field]]) ? false : $os[$connect[$field]])) return "&nbsp;";
138
139 $title = str_replace("other", $translation['misc_other'], $match['title']);
140 if (isset($connect['screen_res'])) $res_str = "(".$connect['screen_res'].")";
141
142 return "<div align=\"left\">&nbsp;<img src=\"".$BBC_IMAGES_PATH."os/".$match['icon'].".png\" class=\"icon\" alt=\"$title\" title=\"$title\" />"
143 ."&nbsp;&nbsp;".str_replace(" ", "&nbsp;", $title)
144 .(empty($connect['os_note']) ? "" : "&nbsp;".$connect['os_note']).(isset($res_str) ? "&nbsp;".$res_str : "")."</div>";
145
146 case "robot":
147 if (is_readable($BBC_LIB_PATH."robot.php")) require($BBC_LIB_PATH."robot.php");
148 else return bbc_msg($BBC_LIB_PATH."robot.php");
149
150 if (!$match = (!isset($robot[$connect[$field]]) ? false : $robot[$connect[$field]])) return "&nbsp;";
151
152 $title = str_replace("other", $translation['misc_other'], $match['title']);
153
154 return "<div align=\"left\">&nbsp;<img src=\"".$BBC_IMAGES_PATH."robot/".$match['icon'].".png\" class=\"icon\" alt=\"$title\" title=\"$title\" />"
155 ."&nbsp;&nbsp;".str_replace(" ", "&nbsp;", $title)
156 .(empty($connect['robot_note']) ? "" : "&nbsp;".$connect['robot_note'])."</div>";
157
158 case "page":
159 if (!isset($connect['page'])) return "&nbsp;";
160
161 $last_page = $titles[($connect['page'])];
162 $last_page = ($last_page == "index") ? $translation["navbar_main_site"] : $last_page;
163
164 return "<div align=\"left\">&nbsp;$last_page</div>";
165
166 default:
167 if (!isset($connect[$field]) || ($connect[$field] == "-")) return "&nbsp;";
168 return "<div align=\"left\">&nbsp;".$connect[$field]."</div>";
169 }
170 }
171
172 // Main functions to generate Stats
173 function bbc_rows_gen() {
174 global $BBC_DETAILED_STAT_FIELDS, $BBC_MAXVISIBLE, $BBC_HTML, $translation, $last;
175
176 $fields_title = array(
177 "browser" => $translation['dstat_browser'],
178 "dns" => $translation['dstat_dns'],
179 "ext" => $translation['dstat_extension'],
180 "id" => $translation['dstat_id'],
181 "ip" => $translation['dstat_ip'],
182 "os" => $translation['dstat_os'],
183 "page" => $translation['dstat_last_page'],
184 "prx_ip" => $translation['dstat_prx'],
185 "referer" => $translation['dstat_from'],
186 "search" => $translation['dstat_search'],
187 "time" => $translation['dstat_time'],
188 "visits" => $translation['dstat_visits'],
189 );
190
191 $fields = explode(",", str_replace(" ", "", $BBC_DETAILED_STAT_FIELDS));
192 $nb_access = isset($last['traffic']) ? count($last['traffic']) : 0;
193 $str = "<tr>\n";
194
195 foreach ($fields as $val) $str .= "<td class=\"label\">".$fields_title[$val]."</td>\n";
196
197 $str .= "</tr>\n";
198
199 for ($k = $nb_access - 1; $k >= max(0, $nb_access - $BBC_MAXVISIBLE); $k--) {
200 $style_class = $BBC_HTML->connect_color_class($last['traffic'][$k]);
201 $str .= "<tr class=\"$style_class hover_white\">\n";
202 reset($fields);
203 foreach ($fields as $key => $val) {
204 $cell = bbc_show_connect_field($last['traffic'][$k], $val, $BBC_HTML->lng, $last['pages']);
205 $str .= "<td class=\"cell\">".(empty($cell) ? "&nbsp;" : $cell)."</td>\n";
206 }
207 $str .= "</tr>\n";
208 }
209 return $str;
210 }
211
212 // Generate page (with use of the functions above)
213 echo $BBC_HTML->html_begin()
214 .$BBC_HTML->topbar()
215 .$BBC_HTML->color_explain()
216 ."<table class=\"centerdata\">\n"
217 ."<tr><td class=\"labelbox\">\n"
218 ."<table class=\"centerdata\">\n"
219 .bbc_rows_gen()
220 ."</table>\n"
221 ."</td></tr></table>\n"
222 .$BBC_HTML->copyright()
223 .$BBC_HTML->topbar(0, 1);
224
225 // END + DISPLAY Time Measuring, load-time of the page (see config)
226 global $BBC_LOADTIME;
227
228 if (!empty($BBC_LOADTIME)) {
229 $time = microtime();
230 $time = explode(' ', $time);
231 $time = $time[1] + $time[0];
232 $finish = $time;
233 $total_time = round(($finish - $start), 4);
234 echo "<div class=\"loadtime\">".$translation['generated'].$total_time.$translation['seconds']."</div>\n";
235 }
236
237 // End of HTML
238 echo $BBC_HTML->html_end()
239 ?>

Properties

Name Value
svn:keywords Id