Размер файла: 5.29Kb
<?php
Error_Reporting(0);
/////////////////////////////////////////////////////////////////////////
list($generic_msec,$generic_sec)=explode(chr('32'),microtime());/////////
$generic_time=$generic_sec+$generic_msec;////////////////////////////////
/////////////////////////////////////////////////////////////////////////
///-----------------------------------------Соединение с бд------------------------------------------------///
include '../connect.php';
///--------------------------------------------------------------------------------------------------------///
$path=$_SERVER['PHP_SELF'];
$folder=dirname($path);
if (isset($_GET['d']) and isset($_GET['m']) and isset($_GET['y']))
{
$dd=valid_number($_GET['d']);
$mm=valid_number($_GET['m']);
$yy=valid_number($_GET['y']);
$name_dir=$dd.'_'.$mm.'_'.$yy;
}
else
{
$dd=date("d");
$mm=date("m");
$yy=date("y");
$name_dir=date("d_m_y");
}
$p_c=25;////количество элементов на страницу
$file=@file('../data/days/'.$name_dir.'/log.dat');
$store=unserialize(trim(file_get_contents('../data/days/'.$name_dir.'/counter.dat')));
$hit=0;
foreach ($store as $k=>$v){$hit+=$store[$k]['hit'];}
if (!is_file('../data/days/'.$name_dir.'/counter.dat'))
{$host=0; $hit=0;}
else {$host=count($store);}
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="red">'.$dd.'.'.$mm.'.'.$yy.'</font>]
Хосты
[<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('../data/days/'.$name_dir.'/log.dat') or count($file)=='0')
{echo '<font color="#ff0000">Логи не установлены</font><br/>';}
else
{
echo '<tr><td nowrap bgcolor="#dcdcdc">Дата/время</td>
<td nowrap bgcolor="#dcdcdc">Браузер/Опсос/страна</td>
<td nowrap bgcolor="#dcdcdc">Посещенная страница</td>
<td nowrap bgcolor="#dcdcdc">Реферер</td></tr>';
foreach($file as $key=>$val)
{
$val=trim($val);
$f_arr=explode('|',$val);
$date=date('d/m/Y H:i:s',$f_arr[0]);
$req_ur=htmlspecialchars($f_arr[3]);
$ref=(empty($f_arr[4])) ? 'Отсутствует':htmlspecialchars($f_arr[4]);
if (empty($f_arr[5]))
{
$expl_brows=explode(' ',$f_arr[1]);
$tw_c=$expl_brows[0];
}
else {$tw_c=$f_arr[5];}
$long_ip=sprintf("%u", ip2long($f_arr[2]));
$res=mysql_query("SELECT *
FROM `operators`
WHERE `start`<'$long_ip'
AND `end`>'$long_ip'
LIMIT 1
");
if (!mysql_num_rows($res)){$tw_c.=" <b>($f_arr[2])</b>";}
else {
$arr_arr=mysql_fetch_assoc($res);
$tw_c.=' <b>('.$arr_arr['operator'].'|'.$arr_arr['country'].')</b>';
}
$arr[]='
<tr>
<td nowrap bgcolor="#dcdcdc">'.$date.'</td>
<td nowrap bgcolor="#dcdcdc">'.$tw_c.'</td>
<td nowrap bgcolor="#dcdcdc">'.$req_ur.'</td>
<td nowrap bgcolor="#dcdcdc">'.$ref.'</td>
</tr>
';
}
$page=valid_number($_GET['page']);
$c_arr=count($arr);
$total_p=ceil($c_arr/$p_c);///количество страниц
if ($page>($total_p-1)){$page='0';}
$first_record = $page*$p_c;
$last_record = @$first_record+$p_c;
for($i=@$first_record;$i<@$last_record;$i++)
{echo @$arr[$i];}
echo '</table>';
if ($page==0){echo '<a href="'.$folder.'/?page='.($page+1).'&d='.$dd.'&m='.$mm.'&y='.$yy.'">Далее>>></a><br>';}
elseif($page<($total_p-1)){echo '<a href="'.$folder.'/?page='.($page-1).'&d='.$dd.'&m='.$mm.'&y='.$yy.'"><<<Назад</a>|<a href="'.$folder.'/?page='.($page+1).'&d='.$dd.'&m='.$mm.'&y='.$yy.'">Далее>>></a><br>';}
elseif($page==($total_p-1)){echo '<a href="'.$folder.'/?page='.($page-1).'&d='.$dd.'&m='.$mm.'&y='.$yy.'"><<<Назад</a><br>';}
echo '<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form action="?" method="get">
(1-'.($total_p-1).')#<input name="page" type="text" maxlength="4" size="5" style="-wap-input-format:\'5N\'" value="'.($page+1).'">
<input type="hidden" name="d" value="'.$dd.'">
<input type="hidden" name="m" value="'.$mm.'">
<input type="hidden" name="y" value="'.$yy.'">
<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://wapbn.com/26.gif" alt="©"/>'.$script_version.'</body></html>';
}
///////////////////////////////////////////////////////////////////////////////
list($generic_newmsec,$generic_newsec)=explode(chr('32'),microtime());/////////
///////////////////////////////////////////////////////////////////////////////
echo '<!--'.round((($generic_newsec+$generic_newmsec)-$generic_time),'4').'-->';
?>