View file statday.php

File size: 2.23Kb
<?php

// выводим верх страницы
include 'verh.php';

echo "<div class=\"main_copyright\"><p align=\"center\"><b>Статистика по дням</b><br/></p>";
echo "</div><div class=\"b\">";
$limit=10;
$p=@intval($_GET['p']);
//cashe
	if(!file_exists("cashe.dat"))
	{
		$vs = mysql_query("SELECT COUNT(`date`) as `cn`,`date` FROM `inet_in` GROUP BY `date` ORDER BY `date` DESC");
		$write='';
		while($out=mysql_fetch_array($vs))$write.=$out['date']."::".mysql_result(mysql_query("SELECT COUNT(`date`) FROM `inet_out` WHERE `date`='".$out['date']."'"),0)."::".$out['cn']."\n";
		$fp=fopen("cashe.dat","w+");
		fwrite($fp,$write);
		fclose($fp);
		chmod("cashe.dat",0777);
	}
	else
	{
		$dt=file("cashe.dat");
		list($date,$out,$in)=explode("::",$dt[0]);
		if($date!=date("Y-m-d"))
		{
			$vs = mysql_query("SELECT COUNT(`date`) as `cn`,`date` FROM `inet_in` GROUP BY `date` ORDER BY `date` DESC");
			$write='';
			while($out=mysql_fetch_array($vs))$write.=$out['date']."::".mysql_result(mysql_query("SELECT COUNT(`date`) FROM `inet_out` WHERE `date`='".$out['date']."'"),0)."::".$out['cn']."\n";
			$fp=fopen("cashe.dat","w+");
			fwrite($fp,$write);
			fclose($fp);
			chmod("cashe.dat",0777);
		}
	}
	//cashe
echo "<div class=\"b\">Дата | Из каталога | В каталог</div><div class=\"b\">";
$data=file("cashe.dat");
$c=count($data);
$st=($p-$limt);
if($st<0)$st=0;
for($i=$st;$i<$p+$limit;$i++)
{
	if($i<$c)
	{
		list($date,$out,$in)=explode("::",$data[$i]);
		echo "$date | $out | ".intval($in)."<br/>";
	}
}
$next = $p+$limit;
$prev = $p-$limit;
if ($p>0)echo "<a href=\"statday.php?p=$prev\">Назад</a>";
if ($p+$limit<$c)echo " <a href=\"statday.php?p=$next\">Далее</a><br/>";
	echo "<div class=\"b\" align=\"center\">Категории:<br/>
<form action='top.php' method='get'><select name='category'>";
$cat=mysql_query("SELECT * FROM inet_category ORDER BY position ASC");
while($category = mysql_fetch_array($cat)) {
echo "<option value=\"".$category['id']."\">".$category['name']."</option>";
}
echo "</select><br/><input type='submit' value='Перейти'/></form>";

echo "</div><div class=\"b\">
&#187;<a href=\"index.php\">На главную</a><br/>";

// выводим низ страницы
include 'niz.php';

?>