ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/BBClone/trunk/lib/html.php
Revision: 417
Committed: Wed Dec 21 11:27:14 2022 UTC (23 months, 1 week ago) by joku
File size: 14614 byte(s)
Log Message:
update Copyright 

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

Properties

Name Value
svn:keywords Id