function bbc_extension_plugin($host, $addr) { global $BBC_GEOIP_PATH, $gi; // First of all let's check if the include file exists if (!@file_exists($BBC_GEOIP_PATH . 'geoip.inc')) { bbc_msg('Missing geoip installation'); } include_once $BBC_GEOIP_PATH . 'geoip.inc'; // Bail out if the file exists but does not seem to be geoip if (!function_exists('geoip_open')) { return ""; } if (preg_match('/^.{1,4}:/', $addr)) { $gi = geoip_open($BBC_GEOIP_PATH . "GeoIPv6.dat", GEOIP_STANDARD); $addr = geoip_country_code_by_addr_v6($gi, $addr); } else { $gi = geoip_open($BBC_GEOIP_PATH . "GeoIP.dat", GEOIP_STANDARD); $addr = geoip_country_code_by_addr($gi, $addr); } geoip_close($gi); return strtolower($addr); }
// START Time Measuring, load-time of the page (see config) $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; // Read constants if (is_readable("constants.php")) { require_once "constants.php"; } else { exit("ERROR: Unable to open constants.php"); } foreach (array($BBC_CONFIG_FILE, $BBC_LIB_PATH . "selectlang.php", $BBC_ACCESS_FILE) as $i) { if (is_readable($i)) { require_once $i; } else { exit(bbc_msg($i)); } } // Determine whether we are allowed to display show_config.php if (empty($BBC_SHOW_CONFIG)) { header("Location: show_global.php"); return; } // Generate page echo $BBC_HTML->html_begin() . $BBC_HTML->topbar() . "<table class=\"center\">\n" . "<tr><td class=\"padding\">\n" . "<table class=\"centerbox\">\n" . "<tr><td>\n" . "<table class=\"centerdata\">\n" . "<tr>\n" . "<td class=\"label\" width=\"20%\">" . $translation['config_variable_name'] . "</td>\n" . "<td class=\"label\" width=\"60%\">" . $translation['config_explanations'] . "</td>\n" . "<td class=\"label\" width=\"20%\">" . $translation['config_variable_value'] . "</td>\n" . "</tr>\n" . $BBC_HTML->show_config("BBC_MAINSITE") . $BBC_HTML->show_config("BBC_SHOW_CONFIG", 1) . $BBC_HTML->show_config("BBC_TITLEBAR") . $BBC_HTML->show_config("BBC_LANGUAGE") . $BBC_HTML->show_config("BBC_MAXTIME") . $BBC_HTML->show_config("BBC_MAXVISIBLE") . $BBC_HTML->show_config("BBC_DETAILED_STAT_FIELDS") . $BBC_HTML->show_config("BBC_TIME_OFFSET") . $BBC_HTML->show_config("BBC_NO_DNS", 1) . $BBC_HTML->show_config("BBC_NO_HITS", 1) . $BBC_HTML->show_config("BBC_IGNORE_IP") . $BBC_HTML->show_config("BBC_IGNORE_REFER") . $BBC_HTML->show_config("BBC_IGNORE_BOTS") . $BBC_HTML->show_config("BBC_IGNORE_AGENT", 1) . $BBC_HTML->show_config("BBC_KILL_STATS", 1) . $BBC_HTML->show_config("BBC_PURGE_SINGLE", 1) . $BBC_HTML->show_config("BBC_LOADTIME", 1) . $BBC_HTML->show_config("BBC_EXT_LOOKUP") . $BBC_HTML->show_config("BBC_CSS_FILE") . $BBC_HTML->show_config("BBC_HITS", 1) . $BBC_HTML->show_config("BBC_USE_ORIGINAL_URI", 1) . $BBC_HTML->show_config("BBC_MAX_PAGENAME") . "</table>\n" . "</td></tr></table>\n" . "</td></tr></table>\n" . $BBC_HTML->copyright() . $BBC_HTML->topbar(0, 1); // END + DISPLAY Time Measuring, load-time of the page (see config) global $BBC_LOADTIME; if (!empty($BBC_LOADTIME)) { $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0];
} return; } // write to lockfile if (($al = bbc_begin_write($BBC_LOCK, "1")) !== false) { foreach (array($BBC_LOG_PROCESSOR, $BBC_LIB_PATH . "new_connect.php", $BBC_LIB_PATH . "timecalc.php", $BBC_LIB_PATH . "referrer.php", $BBC_LIB_PATH . "charconv.php") as $i) { require_once $i; } require $BBC_ACCESS_FILE; require $BBC_LAST_FILE; // global and time stats if (bbc_add_new_connections_to_old()) { $af = bbc_begin_write($BBC_ACCESS_FILE, "<?php\nglobal \$access;\n\$access =\n" . bbc_array_to_str($access) . ";\n?>"); bbc_end_write($af); !empty($BBC_DEBUG) ? print bbc_msg(basename($BBC_ACCESS_FILE), "o") : ""; bbc_update_last_access(); $af = bbc_begin_write($BBC_LAST_FILE, "<?php\nglobal \$last;\n\$last =\n" . bbc_array_to_str($last) . ";\n?>"); bbc_end_write($af); !empty($BBC_DEBUG) ? print bbc_msg(basename($BBC_LAST_FILE), "o") : ""; } } else { !empty($BBC_DEBUG) ? print bbc_msg("", "l") : ""; } // once we've finished we unlock and truncate the lock file bbc_end_write($al); fclose(fopen($BBC_LOCK, "wb")); ignore_user_abort(0); // Exit if debug mode is turned on. if (!empty($BBC_DEBUG)) { exit; }
function bbc_counter_to_array() { global $BBC_CACHE_PATH, $BBC_COUNTER_PREFIX, $BBC_COUNTER_SUFFIX, $BBC_SEP, $BBC_COUNTER_COLUMNS, $BBC_COUNTER_COLUMN_NAMES, $BBC_COUNTER_FILES, $BBC_DEBUG; for ($i = 0, $nb_new_entry = 0; $i < $BBC_COUNTER_FILES; $i++) { $file = $BBC_CACHE_PATH . $BBC_COUNTER_PREFIX . $i . $BBC_COUNTER_SUFFIX; if (!is_readable($file)) { !empty($BBC_DEBUG) ? print bbc_msg($file) : ""; $no_acc = 1; continue; } $fp = fopen($file, "rb"); while (($line = fgetcsv($fp, 4096, $BBC_SEP)) !== false) { for ($j = 0, $max = count($line); $j < $max; $j++) { $line[$j] = trim($line[$j]); } // Avoiding ill formed counter file if (empty($line[0]) || !preg_match(":^[0-9]+\$:", $line[0])) { continue; } for ($k = 0; $k < $BBC_COUNTER_COLUMNS; $k++) { $counter_array[$nb_new_entry][$BBC_COUNTER_COLUMN_NAMES[$k]] = $line[$k]; } $nb_new_entry++; } fclose($fp); // reset the counter files if (is_writable($file)) { fclose(fopen($file, "wb")); } else { empty($no_acc) && !empty($BBC_DEBUG) ? print bbc_msg($file, "w") : ""; } } if (!empty($counter_array)) { usort($counter_array, "bbc_sort_time_sc"); } return empty($counter_array) ? array() : $counter_array; }
function bbc_show_connect_field($connect, $field, $lng, $titles = false) { global $BBC_WHOIS, $BBC_IMAGES_PATH, $BBC_LIB_PATH, $BBC_HTML, $extensions, $translation; $id = empty($connect['id']) ? 0 : $connect['id']; switch ($field) { case "id": return "<div align=\"center\">" . $connect['id'] . " </div>\n"; case "time": return "<div align=\"center\">" . str_replace(" ", " ", date_format_translated($translation["global_time_format"], $connect['time'])) . " </div>\n"; case "visits": return "<div align=\"center\"><a href=\"show_views.php?id={$id}&lng={$lng}\">" . $connect['visits'] . "</a> </div>\n"; case "ext": if (isset($extensions[$connect['ext']])) { $label = $extensions[$connect['ext']]; } else { $label = $connect['ext']; } return "<div align=\"left\"> <img src=\"" . $BBC_IMAGES_PATH . "ext/" . $connect['ext'] . ".png\" class=\"icon\" alt=\"" . $label . "\" title=\"" . $label . "\" /> " . $label . "</div>"; case "dns": if (strlen($connect['dns']) > 50) { $connect['dns'] = "..." . substr($connect['dns'], -47); } if (strlen($connect['dns']) < 2) { $connect['dns'] = $connect['ip']; } // Invalid dns => take IP $dns_str = $connect['dns']; $ip_str = $connect['ip']; if (!strcasecmp($dns_str, $ip_str)) { if ($BBC_WHOIS) { return "<div align=\"left\"> " . $connect[$field] . " <a href=\"" . $BBC_WHOIS . $dns_str . "\" target=\"blank\" title=\"" . $translation['dstat_whois_information'] . "\">(?)</a></div>"; } } return "<div align=\"left\"> " . $connect['dns'] . "</div>"; case "referer": if (strpos($connect['referer'], "://") === false) { return " "; } $url = substr(strstr($connect['referer'], "://"), 3); $str = ($slash = strpos($url, "/")) !== false ? substr($url, 0, $slash) : $url; $str = strlen($str) > 50 ? "..." . substr($str, -47) : $str; return "<div align=\"left\"> \n" . "<script type=\"text/javascript\">\n" . "<!--\n" . "document.write('<a href=\"http://{$url}\" rel=\"nofollow\" title=\"{$str}\">{$str}<\\/a>');\n" . "-->\n" . "</script>\n" . "<noscript><span title=\"{$str}\">{$str}</span></noscript>\n" . "</div>\n"; case "browser": if (!empty($connect['robot'])) { return bbc_show_connect_field($connect, "robot", $lng); } elseif (is_readable($BBC_LIB_PATH . "browser.php")) { require $BBC_LIB_PATH . "browser.php"; } else { return bbc_msg($BBC_LIB_PATH . "browser.php"); } if (!($match = !isset($browser[$connect[$field]]) ? false : $browser[$connect[$field]])) { return " "; } $title = str_replace("other", $translation['misc_other'], $match['title']); return "<div align=\"left\"> <img src=\"" . $BBC_IMAGES_PATH . "browser/" . $match['icon'] . ".png\" class=\"icon\" alt=\"{$title}\" title=\"{$title}\" />" . " " . str_replace(" ", " ", $title) . (empty($connect['browser_note']) ? "" : " " . $connect['browser_note']) . "</div>"; case "os": if (!empty($connect['robot'])) { return bbc_show_connect_field($connect, "robot", $lng); } elseif (is_readable($BBC_LIB_PATH . "os.php")) { require $BBC_LIB_PATH . "os.php"; } else { return bbc_msg($BBC_LIB_PATH . "os.php"); } if (!($match = !isset($os[$connect[$field]]) ? false : $os[$connect[$field]])) { return " "; } $title = str_replace("other", $translation['misc_other'], $match['title']); if (isset($connect['screen_res'])) { $res_str = "(" . $connect['screen_res'] . ")"; } return "<div align=\"left\"> <img src=\"" . $BBC_IMAGES_PATH . "os/" . $match['icon'] . ".png\" class=\"icon\" alt=\"{$title}\" title=\"{$title}\" />" . " " . str_replace(" ", " ", $title) . (empty($connect['os_note']) ? "" : " " . $connect['os_note']) . (isset($res_str) ? " " . $res_str : "") . "</div>"; case "robot": if (is_readable($BBC_LIB_PATH . "robot.php")) { require $BBC_LIB_PATH . "robot.php"; } else { return bbc_msg($BBC_LIB_PATH . "robot.php"); } if (!($match = !isset($robot[$connect[$field]]) ? false : $robot[$connect[$field]])) { return " "; } $title = str_replace("other", $translation['misc_other'], $match['title']); return "<div align=\"left\"> <img src=\"" . $BBC_IMAGES_PATH . "robot/" . $match['icon'] . ".png\" class=\"icon\" alt=\"{$title}\" title=\"{$title}\" />" . " " . str_replace(" ", " ", $title) . (empty($connect['robot_note']) ? "" : " " . $connect['robot_note']) . "</div>"; case "page": if (!isset($connect['page'])) { return " "; } $last_page = $titles[$connect['page']]; $last_page = $last_page == "index" ? $translation["navbar_main_site"] : $last_page; return "<div align=\"left\"> {$last_page}</div>"; default: if (!isset($connect[$field]) || $connect[$field] == "-") { return " "; } return "<div align=\"left\"> " . $connect[$field] . "</div>"; } }
function bbc_show_robot() { global $access, $BBC_IMAGES_PATH, $BBC_LIB_PATH, $BBC_MAXROBOT, $translation; if (is_readable($BBC_LIB_PATH . "robot.php")) { require $BBC_LIB_PATH . "robot.php"; } else { return bbc_msg($BBC_LIB_PATH . "robot.php"); } $robot_tab = isset($access['stat']['robot']) ? $access['stat']['robot'] : array(); for ($robot_total = 0; list(, $robot_score) = each($robot_tab); $robot_total += $robot_score) { } arsort($robot_tab); reset($robot_tab); $str = bbc_rank_head($BBC_MAXROBOT, "gstat_robots"); for ($k = 0; (list($robot_type, $robot_score) = each($robot_tab)) && $k < $BBC_MAXROBOT; $k++) { if (!isset($robot[$robot_type])) { $str .= bbc_list_item("robot/robot.png", $robot_type, $robot_score, $robot_total, 'robot'); continue; } $str .= bbc_list_item("robot/" . $robot[$robot_type]['icon'] . ".png", $robot[$robot_type]['title'], $robot_score, $robot_total, 'robot'); } $str .= bbc_rank_sum($robot_total); return $str; }
*/ //////////////////////////////// // Detection & Setup Language // //////////////////////////////// if (is_readable($BBC_LIB_PATH . "html.php")) { require_once $BBC_LIB_PATH . "html.php"; } else { exit(bbc_msg($BBC_LIB_PATH . "html.php")); } // Initialising the HTML class $BBC_HTML = new BBC_HTML(); if (is_readable($BBC_LANGUAGE_PATH . $BBC_HTML->lng . ".php")) { require_once $BBC_LANGUAGE_PATH . $BBC_HTML->lng . ".php"; } elseif (is_readable($BBC_LANGUAGE_PATH . "en.php")) { } else { exit(bbc_msg($BBC_LANGUAGE_PATH . "en.php")); } /** * Format date/time according to given format string, in the selected language. * @param $format date format, as per PHP specs * @param $timestamp the timestamp to format * @return String with formatted timestamp */ function date_format_translated($format, $timestamp) { global $translation; $day_name_short = array($translation['tstat_su'], $translation['tstat_mo'], $translation['tstat_tu'], $translation['tstat_we'], $translation['tstat_th'], $translation['tstat_fr'], $translation['tstat_sa']); $day_name_full = array($translation['tstat_full_su'], $translation['tstat_full_mo'], $translation['tstat_full_tu'], $translation['tstat_full_we'], $translation['tstat_full_th'], $translation['tstat_full_fr'], $translation['tstat_full_sa']); $month_name_short = array($translation['tstat_jan'], $translation['tstat_feb'], $translation['tstat_mar'], $translation['tstat_apr'], $translation['tstat_may'], $translation['tstat_jun'], $translation['tstat_jul'], $translation['tstat_aug'], $translation['tstat_sep'], $translation['tstat_oct'], $translation['tstat_nov'], $translation['tstat_dec']); $month_name_full = array($translation['tstat_full_jan'], $translation['tstat_full_feb'], $translation['tstat_full_mar'], $translation['tstat_full_apr'], $translation['tstat_full_may'], $translation['tstat_full_jun'], $translation['tstat_full_jul'], $translation['tstat_full_aug'], $translation['tstat_full_sep'], $translation['tstat_full_oct'], $translation['tstat_full_nov'], $translation['tstat_full_dec']); // Loop char by char through php date format string, cacth the ones which need translating