Файл: PROFIWM.COM/top/newsites.php
Строк: 140
<?php
// by -=ШАХТЕР=- (waphp.ru - качай только тут)
include 'config.php';
//---------------------------------------------------------------
//---------------------------------------------------------------
$title = 'ТОП-100';
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."<a href="categories.php">Категории</a> | <a href="index.php">ТОП-100</a> | <b>Новые сайты</b> | <a href="ban.php">Заблокированные</a></div>";
// проверка ввода page
if (empty($_GET['p']))$page = 1;
else if ($_GET['p']<1)$page = 1;
else $page=check($_GET['p']);
////////////////////////
//проверка ввода id
$uid = $_SERVER['QUERY_STRING'];
//list($uid, $size) = explode(",", $data);
$uid = check(intval($uid));
if (!empty($uid))
{
// проверка существования учетной записи
$result = mysql_query("SELECT site_name,link,admin,info FROM top_users WHERE uid=$uid");
$row=mysql_fetch_array($result);
if (!empty($row))
{
//====================== пришло
$week_day = date("w");
$today = date("Ymd");
// подсчет
$result = mysql_query("SELECT `in` FROM `weeks` WHERE `date`=$today AND `status`='new' AND `uid`=$uid LIMIT 1");
$row=mysql_fetch_array($result);
if (empty($row))
{
$dayNext =$week_day + 7;
if ($dayNext > 7)
{
$dayNext-=7;
}
$cntDay=8-$dayNext;
$nextMonday=date("Ymd",mktime(0,0,0,date("m"),date("d")+$cntDay));
@mysql_query("INSERT INTO weeks VALUES ('',$uid,$razd,$nextMonday,$today,$week_day,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'new')");
$in_count = 0;
}
else
{
$in_count = $row['in'];
}
$in_count++;
// сохранение
@mysql_query("UPDATE `weeks` SET `in`=$in_count WHERE `date`=$today AND `status`='new' AND `uid`=$uid LIMIT 1");
$today = date("Ymd");
$hour = date("H");
// за сегодня
$result=mysql_query("SELECT `host` FROM `weeks` WHERE `uid`=$uid AND `date`=$today AND `status`='new' LIMIT 1;");
$row = mysql_fetch_array($result);
$host_today = $row['host'];
//----------------------- Место в топе---------------------------
$result=mysql_query("SELECT * FROM `weeks` WHERE `host` >= $host_today AND `status`='new' AND `date`=$today ORDER BY `host` DESC;");
$top_place = mysql_num_rows($result);
$page=ceil($top_place/$count_top);
if ($page <= 0) $page = 1;
}
}
// ------------------------------ ТОП всех участников -------------------------------
$today = date("Ymd");
// получаем кол во участников
$result = mysql_query("SELECT count(`uid`) FROM `weeks` WHERE `host` > 0 AND `status`='new' and `date`=$today");
$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 `status`='new' ORDER BY host DESC LIMIT $start,$end");
$count_users_on_page = mysql_num_rows($result);
if ($count_users_on_page==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 FROM top_users WHERE uid=$uid");
$user_data_row = mysql_fetch_array($user_data);
$site_names = esc2($user_data_row['site_name']);
$link = esc2($user_data_row['link']);
$info = esc2($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>'.$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/p1.png" alt="" /> $link<br />";
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="newsites.php?p=".($page-1)."">пред.</a> | ";
echo "стр.<b>$page</b> из ".$max_page;
if ($max_page-$page>0)
echo " | <a href="newsites.php?p=".($page+1)."">след.</a> <img src="img/next.gif" alt="-" />";
echo "<br>";
$in=-3;
$out=3;
if ($page!=1)
{
echo "<a href="newsites.php?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="newsites.php?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="newsites.php?p=$max_page">$max_page</a>";
}
elseif ($max_page>1)
{
echo " <b>$max_page</b>";
}
echo "</div>";
//////////////////////////
}
echo "".$div1."";
echo '<a href="statistika.php">Статистика рейтинга</a><br />';
echo '<a href="search.php">Поиск</a><br />';
echo "</div>";
echo ''.$div4.'<a href="'.$rating_url.'index.php">'.$site_name.'</a><img src="img/gt.gif" alt=">" />TOP</div>';
include "foot_code.php";
?>