; die; }
reset ($_GET);
while (list($key, $value)=each($_GET)) {
$$key=htmlspecialchars(trim(substr($value, 0, 255)));
}
// Ядро системы
$core=new core();
$core->begin = $begin== "" ? date("d-m-Y", time()) : $begin;
$core->end = $end== "" ? date("d-m-Y", time()) : $end;
$core->type = $type;
$core->type_gr = $type_gr;
$core->init();
if ($core->gbl_config['access']) {
if (!$_SERVER['PHP_AUTH_USER'] or $_SERVER['PHP_AUTH_PW'] != $core->gbl_config['password']) {
header("WWW-Authenticate: Basic realm=\"Просмотр статистики 'WEB_Count'\"");
header("HTTP/1.0 401 Unauthorized");
die("[Ошибка] Ошибка доступа к статистике.\n");
}
}
$result=$core->exec("SELECT DISTINCT ip FROM wc_online;");
$online = $result->num_rows() ? $result->num_rows() : "0";
$start = date("d ", $core->start).$core->rusdate(date("m", $core->start), true).date(" Y г.", $core->start);
$last = date("d ", $core->update).$core->rusdate(date("m", $core->update), true).date(" Y г. в H:i", $core->update);
$result=$core->exec("SHOW TABLE STATUS;");
while($data=$result->fetch_array()) {
$rows += $data['Rows'];
$bytes += $data['Data_length'];
}
// Удаление этой строки противоречит лицензионному соглашению!
$page = "\n";
$page .= getInclude("template.htm");
$page = str_replace("{selbegin}", $core->get_date("b", $core->begin), $page);
$page = str_replace("{selend}", $core->get_date("e", $core->end), $page);
$page = str_replace("{seltype}", $core->get_type(), $page);
$page = str_replace("{calendar}", calendar(), $page);
$page = str_replace("{begin}", $core->begin, $page);
$page = str_replace("{end}", $core->end, $page);
$page = str_replace("{type}", $core->type, $page);
$page = str_replace("{type_gr}", $core->type_gr, $page);
$page = str_replace("{header}", $core->header, $page);
$page = str_replace("{content}", $core->html_data, $page);
$page = str_replace("{pages}", $core->pages, $page);
$page = str_replace("{version}", $core->version.$core->version_type, $page);
$page = str_replace("{online}", $online, $page);
$page = str_replace("{start}", $start, $page);
$page = str_replace("{last}", $last, $page);
$page = str_replace("{rows}", number_format($rows, 0, '.', ' '), $page);
$page = str_replace("{bytes}", get_size($bytes), $page);
echo $page;
exit;
function calendar() {
global $core;
$month = date("m", $core->end_date);
$year = date("Y", $core->end_date);
$day = date("d", $core->end_date);
$tmpd = getdate(mktime( 0,0,0,$month,1,$year ));
$firstwday= $tmpd["wday"];
$lastday = lastday($month, $year);
if (!$firstwday) { $firstwday=7; }
$kn1 = (($month-1)<1) ? 12 : $month-1;
$kn2 = (($month-1)<1) ? $year-1 : $year;
$kn3 = ((($month-1)<1) ? $year-1 : $year)-1;
$kn4 = ((($month+1)>12) ? $year+1 : $year)+1;
$kn5 = (($month+1)>12) ? 1 : $month+1;
$kn6 = (($month+1)>12) ? $year+1 : $year;
$kn7 = $month + 0;
$nadp = $core->rusdate($month, false)." ".$year;
$html .= '
|
Пн |
Вт | Ср |
Чт | Пт |
Сб | Вс |
';
$d = 1;
$wday = $firstwday;
$firstweek = true;
while ($d <= $lastday) {
if ($firstweek) {
$html .= '' ;
for ($i=2; $i <= $firstwday; $i++) $html .= ' | ';
$firstweek = false;
}
if ($wday == 1) $html .= '
' ;
//$bgcolor = 'class="oddrow"';
$time_begin = mktime(0, 0, 0, $month, $d, $year) ;
$time_end = mktime(23, 59, 59, $month, $d, $year) ;
if ( ($wday == 0) || ($wday == 6) || ($wday == 7) || ($day == $d)) { $bgcolor = 'style="font-weight: bold;"'; } else { $bgcolor = ''; }
$now_timestamp = strtotime("$month/$d/$year");
if ( $now_timestamp <= time() && $now_timestamp >= $core->start) {
$html .= ''.$d.' | ' ;
} else {
$html .= ''.$d.' | ' ;
}
if ($wday == 0) $html .= '
' ;
$wday++;
$wday = $wday % 7;
$d++;
}
$html .= '
';
return $html;
}
function lastday($mon, $year) {
for ($tday=28; $tday <= 31; $tday++) {
$tdate = getdate( mktime( 0, 0, 0, $mon, $tday, $year ) ) ;
if ( $tdate["mon"] != $mon ) { break; }
}
$tday-- ;
return $tday ;
}
function getInclude($name) {
$file="./template/".$name;
$fp=@fopen($file, "r");
$content=@fread($fp, filesize($file));
@fclose($fp);
if (!$content) {
$content="[Ошибка] Ошибка открытия файла $file.";
}
return $content;
}
function get_size($filesize) {
$kilobyte = 1024;
$megabyte = 1048576;
$gigabyte = 1073741824;
$terabyte = 1099511627776;
if ($filesize >= $terabyte) { return number_format($filesize/$terabyte, 2, ',', '.')." Тб."; }
elseif ($filesize >= $gigabyte) { return number_format($filesize/$gigabyte, 2, ',', '.')." Гб."; }
elseif ($filesize >= $megabyte) { return number_format($filesize/$megabyte, 2, ',', '.')." Мб."; }
elseif ($filesize >= $kilobyte) { return number_format($filesize/$kilobyte, 2, ',', '.')." Кб."; }
else { return number_format($filesize, 0, ',', '.')." б."; }
}
?>