Файл: PROFIWM.COM/top/category.php
Строк: 115
<?php
// by -=ШАХТЕР=- (waphp.ru - качай только тут)
include 'config.php';
//---------------------------------------------------------------
//---------------------------------------------------------------
$title='Категория';
include_once 'head.php';
if (!isset($user_id)){echo "".$div1."<a href="/in.php">Войти</a> | <a href="/reg.php">Регистрация</a></div>";
}else{echo "".$div1."<a href="admin.php">Личный кабинет</a></div>";}
echo "".$div4."<b>Категория</b> | <a href="index.php">ТОП-100</a></div>";
//проверка ввода page
if (empty($_GET['p']))
{
$page = 1;
}
elseif ($_GET['p']<1)
{
$page = 1;
}
else
$page=check($_GET['p']);
//проверка ввода razd
if (empty($_GET['id']))
{
$razd = 1;
}
elseif ($_GET['id']<1)
{
$razd = 1;
}
else
$razd=check(intval($_GET['id']));
if (!preg_match("!^[0-9]+$!i",$razd))
{
echo "".$div4."";
echo "<b>Ошибка!</b>";
echo "</div>";
print ''.$div4.'<a href="'.$rating_url.'index.php">'.$site_name.'</a><img src="img/gt.gif" alt=">" />Категория</div>';
include "foot_code.php";
exit;
}
// ------------------------------ ТОП всех участников -------------------------------
$today = date("Ymd");
// получаем кол во участников
$result = mysql_query("SELECT count(`uid`) FROM `weeks` WHERE `host` > 0 and `date`=$today and `razdel`=$razd");
$cntData = mysql_fetch_row($result);
$count_users = $cntData[0];
$max_page = ceil ($count_users / $count_top);
$page = ($page > $max_page) ? (($max_page == 0)? $page : $max_page) : $page;
$start = $count_top*($page-1);
$end = $count_top;
// получаем uid участников
$result=mysql_query("SELECT DISTINCT `uid`,`count`,`host`,`in`,`out` FROM weeks WHERE host > 0 and date=$today and razdel=$razd ORDER BY host DESC LIMIT $start,$end");
$count_users_on_page = mysql_num_rows($result);
$razdel_data = mysql_query("SELECT name FROM razdels WHERE id=$razd");
$razdel_data_row = mysql_fetch_array($razdel_data);
$razdel = base64_decode($razdel_data_row['name']);
if ($razdel_data_row==0)
{
echo "".$div4."";
echo "<b>Ошибка!</b>";
echo "</div>";
print ''.$div4.'<a href="'.$rating_url.'index.php">'.$site_name.'</a><img src="img/gt.gif" alt=">" />Категория</div>';
include "foot_code.php";
exit;
}
// заголовок
echo "".$div4."";
echo "<a href="categories.php">Категории</a> » $razdel";
echo'</div>';
// вывод инфы
if ($count_users==0)
{
echo "Нет сайтов";
}
else
{
for($i = 0;$i < $count_users_on_page;$i++)
{
$row = mysql_fetch_array($result);
$uid = $row['uid'];
$hits = $row['count'];
$hosts = $row['host'];
// данные участника
$user_data = mysql_query("SELECT site_name,link,info,razdel FROM top_users WHERE uid=$uid");
$user_data_row = mysql_fetch_array($user_data);
$site_names = htmlspecialchars($user_data_row['site_name']);
$link = htmlspecialchars($user_data_row['link']);
$info = htmlspecialchars($user_data_row['info']);
// -----------------------Всего---------------------------
$res_count = mysql_query("SELECT sum(count),sum(host) FROM months WHERE uid=$uid");
$count_row=mysql_fetch_row($res_count);
$all_hits = (int)$count_row[0];
$all_hosts = (int)$count_row[1];
// -----------------------подсчитываем онлайн посетителей-----------------------
$res_count = mysql_query("SELECT count(ip) FROM online_ip WHERE uid=$uid");
$count_row=mysql_fetch_row($res_count);
$online=(int)$count_row[0];
// -----------------------Пришло Ушло---------------------------
$in_count = (int)$row['in'];
$out_count = (int)$row['out'];
echo '<dl></dl>';
echo "$div2";
if ((($i+1)+($count_top*($page-1)))==1)echo '<img src="img/medal1.gif" alt="gold" /> ';
else if ((($i+1)+($count_top*($page-1)))==2)echo '<img src="img/medal2.gif" alt="silver" /> ';
else if ((($i+1)+($count_top*($page-1)))==3)echo '<img src="img/medal3.gif" alt="bronze" /> ';
echo "<a href="go.php?$uid">".(($i+1)+($count_top*($page-1))).". $site_names</a>";
echo "</div>";
echo "<img src="img/gt.gif" alt="" /> $info<br/>";
echo "<img src="img/online.gif" alt="" /> On-line: <a href="online_tel.php?uid=$uid">$online</a><br/>";
echo "<img src="img/stat.gif" alt="" /> <a href="stat.php?uid=$uid">Статистика</a><br/>";
echo "Xосты: $hosts | Xиты: $hits |<br/>";
echo "Из топа: $out_count | В топ: $in_count<br/>";
}
}
// постраничная навигация
echo "<div class="navi" align="center">";
if ($page>1)
echo "<img src="img/back.gif" alt="-" /> <a href="category.php?id=$razd&p=".($page-1)."">пред.</a> | ";
echo "стр.<b>$page</b> из ".$max_page;
if ($max_page-$page>0)
echo " | <a href="category.php?id=$razd&p=".($page+1)."">след.</a> <img src="img/next.gif" alt="-" />";
echo "<br>";
$in=-3;
$out=3;
if ($page!=1)
{
echo "<a href="category.php?id=$razd&p=1">1</a>";
}
else
{
echo "<b>1</b>";
}
for ($ot=$in; $ot<=$out; $ot++)
{
$t_str=$page+$ot;
if ($t_str>1 && $t_str<$max_page)
{
if ($in==$ot && $t_str>2)
{
echo " ... ";
}
if ($ot!=0)
{
echo " <a href="category.php?id=$razd&p=$t_str">$t_str</a>";
}
else
{
echo " <b>$t_str</b>";
}
if ($ot==$out && $t_str<$max_page-1)
{
echo " ... ";
}
}
}
if ($page!=$max_page)
{
echo " <a href="category.php?id=$razd&p=$max_page">$max_page</a>";
}
elseif ($max_page>1)
{
echo " <b>$max_page</b>";
}
echo "</div>";
//////////////////////////
print ''.$div4.'<a href="'.$rating_url.'index.php">'.$site_name.'</a><img src="img/gt.gif" alt=">" />'.$razdel.'</div>';
include "foot_code.php";
?>