<?php
$all = Core::count("SELECT COUNT(*) FROM `user_sites` WHERE `ban` = '0' && `mod` = '0' && `host` > '0' && `category`!='27' ");
if($all > 0){
	$Navig = new Navig($all);
	$start = $Navig -> start;
	$pages = 10;
if(isset($_GET['p']) && $_GET['p']!=0){	
$num = $_GET['p']*$pages-($pages-1);
}else{
$num = 1 ;
}
	$q = Core::query("SELECT * FROM `user_sites` WHERE `ban` = '0' && `mod` = '0' && `host` > '0' && `category`!='27' ORDER BY `host` DESC LIMIT $start, $pages");
	while($post = $q -> fetch()){
		$cat = Core::query("SELECT `name` FROM `category` WHERE `id` = ?", array($post['category'])) -> fetch();
		

		echo '<div class="topni"><table style = "width: 640px;"><tr><td style = "width: 20px;"><span class="o4">'.$num.'</span></td>';
		
		if(isset($_GET['id_s'])){
                if($_GET['id_s']==$post['id']){
		echo '<td style = "width: 530px;"><a target="_blank" href=http://keotop.ru/out?get='.$post['id'].'><font color="red">'.Protect::title($post['title']).'</font></a> ['.$post['host'].'|'.$post['hit'].'] <br/> '.substr($post['opis'],0,120).'...</td><td style = "width: 90px;"><a href="/stat/index/'.$post['id'].'"><img src="style/images/stat.png" alt="?" class = "ico"></a></td></tr></table></div>';
}else{
		echo '<td style = "width: 530px;"><a target="_blank" href=http://keotop.ru/out?get='.$post['id'].'>'.Protect::title($post['title']).'</a> ['.$post['host'].'|'.$post['hit'].'] <br/> '.substr($post['opis'],0,120).'...</td><td style = "width: 90px;"><a href="/stat/index/'.$post['id'].'"><img src="style/images/stat.png" alt="?" class = "ico"></a></td></tr></table></div>';

}}else{
		echo '<td style = "width: 530px;"><a target="_blank" href=http://keotop.ru/out?get='.$post['id'].'>'.Protect::title($post['title']).'</a> ['.$post['host'].'|'.$post['hit'].'] <br/> '.substr($post['opis'],0,120).'...</td><td style = "width: 90px;"><a href="/stat/index/'.$post['id'].'"><img src="style/images/stat.png" alt="?" class = "ico"></a></td></tr></table></div>';

}
				$num = ++$num;
					}
	 $Navig -> str('?');
}else{
	echo '<div class="navig">Активных сайтов не найдено</div>';
}

?>