View file index.php

File size: 12.46Kb
<?php 
Error_Reporting(0);
/*include $_SERVER['DOCUMENT_ROOT'].'/stat/log.php';*/
$name_dir=date("d_m_y");
$store=($_SERVER['DOCUMENT_ROOT'].'/stat/data/days/'.$name_dir.'/counter.dat');
if (!file_exists($store)) 
{$hit=0; $host=0;}
else
{
$data=file($store);

$hit=count($data);
$ip_ua=array();

foreach ($data as $v) 
if
(!in_array($v,$ip_ua))
{$ip_ua[]=$v;} 
$host=count($ip_ua);
}
$vsego=25;
$file=file($_SERVER['DOCUMENT_ROOT'].'/stat/data/days/'.$name_dir.'/log.dat');
$script_version='v 1.0.1';
if(isset($_GET['stat']))
{$ver = $_GET['stat'];}
else
{$ver = "";}
if($ver != "today" && $ver != "days")
{$ver = "today";}
switch($ver)
{
case 'today' :
header("Content-type: text/html; charset=utf-8");
header("Cache-Control: no-cache");
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<title>Статистика посещений сайта '.$_SERVER['HTTP_HOST'].'</title></head>
<body bgcolor="#999999">
<font color="#ffffff">Статистика посещений сайта <font color="#ff0000"><b>'.$_SERVER['HTTP_HOST'].'</b></font></font>
<br/>Сегодня:
Хосты
[<font color="#ff0000">'.$host.'</font>]
Хиты
[<font color="#ff0000">'.$hit.'</font>]
<table width="100%" border="0" cellspacing="2" cellpadding="0" align="center" bgcolor="#000000">
<br/>';
if (!file_exists($_SERVER['DOCUMENT_ROOT'].'/stat/data/days/'.$name_dir.'/log.dat') or count($file)=='0')
{echo '<font color="#ff0000">Сегодня посещений нет.</font><br/>';}
else {
echo '<tr><td nowrap bgcolor="#dcdcdc">IP-Адрес</td><td nowrap bgcolor="#dcdcdc">Дата и время</td><td nowrap bgcolor="#dcdcdc">Браузер</td><td nowrap bgcolor="#dcdcdc">Посещенная страница</td><td nowrap bgcolor="#dcdcdc">Реферер</td></tr>';
if (empty($page))
{
$page=1;
}
$obsum=$page*$vsego;
$nasum=$obsum-$vsego;

for($i=$nasum; $i<$obsum; $i++)
{
if(isset($file[$i])) 
{
echo $file[$i]; //Вывод содержимого строки, в цикле
}
}
if (count($file)<=$i)
{
$endd=1;
}
$page_count=ceil(count($file)/$vsego);
if ($page==1 && $endd==1){echo '</table>';}else{
if ($page==1){}else{echo '</table><a href="?page='.($page-1).'">&lt;&lt;&lt; Назад</a>';}
if ($endd==1){echo '<br/>';}else{echo '</table><a href="?page='.($page+1).'">Далее &gt;&gt;&gt;</a><br/>';}
}}
echo '<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form action="?" method="get">(1-'.$page_count.')#<input name="page" type="text"  maxlength="4" size="5" value="'.($page+1).'">
<input type="submit" value="Перейти"></form></td>
<td><form action="?" method="get"><input type=hidden name="stat" value="days"><input type="submit" value="История посещений"></form></td>
<td><form action="/" method="get"><input type="submit" value="'.$_SERVER['HTTP_HOST'].'"></form></td>
<td><form action="http://lobok.org" method="get"><input type="submit" value="LoBoK.ORG"></form></td>
</tr>
</table><img src="http://wen.ru/i/s/26.gif" alt="©"/>'.$script_version.'</body></html>';
break;
case 'days' :
$dd=$_GET['dd'];
$mm=$_GET['mm'];
$yy=$_GET['yy'];
if (!isset($dd) or !isset($mm) or !isset($gg))
{
header("Content-type: text/html; charset=utf-8");
header("Cache-Control: no-cache");
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<title>Статистика по дням</title></head>
<body bgcolor="#999999">
<font color="#ffffff">История посещений сайта <font color="#ff0000"><b>'.$_SERVER['HTTP_HOST'].'</b></font></font>
<br/><font color="#ffffff">Выберите дату за которую хотите получить историю:</font><br/>';
echo '<form method="get" action="?">
<input type=hidden name="stat" value="days">
<table border="1" cellspacing="0" cellpadding="0" bgcolor="black">
<caption><div align="left">Выберите число</div></caption><tr bgcolor="black">
<td bgcolor="white">1</td>
<td bgcolor="white">2</td>
<td bgcolor="white">3</td>
<td bgcolor="white">4</td>
<td bgcolor="white">5</td>
<td bgcolor="white">6</td>
<td bgcolor="white">7</td>
<td bgcolor="white">8</td>
<td bgcolor="white">9</td>
<td bgcolor="white">10</td>
<td bgcolor="white">11</td>
<td bgcolor="white">12</td>
<td bgcolor="white">13</td>
<td bgcolor="white">14</td>
<td bgcolor="white">15</td>
<td bgcolor="white">16</td>
<td bgcolor="white">17</td>
<td bgcolor="white">18</td>
<td bgcolor="white">19</td>
<td bgcolor="white">20</td>
<td bgcolor="white">21</td>
<td bgcolor="white">22</td>
<td bgcolor="white">23</td>
<td bgcolor="white">24</td>
<td bgcolor="white">25</td>
<td bgcolor="white">26</td>
<td bgcolor="white">27</td>
<td bgcolor="white">28</td>
<td bgcolor="white">29</td>
<td bgcolor="white">30</td>
<td bgcolor="white">31</td>
</tr><tr>
<td bgcolor="white"><input type="radio" name="dd" value="01" checked></td>
<td bgcolor="white"><input type="radio" name="dd" value="02"></td>
<td bgcolor="white"><input type="radio" name="dd" value="03"></td>
<td bgcolor="white"><input type="radio" name="dd" value="04"></td>
<td bgcolor="white"><input type="radio" name="dd" value="05"></td>
<td bgcolor="white"><input type="radio" name="dd" value="06"></td>
<td bgcolor="white"><input type="radio" name="dd" value="07"></td>
<td bgcolor="white"><input type="radio" name="dd" value="08"></td>
<td bgcolor="white"><input type="radio" name="dd" value="09"></td>
<td bgcolor="white"><input type="radio" name="dd" value="10"></td>
<td bgcolor="white"><input type="radio" name="dd" value="11"></td>
<td bgcolor="white"><input type="radio" name="dd" value="12"></td>
<td bgcolor="white"><input type="radio" name="dd" value="13"></td>
<td bgcolor="white"><input type="radio" name="dd" value="14"></td>
<td bgcolor="white"><input type="radio" name="dd" value="15"></td>
<td bgcolor="white"><input type="radio" name="dd" value="16"></td>
<td bgcolor="white"><input type="radio" name="dd" value="17"></td>
<td bgcolor="white"><input type="radio" name="dd" value="18"></td>
<td bgcolor="white"><input type="radio" name="dd" value="19"></td>
<td bgcolor="white"><input type="radio" name="dd" value="20"></td>
<td bgcolor="white"><input type="radio" name="dd" value="21"></td>
<td bgcolor="white"><input type="radio" name="dd" value="22"></td>
<td bgcolor="white"><input type="radio" name="dd" value="23"></td>
<td bgcolor="white"><input type="radio" name="dd" value="24"></td>
<td bgcolor="white"><input type="radio" name="dd" value="25"></td>
<td bgcolor="white"><input type="radio" name="dd" value="26"></td>
<td bgcolor="white"><input type="radio" name="dd" value="27"></td>
<td bgcolor="white"><input type="radio" name="dd" value="28"></td>
<td bgcolor="white"><input type="radio" name="dd" value="29"></td>
<td bgcolor="white"><input type="radio" name="dd" value="30"></td>
<td bgcolor="white"><input type="radio" name="dd" value="31"></td>
</tr>
</table><table border="1" cellspacing="0" cellpadding="0" bgcolor="black" >
<caption><div align="left">
Выберите месяц</div></caption><tr>
<td bgcolor="white">1</td>
<td bgcolor="white">2</td>
<td bgcolor="white">3</td>
<td bgcolor="white">4</td>
<td bgcolor="white">5</td>
<td bgcolor="white">6</td>
<td bgcolor="white">7</td>
<td bgcolor="white">8</td>
<td bgcolor="white">9</td>
<td bgcolor="white">10</td>
<td bgcolor="white">11</td>
<td bgcolor="white">12</td>
</tr><tr>
<td bgcolor="white"><input type="radio" name="mm" value="01" checked></td>
<td bgcolor="white"><input type="radio" name="mm" value="02"></td>
<td bgcolor="white"><input type="radio" name="mm" value="03"></td>
<td bgcolor="white"><input type="radio" name="mm" value="04"></td>
<td bgcolor="white"><input type="radio" name="mm" value="05"></td>
<td bgcolor="white"><input type="radio" name="mm" value="06"></td>
<td bgcolor="white"><input type="radio" name="mm" value="07"></td>
<td bgcolor="white"><input type="radio" name="mm" value="08"></td>
<td bgcolor="white"><input type="radio" name="mm" value="09"></td>
<td bgcolor="white"><input type="radio" name="mm" value="10"></td>
<td bgcolor="white"><input type="radio" name="mm" value="11"></td>
<td bgcolor="white"><input type="radio" name="mm" value="12"></td>
</tr>
<table border="1" cellspacing="0" cellpadding="0" bgcolor="black"><caption>
<div align="left">Год</div></caption><tr>
<td bgcolor="white">'.date("Y").'</td>
<td bgcolor="white"><input type="radio" name="gg" value="'.date("y").'" checked></td>
</tr></table>
<input type="submit" value="Ок"></form>';
echo '<a href="?stat=today">Статистика за сегодня</a><br/><a href="/">'.$_SERVER['HTTP_HOST'].'</a><br/><img src="http://wen.ru/i/s/26.gif" alt="©"/>'.$script_version.'</body></html>';
}
else {
header("Content-type: text/html; charset=utf-8");
header("Cache-Control: no-cache");
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<title>Статистика по дням</title></head>
<body bgcolor="#999999">
<font color="#ffffff">История посещений сайта <font color="#ff0000"><b>'.$_SERVER['HTTP_HOST'].'</b></font></font>
<br/>';
$store=($_SERVER['DOCUMENT_ROOT'].'/stat/data/days/'.$dd.'_'.$mm.'_'.$gg.'/counter.dat');
$file=($_SERVER['DOCUMENT_ROOT'].'/stat/data/days/'.$dd.'_'.$mm.'_'.$gg.'/log.dat');
if (!file_exists($store) or !file_exists($file) or count($file)=='0') 
{echo '<font color="#ff0000">Извините, но за указаную дату "'.$dd.' '.$mm.' '.$gg.'" история не сохранилась.</font>
<table border="0" cellspacing="0" cellpadding="0">
<tr><td><form action="?" method="get"><input type=hidden name="stat" value="days"><input type="submit" value="История посещений"></form></td>
<td><form action="/" method="get"><input type="submit" value="'.$_SERVER['HTTP_HOST'].'"></form></td>
<td><form action="http://lobok.org" method="get"><input type="submit" value="LoBoK.ORG"></form></td>
</tr>
</table><img src="http://wen.ru/i/s/26.gif" alt="©"/>'.$script_version.'</body></html>
</body></html>';}
else {echo '<font color="#ff0000">'.$dd.' '.$mm.' '.$gg.'</font> было:';
$data=file($store);
$hit=count($data);
$ip_ua=array();
foreach ($data as $v) 
if
(!in_array($v,$ip_ua))
{$ip_ua[]=$v;} 
$host=count($ip_ua);
echo 'Хостов
[<font color="#ff0000">'.$host.'</font>]
Хитов
[<font color="#ff0000">'.$hit.'</font>]<table width="100%" border="0" cellspacing="2" cellpadding="0" align="center" bgcolor="#000000">
<tr><td nowrap bgcolor="#dcdcdc">IP-Адрес</td><td nowrap bgcolor="#dcdcdc">Дата и время</td><td nowrap bgcolor="#dcdcdc">Браузер</td><td nowrap bgcolor="#dcdcdc">Посещенная страница</td><td nowrap bgcolor="#dcdcdc">Реферер</td></tr>';
$file=file($_SERVER['DOCUMENT_ROOT'].'/stat/data/days/'.$dd.'_'.$mm.'_'.$gg.'/log.dat');
$listing=$_GET['listing'];
if (empty($listing))
{
$listing=1;
}
$obsum=$listing*$vsego;
$nasum=$obsum-$vsego;

for($i=$nasum; $i<$obsum; $i++)
{
if(isset($file[$i])) 
{
echo $file[$i]; //Вывод содержимого строки, в цикле
}
}
if (count($file)<=$i)
{
$endd=1;
}
$listing_count=ceil(count($file)/$vsego);
if ($listing==1 && $endd==1){echo '</table>';}else{
if ($listing==1){}else{echo '</table><a href="?stat=days&amp;dd='.$dd.'&amp;mm='.$mm.'&amp;gg='.$gg.'&amp;listing='.($listing-1).'">&lt;&lt;&lt; Назад</a>';}
if ($endd==1){echo '<br/>';}else{echo '</table><a href="?stat=days&amp;dd='.$dd.'&amp;mm='.$mm.'&amp;gg='.$gg.'&amp;listing='.($listing+1).'">Далее &gt;&gt;&gt;</a><br/>';}
}
echo '<table border="0" cellspacing="0" cellpadding="0"><tr><td><form action="?" method="get">(1-'.$listing_count.')#<input name="listing" type="text"  maxlength="4" size="5" value="'.($listing+1).'">
<input type=hidden name="stat" value="days">
<input type=hidden name="dd" value="'.$dd.'">
<input type=hidden name="mm" value="'.$mm.'">
<input type=hidden name="gg" value="'.$gg.'">
<input type="submit" value="Перейти"></form></td>
<td><form action="?" method="get"><input type=hidden name="stat" value="days"><input type="submit" value="История посещений"></form></td>
<td><form action="/" method="get"><input type="submit" value="'.$_SERVER['HTTP_HOST'].'"></form></td>
<td><form action="http://lobok.org" method="get"><input type="submit" value="LoBoK.ORG"></form></td>
</tr>
</table><img src="http://wen.ru/i/s/26.gif" alt="©"/>'.$script_version.'</body></html>
</body></html>';
}
}
break;
}
?>