function bbc_plot($x, $y, $width, $height) { global $BBC_IMAGES_PATH, $BBC_TIME_OFFSET, $translation; // Various sizes $nb_x = count($x); $nb_y = count($y); $nb = !empty($x) ? min($nb_x, $nb_y) : $nb_y; $bar_width = round($width / $nb); $sum_y = array_sum($y); $nb_e = $nb; if ($nb_e == 12) { for ($i = 0; $i < 12; $i++) { if ($y[$i] != 0) { $nb_e = $nb_e - $i; break; } } } $avarage = round($sum_y / $nb_e); // Finding the max for ($k = 0, $max_y = 0; $k < $nb; $max_y = max($y[$k], $max_y), $k++) { } // The height of one unit $unit_height = !empty($max_y) ? 0.92 * ($height / $max_y) : 0; $avarage_height = round($max_y * $unit_height) - round($avarage * $unit_height) + 17; $str = "<div><div class=\"graph-line\" style=\"top:" . $avarage_height . "px; \"><p align=\"left\" style=\"color:#df5959; padding:0px;margin:0px;\"><em>" . $translation['tstat_average'] . ": " . $avarage . "</em></p></div>"; $str .= "<table class=\"centerbox\">\n" . "<tr class=\"graph-background\">\n"; for ($k = 0; $k < $nb; $k++) { $bar_height = round($y[$k] * $unit_height); $str .= "<td class=\"nopadding\" width=\"{$bar_width}\" height=\"{$height}\">\n" . "<table class=\"centerdata\">\n" . "<tr>\n"; if ($y[$k]) { $numb = $y[$k] >= 1000 ? substr($tmp = $y[$k] / 1000, 0, strpos($tmp, ".") + 2) . "k" : $y[$k]; $bbc_column_color = "column"; // default column color if ($nb > 27 || $nb == 7) { // make sure it's a month and not a week, hour, etc. $bbc_weekend = mktime(date("G"), date("i"), 0, date("m"), date("d") - ($nb - $k - 1), date("Y")); // Correct for time offset $bbc_weekend = $bbc_weekend + $BBC_TIME_OFFSET * 60; if (date("w", $bbc_weekend) == 0 || date("w", $bbc_weekend) == 6) { // 0 is Sunday and 6 is Saturday $bbc_column_color = "weekend-column"; // column color for weekends } } else { if ($nb == 24) { $bbc_weekend = mktime(date("G") - ($nb - $k - 1), date("i"), 0, date("m"), date("d"), date("Y")); // Correct for time offset $bbc_weekend = $bbc_weekend + $BBC_TIME_OFFSET * 60; } else { $bbc_weekend = mktime(date("G"), date("i"), 0, date("m") - ($nb - $k - 1), date("d"), date("Y")); // Correct for time offset $bbc_weekend = $bbc_weekend + $BBC_TIME_OFFSET * 60; } } $str .= "<td class=\"sky\" height=\"" . ($height - $bar_height) . "\" " . "style=\"border-style: none " . bbc_graph_spacer($nb - 1, $k, $y) . "\">" . "<span class=\"label-graph-ydata\">{$numb}</span>" . "</td>\n" . "</tr>\n" . "<tr class=\"" . $bbc_column_color . "\">\n"; if ($nb > 27 || $nb == 7) { // make sure it's a month and not a week, hour, etc. // week (7 days), and full month (>27 days) $str .= "<td title=\"" . date_format_translated($translation['global_day_format'], $bbc_weekend) . " «" . $y[$k] . "»\" height=\"{$bar_height}\" class=\"brd\" "; } else { if ($nb == 24) { // hours (24) $str .= "<td title=\"" . date_format_translated($translation['global_hours_format'], $bbc_weekend) . " «" . $y[$k] . "»\" height=\"{$bar_height}\" class=\"brd\" "; } else { // months (12) $str .= "<td title=\"" . date_format_translated($translation['global_month_format'], $bbc_weekend) . " «" . $y[$k] . "»\" height=\"{$bar_height}\" class=\"brd\" "; } } $str .= "style=\"border-style: solid " . bbc_graph_spacer($nb - 1, $k, $y) . "\"></td>\n"; } else { $str .= "<td height=\"{$height}\"></td>\n"; } $str .= "</tr>\n" . "</table>\n" . "</td>\n"; } $str .= "</tr>\n" . "<tr class=\"bottombox\">\n"; for ($k = 0; $k < $nb; $k++) { $str .= "<td class=\"center\" width=\"{$bar_width}\" height=\"15\">\n" . "<table class=\"brd\" style=\"border-style: solid none none\" align=\"center\" border=\"0\" " . "cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n" . "<tr>\n" . "<td class=\"label-graph-xdata\">" . $x[$k] . "</td>\n" . "</tr>\n" . "</table>\n" . "</td>\n"; } $str .= "</tr>\n" . "</table>\n"; $str .= "</div>"; return $str; }
function last_reset() { global $translation, $access; $timestamp = isset($access['time']['reset']) ? $access['time']['reset'] : ""; return "<p align=\"center\"><i>" . $translation['global_last_reset'] . ": " . date_format_translated($translation['global_day_format'], $timestamp) . ".</i></p>\n"; }
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>"; } }