File size: 3.37Kb
<?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';");
$count = @mysql_query("select `category`,`from`,`in` from `users` where `id`='$id' and `activ`='yes';");
$its = @mysql_fetch_array($count);
if (@mysql_num_rows($rf) == 0)
{
//Если сайт неактивен то не захламляем логи
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';");
}
$fs = $its['from'];
$n = $its['category'];
}
if (empty($n))
{
print "<meta http-equiv='refresh' content='2;URL=index.php'/>";
print "<font color=\"#FF0000\">Такого сайта нет в каталоге!<br/></font>";
}
else
{
$cname = @mysql_query("select `name` from `categories` where `id`='$n' limit 1;");
$ctnames = @mysql_fetch_array($cname);
$lst = @mysql_query("select `id` from `users` where `category`='$n' and `activ`='yes';");
$all = @mysql_num_rows($lst);
print "<div class=b>";
print "<b>>".$ctnames['name']."($all)</b>";
print "</div>";
if (!empty($id))
{
$qs = @mysql_query("select `id` from `users` where `from`>'$fs' and `activ`='yes';");
$high = @mysql_num_rows($qs);
$highst = $high/10;
$s = floor($highst);
}
$pg = $s*10;
$num = $pg;
$sites = @mysql_query("select `url`, `sname`, `about`, `from`, `in` from `users` where `category`='$n' and `activ`='yes' order by `from` desc limit $pg,10;");
print "<div align=\"left\">";
if(@mysql_num_rows($sites) == 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>";
}
$s = $s+1;
$p = $pg+10;
if ($pg = 0)
{
$p = 10;
}
if ($all > $p){
print "<a href=\"category.php?n=$n&s=$s\">След.</a><br/>";
}
if ($s != 1)
{
$s = $s - 2;
print "<a href=\"category.php?n=$n&s=$s\">Пред.</a><br/>";
}
$str = floor($all/10);
if ($str > 1)
print "<form method=\"post\" action=\"category.php?n=$n\">Перейти к странице(0-$str):<br><input name=\"s\" maxlength=\"3\" size=\"5\" value=\"\"><input value=\">>\" name=\"go\" type=\"submit\"></form>";
print "<a href=\"registration.php?cat=$n\">Регистрация</a><br/>";
print "<a href=\"index.php\">К категориям</a>";
}
include "foot.php";
print "</div>";
echo "</body></html>";
?>