<?php
define('NTOP', 1);
$title = 'Топ рейтинг сайтов';
require_once ('system/connect.php');
require_once ('system/core.php');
require_once ('system/function.php');
require_once ('str/head.php');

if($_COOKIE['version'] == 'web'){
echo '<table class="stata"><tr>
                	<th class="left0 top0">#</th>
                	<th class="top0">Сайты из категории Top-100</th>
                	<th class="top0">Хосты</th>
                	<th class="top0">Хиты</th>
                            <th class="top0">В топ</th>
                	<th class="top0">Из</th>
                	<th class="right0 top0">?</th></tr>';
$all = mysql_num_rows(mysql_query("SELECT * FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `of_hosts` > '0' AND `category` != '19'"));
if($all != 0){
$total = intval(($all-1)/20)+1;
$page = abs(intval($_GET['page']));
if($id or $id >= 1){
$result = mysql_query("SELECT `hosts` FROM `".$prefix."sait` WHERE `id` = '".$id."' AND `status` = '1' AND `ban` = '0' AND `of_hosts` > '0' AND `category` != '19' LIMIT 1;");
$row = mysql_fetch_array($result);
$host_today = $row['hosts'];
$topt = mysql_num_rows(mysql_query("SELECT * FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `category` != '19' AND `of_hosts`>= '".$host_today."' ORDER BY `hosts` DESC;"));
$page = ceil($topt/20);
}
if(empty($page) OR $page <= 0){
$page = 1;
}
if($page > $total){
$page = $total;
}
$past=intval($all/20);
$start=$page*20-20;
$top = mysql_query("SELECT * FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `of_hosts` > '0' AND `category` != '19' ORDER BY `hosts` DESC LIMIT ".$start.",20");
while($row = mysql_fetch_array($top)){
$start++;
echo '<tr class="tr2"><td class="num bold left0">'.$start.'</td>';
if($row['id'] == $id){
echo'<td class="site"><a href="/out.php?id='.$row['id'].'"><font color="red">'.$row['url'].'</font></a>';
} else {
echo'<td class="site"><a href="/out.php?id='.$row['id'].'">'.$row['url'].'</a>';
}
echo'<br><small>'.$row['about'].'</small></td>
<td>'.stats($row['of_hosts']).'</td>
<td>'.stats($row['of_hits']).'</td>
<td>'.$row['of_in'].'</td>
<td>'.$row['of_out'].'</td>';
if($row['mem'] == 0){echo'<td class="more right0"><a href="/str/infos.php?id='.$row['id'].'"><img src="/images/s.gif" alt="?" /></a></td></tr>';
}else{echo'<td class="more right0"><img src="/images/d.gif" alt="?" /></td></tr>';}}
echo'</table>';
navigation($all,20,$page,'index.php?',$total);
} else {
echo '<div class="stat">Сайтов в топе пока нет!</div>';}

}else{

echo'<div class="topik">Top 100 | <b><a href="/str/cat.php">Категории</a></b></div>';
$all = mysql_num_rows(mysql_query("SELECT * FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `of_hosts` > '0' AND `category` != '19'"));
if($all != 0){
$total = intval(($all-1)/$page_top)+1;
$page = abs(intval($_GET['page']));
if($id or $id >= 1){
$result = mysql_query("SELECT `hosts` FROM `".$prefix."sait` WHERE `id` = '".$id."' AND `status` = '1' AND `ban` = '0' AND `of_hosts` > '0' AND `category` != '19' LIMIT 1;");
$row = mysql_fetch_array($result);
$host_today = $row['hosts'];
$topt = mysql_num_rows(mysql_query("SELECT * FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `category` != '19' AND `of_hosts`>= '".$host_today."' ORDER BY `hosts` DESC;"));
$page = ceil($topt/$page_top);
}
if(empty($page) OR $page <= 0){
$page = 1;
}
if($page > $total){
$page = $total;
}
$past=intval($all/$page_top);
$start=$page*$page_top-$page_top;
$top = mysql_query("SELECT * FROM `".$prefix."sait` WHERE `status` = '1' AND `ban` = '0' AND `of_hosts` > '0' AND `category` != '19' ORDER BY `hosts` DESC LIMIT ".$start.",".$page_top."");
while($row = mysql_fetch_array($top)){
if($row['id'] == $id){
$start++;
echo '<div class="ico"><b><font color="red"><div class="topni">'.$start.'. <a href="/out.php?id='.$row['id'].'"><span class="site"><b></font>'.$row['url'].'</b></b></span></a> <small><b>('.$row['of_hosts'].'/'.$row['of_hits'].'</b>';
//echo <b>($row['hits'] > 999 ? round($row['hits']/1000).'К' : $row['hits'])</b>;
if($row['mem'] == 0){
echo'<b>)</b></small> <a href="/str/infos.php?id='.$row['id'].'"><img src="/images/s.gif" alt="?"></a>';}else{echo'<b>)</b></small> <img src="/images/d.gif" alt="*"></div>';}
} else {
$start++;
echo '<div class="ico"><b><font color="red"><div class="topni">'.$start.'. <a href="/out.php?id='.$row['id'].'"><span class="site">'.$row['url'].'</b></font></span></a> <small><b>('.$row['of_hosts'].'/'.$row['of_hits'].'</b>';
//echo <b>($row['hits'] > 999 ? round($row['hits']/1000).'К' : $row['hits'])</b>;
if($row['mem'] == 0){
echo'<b>)</b></small> <a href="/str/infos.php?id='.$row['id'].'"><img src="/images/s.gif" alt="?"></a>';}else{echo'<b>)</b></small> <img src="/images/d.gif" alt="*">';}}
echo'<div class="info">'.$row['about'].'</div></div>';

echo '<div class="str">Ушло на сайт: <strong>'.$row['of_out'].'</strong><br/></div></div>';
}
echo'<div class="t"><a href="/index.php">За сегодня</a> | За вчера</div>';
navigation($all,$page_top,$page,'index2.php?',$total);
} else {
echo '<div class="stat">Сайтов в топе пока нет!</div>';}
echo'<div class="topik">';
if(!$user_data){echo'<a href="/str/enter.php">Войти</a> | <a href="/str/reg.php">Регистрация</a> | <a href="/str/statistika.php">Инфо</a><br>';}else{
echo'<a href="/str/office.php"><b>'.$user_data['login'].'</b></a> | <a href="/str/enter.php?act=exit">Выход</b></a> | <a href="/str/statistika.php">Инфо</a><br>';}
echo '</div>';
$l = mysql_query("SELECT * FROM `".$prefix."rek` WHERE `status` = '1' ORDER BY `id` DESC");
echo '<div class="rek"><img src="http://zipvap.ru/style/img/reklama.gif" alt="Реклама"/></img><br>';
echo'<a href="reklama.php">Свободное место 50р.</a><br/>';
while($rek = mysql_fetch_array($l)){
if(empty($rek['color']))echo '<a href="http://'.$rek['url'].'">'.$rek['name'].'</a><br>'; else echo '<a href="http://'.$rek['url'].'"><font color="'.$rek['color'].'">'.$rek['name'].'</font></a><br>';}
echo'</div>';

}
require_once ('str/foot.php');
?>