Просмотр файла top20.php

Размер файла: 2.09Kb
<?php
include "head.php";
include "inc.php";
include "config.php";
print "<div align=\"center\"><div class=a>";
print "$catalog";
print "</div><br/>";
$today = date("d-m-Y");
//Проверяем наличие логов на сегодня если нет то очищаем таблицы и ведем статистику снова
$rs = @mysql_query("select `cid` from `logs` where `day`='$today';");
	if (@mysql_num_rows($rs) == 0)
	{
	@mysql_query("truncate table `logs`;");
	@mysql_query("update `users` set `from`='0', `in`='0';");
	}

//Ведем статистику если был переход с сайта
if (!empty($id))
{
$ip = getenv(REMOTE_ADDR);
	$rf = @mysql_query("select `cid` from `logs` where `ip`='$ip' and `type`='in' and `day`='$today' and `cid`='$id';");
	if (@mysql_num_rows($rf) == 0)
	{
		$count = @mysql_query("select `in` from `users` where `id`='$id' and `activ`='yes';");
		$its = @mysql_fetch_array($count);
		//Если сайт неактивен то не захламляем логи
		if (@mysql_num_rows($count) !== 0)
		@mysql_query("insert into `logs` values(0,'$ip','in','$today','$id');");
		$new = $its['in']+1;
		@mysql_query("update `users` set `in`='$new' where `id`='$id' and `activ`='yes';");
	}
}

print "<div class=foot>";
print "<b>>Топ20</b>";
print "</div>";
$sites = @mysql_query("select `url`, `sname`, `about`, `from`, `in` from `users` where `activ`='yes' order by `from` desc limit 20;");
print "<div align=\"left\">";
if(mysql_affected_rows()==0)
print "<font color=\"#FF0000\">Категория пуста!<br/></font>";
while($sp = @mysql_fetch_array($sites))
{
    $num = $num+1;
	print "<b><a href=\"go.php?url=".$sp['url']."\">$num. ".$sp['sname']."</a></b><br/>";
	print "<small>".$sp['about']."</small><br/>";
	print "Из каталога: ".$sp['from'].", В каталог: ".$sp['in']."";
	print "<hr>";
}

print "<a href=\"registration.php\">Регистрация</a><br/>";
print "<a href=\"index.php\">К категориям</a>";
include "foot.php";
print "</div>";
echo "</body></html>";
?>