<?php
#-----------------------------------------------------#
#          ********* WAP-MOTORS *********             #
#             Made by   :  VANTUZ                     #
#               E-mail  :  visavi.net@mail.ru         #
#                 Site  :  http://pizdec.ru           #
#             WAP-Site  :  http://visavi.net          #
#                  ICQ  :  36-44-66                   #
#  Вы не имеете право вносить изменения в код скрипта #
#-----------------------------------------------------#	
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/isset.php";

$hour=(int)date("H",$sitetime);
$hday=date("j",$sitetime)-1;
//-------------------- Вывод статистики ------------------------------//
if(!isset($action)) {
echo'<img src="../images/img/partners.gif" alt=""> <b>Количество посещений</b><br><br>';
$pstr = file_get_contents(BASEDIR."local/online.dat");
$pcounter_guest = substr_count($pstr,"##");
$pbans=BASEDIR."local/online.dat";
$plines=file($pbans);
$pcounter_online=count($plines);
$pcounter_reg=$pcounter_online-$pcounter_guest;

$pcount=file(BASEDIR."local/datacounter/host.dat");
$pcount =explode("#",$pcount[0]);
$pcounter_host=$pcount[1];
$pcounter_all=$pcount[2];
$pcounter_hourhost=$pcount[4];

$phcount=file(BASEDIR."local/datacounter/hits.dat");
$phcount =explode("#",$phcount[0]);
$pcounter_hits=$phcount[1];
$pcounter_allhits=$phcount[2];
$pcounter_hourhits=$phcount[4];



$p24_host=file(BASEDIR."local/datacounter/24_host.dat");
$p24_host =explode("|",$p24_host[0]);

foreach($p24_host as $k){
$p24datadays = explode("-",$k);
$p24_allhost+=$p24datadays[1];
}


$p24_hits=file(BASEDIR."local/datacounter/24_hits.dat");
$p24_hits =explode("|",$p24_hits[0]);

foreach($p24_hits as $k){
$p24datadays = explode("-",$k);
$p24_allhits+=$p24datadays[1];
}

$p31_host=file(BASEDIR."local/datacounter/31_host.dat");
$p31_host =explode("|",$p31_host[0]);

foreach($p31_host as $k){
$p31datadays = explode("-",$k);
$p31_allhost+=$p31datadays[1];
}

$p31_hits=file(BASEDIR."local/datacounter/31_hits.dat");
$p31_hits =explode("|",$p31_hits[0]);

foreach($p31_hits as $k){
$p31datadays = explode("-",$k);
$p31_allhits+=$p31datadays[1];
}

echo 'Всего посетителей на сайте: <b>'.(int)$pcounter_online.'</b><br>';
echo 'Всего авторизованных: <b>'.(int)$pcounter_reg.'</b><br>';
echo 'Всего гостей: <b>'.(int)$pcounter_guest.'</b><br><br>';

echo 'Хостов сегодня: <b>'.(int)$pcounter_host.'</b><br>';
echo 'Хитов сегодня: <b>'.(int)$pcounter_hits.'</b><br>';
echo 'Всего хостов: <b>'.(int)$pcounter_all.'</b><br>';
echo 'Всего хитов: <b>'.(int)$pcounter_allhits.'</b><br><br>';

echo 'Хостов за текущий час: <b>'.(int)$pcounter_hourhost.'</b><br>';
echo 'Хитов за текущий час: <b>'.(int)$pcounter_hourhits.'</b><br><br>';

echo 'Хостов за 24 часа: <b>'.(int)($p24_allhost+$pcounter_hourhost).'</b><br>';
echo 'Хитов за 24 часа: <b>'.(int)($p24_allhits+$pcounter_hourhits).'</b><br><br>';

echo 'Хостов за месяц: <b>'.(int)($p31_allhost+$pcounter_host).'</b><br>';
echo 'Хитов за месяц: <b>'.(int)($p31_allhits+$pcounter_hits).'</b><br><br>';

echo 'Динамика за сутки<br>';
echo '<img src="'.BASEDIR.'gallery/count24.php" alt=""><br><br>'; 

echo 'Динамика за месяц<br>';
echo '<img src="'.BASEDIR.'gallery/count31.php" alt=""><br><br>'; 

echo '<a href="counter.php?action=count24&amp;'.SID.'">Статистика по часам</a><br>';
echo '<a href="counter.php?action=count31&amp;'.SID.'">Статистика по дням </a><br>';
}

//------------------------ Статистика за 24 часа --------------------------------//
if($action=="count24") {
echo'<img src="../images/img/partners.gif" alt=""> <b>Статистика по часам</b><br><br>';

$p24_hits=file(BASEDIR."local/datacounter/24_hits.dat");
$p24_hits =explode("|",$p24_hits[0]);

$p24_host=file(BASEDIR."local/datacounter/24_host.dat");
$p24_host =explode("|",$p24_host[0]);


echo 'Динамика за сутки<br>';
echo '<img src="'.BASEDIR.'gallery/count24.php" alt=""><br><br>'; 

if($hour>0){
echo '<b>Хиты</b><br>';

for($i=0;$i<$hour;$i++){
$p24_hitshour = explode("-",$p24_hits[$i]);

$tekhour=(date("H:i",$p24_hitshour[0]));
$tekhour2=(date("H:i",$p24_hitshour[0]-3600));

if($tekhour!="" && $tekhour2!=""){
echo $tekhour2.'-'.$tekhour.' - <b>'.(int)$p24_hitshour[1].'</b> хитов<br>';
}}



echo '<br><b>Хосты</b><br>';

for($i=0;$i<$hour;$i++){
$p24_hosthour = explode("-",$p24_host[$i]);
$tekhour=(date("H:i",$p24_hosthour[0]));
$tekhour2=(date("H:i",$p24_hosthour[0]-3600));

if($tekhour!="" && $tekhour2!=""){
echo $tekhour2.'-'.$tekhour.' - <b>'.(int)$p24_hosthour[1].'</b> хостов<br>';
}}

}else{echo 'Статистика за текущие сутки еще не обновилась<br>';}

echo'<br><img src="../images/img/back.gif" alt=""> <a href="counter.php?'.SID.'">Вернуться</a>';
}


//------------------------ Статистика за месяц --------------------------------//
if($action=="count31") {
echo'<img src="../images/img/partners.gif" alt=""> <b>Статистика по дням</b><br><br>';

$p31_hits=file(BASEDIR."local/datacounter/31_hits.dat");
$p31_hits =explode("|",$p31_hits[0]);

$p31_host=file(BASEDIR."local/datacounter/31_host.dat");
$p31_host =explode("|",$p31_host[0]);


echo 'Динамика за месяц<br>';
echo '<img src="'.BASEDIR.'gallery/count31.php" alt=""><br><br>'; 

if($hday>0){
echo '<b>Хиты</b><br>';

for($i=0;$i<$hday;$i++){
$p31_hitshour = explode("-",$p31_hits[$i]);

$tekhour=(date("d.m",$p31_hitshour[0]));
$tekhour2=(date("d.m",$p31_hitshour[0]-86400));

if($tekhour!="" && $tekhour2!=""){
echo $tekhour2.'-'.$tekhour.' - <b>'.(int)$p31_hitshour[1].'</b> хитов<br>';
}}



echo '<br><b>Хосты</b><br>';

for($i=0;$i<$hday;$i++){
$p31_hosthour = explode("-",$p31_host[$i]);

$tekhour=(date("d.m",$p31_hosthour[0]));
$tekhour2=(date("d.m",$p31_hosthour[0]-86400));

if($tekhour!="" && $tekhour2!=""){
echo $tekhour2.'-'.$tekhour.' - <b>'.(int)$p31_hosthour[1].'</b> хостов<br>';
}}

}else{echo 'Статистика за текущий месяц еще не обновилась<br>';}

echo'<br><img src="../images/img/back.gif" alt=""> <a href="counter.php?'.SID.'">Вернуться</a>';
}



echo'<br><img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a><br>';
include_once"../themes/$config_themes/foot.php";
?>