ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/BBClone/trunk/show_detailed.php
Revision: 63
Committed: Thu Dec 5 15:19:31 2013 UTC (10 years, 11 months ago) by joku
File size: 8520 byte(s)
Log Message:
update Copyright, cobvert dos2unix

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

Properties

Name Value
svn:keywords Id