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-2013, 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 |
// HTML Output Builder // |
23 |
///////////////////////// |
24 |
|
25 |
// Include BBClone hits in Stats (see config, enabled by default) |
26 |
if ($BBC_HITS == 1) { |
27 |
// if (!defined("_BBC_PAGE_NAME")) {define("_BBC_PAGE_NAME", "/");} |
28 |
if (!defined("_BBCLONE_DIR")) {define("_BBCLONE_DIR", "./");} |
29 |
if (!defined("COUNTER")) { |
30 |
define("COUNTER", _BBCLONE_DIR."mark_page.php"); |
31 |
if (is_readable(COUNTER)) include_once(COUNTER); |
32 |
} |
33 |
} |
34 |
|
35 |
class bbc_html { |
36 |
var $lang_tab, $lng, $server; |
37 |
|
38 |
function get_lng() { |
39 |
if (_BBC_PHP < 410) global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS; |
40 |
|
41 |
global $BBC_LANGUAGE; |
42 |
|
43 |
// Get variables depending on PHP version |
44 |
$get = ((_BBC_PHP < 410) ? !empty($HTTP_GET_VARS['lng']) : !empty($_GET['lng'])) ? |
45 |
((_BBC_PHP < 410) ? $HTTP_GET_VARS['lng'] : $_GET['lng']) : ""; |
46 |
$post = ((_BBC_PHP < 410) ? !empty($HTTP_POST_VARS['lng']) : !empty($_POST['lng'])) ? |
47 |
((_BBC_PHP < 410) ? $HTTP_POST_VARS['lng'] : $_POST['lng']) : ""; |
48 |
$aclng = ((_BBC_PHP < 410) ? !empty($HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE']) : |
49 |
!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) ? ((_BBC_PHP < 410) ? |
50 |
$HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'] : $_SERVER['HTTP_ACCEPT_LANGUAGE']) : ""; |
51 |
|
52 |
if ($get && preg_match(":^[\w\-]{1,5}:", $get)) $this->lng = $get; |
53 |
elseif ($post && (preg_match(":^[\w\-]{1,5}:", $post))) $this->lng = $post; |
54 |
elseif ($aclng && (preg_match(":^[\w\-]{1,5}:", $aclng))) { |
55 |
|
56 |
$this->lng = (($comma = strpos($aclng, ",")) !== false) ? substr($aclng, 0, $comma) : $aclng; |
57 |
$this->lng = ((($dash = strpos($this->lng, "-")) !== false) && (!isset($this->lang_tab[$this->lng]))) ? |
58 |
substr($this->lng, 0, $dash) : $this->lng; |
59 |
} |
60 |
else $this->lng = $BBC_LANGUAGE; |
61 |
|
62 |
return (isset($this->lang_tab[$this->lng]) ? $this->lng : $BBC_LANGUAGE); |
63 |
} |
64 |
|
65 |
function set_title() { |
66 |
global $BBC_TIMESTAMP, $BBC_TIME_OFFSET, $BBC_TITLEBAR, $translation; |
67 |
|
68 |
$conv = array( |
69 |
"%DATE" => date_format_translated($translation['global_day_format'], ($BBC_TIMESTAMP + ($BBC_TIME_OFFSET * 60))), |
70 |
"%SERVER" => $this->server |
71 |
); |
72 |
if (empty($BBC_TITLEBAR)) { |
73 |
$BBC_TITLEBAR = $translation['global_titlebar']; |
74 |
}; |
75 |
return strtr($BBC_TITLEBAR, $conv); |
76 |
} |
77 |
|
78 |
function last_reset() { |
79 |
global $translation, $access; |
80 |
$timestamp = isset($access['time']['reset']) ? $access['time']['reset'] : ""; |
81 |
return "<p align=\"center\"><i>".$translation['global_last_reset'].": ".date_format_translated($translation['global_day_format'], $timestamp) |
82 |
.".</i></p>\n"; |
83 |
} |
84 |
|
85 |
function bbc_html() { |
86 |
if (_BBC_PHP < 410) global $HTTP_SERVER_VARS; |
87 |
|
88 |
global $translation; |
89 |
|
90 |
$this->lang_tab = array( |
91 |
"ar" => "Arabic", |
92 |
"bs" => "Bosnian", |
93 |
"bg" => "Bulgarian", |
94 |
"ca" => "Catalan", |
95 |
"cs" => "Czech", |
96 |
"zh-cn" => "Chinese Simp", |
97 |
"zh-tw" => "Chinese Trad", |
98 |
"da" => "Danish", |
99 |
"en" => "English", |
100 |
"nl" => "Nederlands", |
101 |
"de" => "Deutsch", |
102 |
"fr" => "Français", |
103 |
"fi" => "Finnish", |
104 |
"el" => "Greek", |
105 |
"et" => "Estonian", |
106 |
"hu" => "Hungarian", |
107 |
"id" => "Indonesian", |
108 |
"it" => "Italian", |
109 |
"ja" => "Japanese", |
110 |
"ko" => "Korean", |
111 |
"lt" => "Lithuanian", |
112 |
"mk" => "Macedonian", |
113 |
"nb" => "Norwegian Bkm", |
114 |
"pl" => "Polish", |
115 |
"pt" => "Portuguese", |
116 |
"pt-br" => "Portuguese Br", |
117 |
"ro" => "Romanian", |
118 |
"ru" => "Russian", |
119 |
"sk" => "Slovak", |
120 |
"sl" => "Slovenian", |
121 |
"es" => "Spanish", |
122 |
"sv" => "Swedish", |
123 |
"th" => "Thai", |
124 |
"tr" => "Turkish", |
125 |
"uk" => "Ukrainian" |
126 |
); |
127 |
$this->lng = $this->get_lng(); |
128 |
$this->server = ((_BBC_PHP < 410) ? !empty($HTTP_SERVER_VARS['SERVER_NAME']) : !empty($_SERVER['SERVER_NAME'])) ? |
129 |
htmlspecialchars(((_BBC_PHP < 410) ? $HTTP_SERVER_VARS['SERVER_NAME'] : $_SERVER['SERVER_NAME']), |
130 |
ENT_QUOTES) : "noname"; |
131 |
} |
132 |
|
133 |
// Generates BBClone Config details |
134 |
function show_config($varname, $booleanflag = 0) { |
135 |
|
136 |
global $translation, $$varname; |
137 |
|
138 |
return "<tr class=\"morethan_row hover_white\">\n" |
139 |
// Variable name |
140 |
."<td align=\"left\" class=\"config-cell\">\n" |
141 |
."<b>\$$varname</b>\n" |
142 |
."</td>\n" |
143 |
// Explaination |
144 |
."<td align=\"left\" class=\"config-cell text-wrap\">\n" |
145 |
.$translation["config_".$varname]."\n" |
146 |
."</td>\n" |
147 |
// Variable value |
148 |
."<td align=\"left\" class=\"config-cell\">\n" |
149 |
."<b>".(!empty($$varname) ? ($booleanflag==1 ? $translation['global_yes'] : $$varname) : $translation['global_no'])."</b>\n" |
150 |
."</td></tr>\n"; |
151 |
} |
152 |
|
153 |
// Begin of all BBClone HTML documents |
154 |
function html_begin() { |
155 |
global $BBC_VERSION, $BBC_EXT_LOOKUP, $BBC_IMAGES_PATH, $BBC_CSS_PATH, $BBC_CSS_FILE, $translation; |
156 |
|
157 |
// Work around for default charset in Apache 2 (Thanks Martin Halachev!) |
158 |
if (!headers_sent()) header("Content-type: text/html; charset=".$translation['global_charset']); |
159 |
|
160 |
return "<?xml version=\"1.0\" encoding=\"".$translation['global_charset']."\"?>\n" |
161 |
."<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" |
162 |
."\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" |
163 |
."<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" |
164 |
."<head>\n" |
165 |
."<title>BBClone $BBC_VERSION $BBC_EXT_LOOKUP</title>\n" |
166 |
."<link rel=\"shortcut icon\" href=\"".$BBC_IMAGES_PATH."favicon.ico\" />\n" |
167 |
."<link rel=\"stylesheet\" href=\"".$BBC_CSS_PATH.$BBC_CSS_FILE."\" type=\"text/css\" />\n" |
168 |
."<meta http-equiv=\"cache-control\" content=\"no-cache\" />\n" |
169 |
."<meta http-equiv=\"pragma\" content=\"no-cache\" />\n" |
170 |
."<meta http-equiv=\"content-Script-Type\" content=\"text/javasript\" />\n" |
171 |
."<meta http-equiv=\"content-Style-Type\" content=\"text/css\" />\n" |
172 |
."<meta http-equiv=\"content-type\" content=\"text/html; charset=".$translation['global_charset']."\" />\n" |
173 |
."<meta name=\"robots\" content=\"none\" />\n" |
174 |
."<meta name=\"description\" content=\"BBClone ".$BBC_VERSION." - A PHP based Web Counter on Steroids\" />\n" |
175 |
."</head>\n" |
176 |
."<body>\n" |
177 |
// BBClone copyright notice: Removal or modification of the copyright holder |
178 |
// will void any support by the BBClone team and may be a reason to deny |
179 |
// access to the BBClone site if detected. |
180 |
."<!--\n" |
181 |
."This is BBClone $BBC_VERSION\n" |
182 |
."Homebase: http://www.bbclone.de/\n" |
183 |
."Copyright: 2001-2011 The BBClone Team\n" |
184 |
."License: GNU/GPL, version 2 or later\n" |
185 |
."-->\n"; |
186 |
} |
187 |
|
188 |
// Navigation Bar (both top and bottom) |
189 |
function topbar($lang_sel = 1, $on_bottom = 0) { |
190 |
if (_BBC_PHP < 410) global $HTTP_SERVER_VARS; |
191 |
|
192 |
global $BBC_IMAGES_PATH, $BBC_MAINSITE, $BBC_SHOW_CONFIG, $translation; |
193 |
|
194 |
$self = basename((_BBC_PHP < 410) ? $HTTP_SERVER_VARS['PHP_SELF'] : $_SERVER['PHP_SELF']); |
195 |
$self = htmlspecialchars(str_replace("index.php", ".", $self), ENT_QUOTES); |
196 |
$url_lng = !empty($this->lang_tab[$this->lng]) ? "?lng=".$this->lng."" : ""; |
197 |
// Navigation Buttons |
198 |
$navbar = array( |
199 |
"main" => array( "url" => $BBC_MAINSITE, "title" => $translation['navbar_main_site'], "icon" => "navbar_main.png" ), |
200 |
"config" => array( "url" => "show_config.php", "title" => !empty($BBC_SHOW_CONFIG)? $translation['navbar_configuration'] : "", "icon" => "navbar_config.png" ), |
201 |
"global" => array( "url" => "show_global.php", "title" => $translation['navbar_global_stats'], "icon" => "navbar_global.png" ), |
202 |
"detailed" => array( "url" => "show_detailed.php", "title" => $translation['navbar_detailed_stats'], "icon" => "navbar_detailed.png" ), |
203 |
"time" => array( "url" => "show_time.php", "title" => $translation['navbar_time_stats'], "icon" => "navbar_time.png" ) |
204 |
); |
205 |
// Language Selector |
206 |
$str = (empty($lang_sel) ? "" : "<form method=\"post\" action=\"$self\">\n") |
207 |
."<table ".(empty($on_bottom) ? "class=\"navbar\"" : "class=\"navbar bottom\"")."><tr><td>\n"; |
208 |
|
209 |
$sep = ""; |
210 |
// Create Navigation Buttons |
211 |
foreach (array_keys($navbar) as $menu_key) { |
212 |
$url = $navbar[$menu_key]['url']; |
213 |
$title = $navbar[$menu_key]['title']; |
214 |
$icon = $navbar[$menu_key]['icon']; |
215 |
$selected_class = (basename($_SERVER['SCRIPT_NAME']) == $url ? " selected" : ""); |
216 |
if ( basename($_SERVER['SCRIPT_NAME']) == "index.php" && $menu_key == "global") { |
217 |
$selected_class = " selected"; |
218 |
} |
219 |
if (empty($title)){ |
220 |
continue; |
221 |
} |
222 |
$str .= "<a class=\"navbar".$selected_class."\" href=\"$url".($menu_key != "main" ? $url_lng : "")."\"><img src=\"".$BBC_IMAGES_PATH.$icon."\" alt=\"icon\" /> $title</a> \n"; |
223 |
} |
224 |
// Create Language Selector |
225 |
if (!empty($lang_sel)) { |
226 |
$str .= " <img src=\"".$BBC_IMAGES_PATH."navbar_lng.png\" alt=\"".$translation['navbar_language']."\" title=\"".$translation['navbar_language']."\" /> \n" |
227 |
."<select name=\"lng\" onchange=\"if (this.selectedIndex>0){location.href='$self?lng=' + " |
228 |
."this.options[this.selectedIndex].value;}\">\n" |
229 |
."<option value=\"\"".(empty($this->lng) ? " selected=\"selected\"" : "").">".$translation['navbar_language']."</option>\n"; |
230 |
|
231 |
foreach ($this->lang_tab as $lang_id => $lang_name) { |
232 |
$str .= "<option value=\"$lang_id\"".(($this->lng == $lang_id) ? " selected=\"selected\"" : "") |
233 |
.">$lang_name</option>\n"; |
234 |
} |
235 |
$lang_tab_lng = empty($this->lang_tab[$this->lng]) ? "" : $this->lang_tab[$this->lng]; |
236 |
$str .= "</select>\n" |
237 |
." <noscript><input type=\"submit\" value=\"".$translation['navbar_go']."\" /></noscript>\n"; |
238 |
} |
239 |
|
240 |
$str .= "</td></tr></table>\n" |
241 |
.((!empty($on_bottom)) ? "" : |
242 |
"<table class=\"titlebar\">\n" |
243 |
."<tr><td class=\"title\">\n" |
244 |
.$this->set_title()."\n" |
245 |
."</td></tr></table>\n") |
246 |
.(empty($lang_sel) ? "" : "</form>\n"); |
247 |
|
248 |
return $str; |
249 |
} |
250 |
|
251 |
// Color explanation |
252 |
function color_explain() { |
253 |
global $BBC_MAXTIME, $BBC_MAXVISIBLE, $translation; |
254 |
|
255 |
return "<p><i>".$translation['dstat_visible_rows'].": $BBC_MAXVISIBLE | \n" |
256 |
."<span class=\"lessthan_row\"> ".$translation['dstat_last_visit']." < $BBC_MAXTIME ".$translation['misc_second_unit']." </span> | \n" |
257 |
."<span class=\"morethan_row\"> ".$translation['dstat_last_visit']." > $BBC_MAXTIME ".$translation['misc_second_unit']." </span> | \n" |
258 |
."<span class=\"robot_row\"> ".$translation['dstat_robots']." </span> | \n" |
259 |
."<span class=\"my_visit_row\"> ".$translation['dstat_my_visit']." </span></i></p>\n"; |
260 |
} |
261 |
|
262 |
// Determine the color style of the connection |
263 |
function connect_color_class($connect) { |
264 |
global $BBC_MAXTIME, $BBC_TIMESTAMP, $BBC_TIME_OFFSET; |
265 |
if (_BBC_PHP < 410) global $HTTP_SERVER_VARS; |
266 |
|
267 |
// It was you |
268 |
if (((_BBC_PHP < 410) ? $HTTP_SERVER_VARS["REMOTE_ADDR"] : $_SERVER["REMOTE_ADDR"]) == $connect['ip']) return 'my_visit_row'; |
269 |
// else, it was an access within $BBC_TIME_OFFSET |
270 |
elseif ((($BBC_TIMESTAMP + ($BBC_TIME_OFFSET * 60)) - $connect['time']) < $BBC_MAXTIME) return "lessthan_row"; |
271 |
// else, it is red if it is a robot |
272 |
elseif (!empty($connect['robot'])) return "robot_row"; |
273 |
// or blue if something else |
274 |
else return "morethan_row"; |
275 |
} |
276 |
|
277 |
// BBClone copyright notice |
278 |
function copyright() { |
279 |
global $BBC_IMAGES_PATH, $BBC_VERSION, $BBC_EXT_LOOKUP, $translation; |
280 |
|
281 |
// Get Build No |
282 |
if (is_readable("build.inc")) $BBC_BUILDNO = file_get_contents("build.inc"); |
283 |
else $BBC_BUILDNO = ""; |
284 |
|
285 |
return "<p><a href=\"http://www.bbclone.de/\">BBClone ".$BBC_VERSION." ".$BBC_EXT_LOOKUP."</a> © ".$translation['global_bbclone_copyright'] |
286 |
." <a href=\"http://www.gnu.org/copyleft/gpl.html\">GPL</a>\n" |
287 |
." <a href=\"http://validator.w3.org/check?url=referer\">" |
288 |
."<img src=\"".$BBC_IMAGES_PATH."valid-xhtml10.png\" class=\"validicon\" alt=\"Valid XHTML 1.0!\" title=\"Valid XHTML 1.0!\" /></a>\n" |
289 |
." <a href=\"http://jigsaw.w3.org/css-validator/check/referer\">" |
290 |
."<img src=\"".$BBC_IMAGES_PATH."valid-css.png\" class=\"validicon\" alt=\"Valid CSS!\" title=\"Valid CSS!\" /></a>\n" |
291 |
// ."<a href=\"http://www.php.net/\"><img src=\"".$BBC_IMAGES_PATH |
292 |
// ."php.png\" class=\"validicon\" |
293 |
// alt=\"PHP\" title=\"PHP\" " |
294 |
// alt=\"".phpversion()."\" title=\"".phpversion()."\" " |
295 |
// ."align=\"middle\" /></a>\n" |
296 |
// .phpversion() |
297 |
." <a href=\"http://tidy.sourceforge.net\">" |
298 |
."<img src=\"".$BBC_IMAGES_PATH."valid-tidy.png\" class=\"validtidy\" alt=\"Valid HTML Tidy!\" title=\"Valid HTML Tidy!\" /></a></p>\n" |
299 |
; |
300 |
} |
301 |
|
302 |
// End of all BBClone HTML documents |
303 |
function html_end() { |
304 |
return "</body>\n" |
305 |
."</html>\n"; |
306 |
} |
307 |
} |
308 |
?> |