<?php

echo '<div class="rek"><img src="/style/img/ind4.png" alt="*"/> <a href="/billing/rekl" class = "cvetss">Купить рекламу за 1 wmr в сутки</a><br />';
$rekl_k= Core::count("SELECT COUNT(*) FROM `rekl` where `date_last`>'".time()."'");
if($rekl_k){
	$reklam = Core::query("SELECT * FROM `rekl` where `date_last`>'".time()."' ORDER BY RAND() DESC LIMIT 5");
 while ($rekl = $reklam -> fetch())
        {	
        if($rekl['color']==null){$name=$rekl['name'];}else{$name='<font color="'.$rekl['color'].'">'.$rekl['name'].'</font>';}
       if($rekl['bold']==1){$nam='<b>'.$name.'</b>';}else{$nam=$name;}
       echo '<img src="/style/img/ind4.png" alt="*"/> <a href='.$rekl['url'].' class = "cvetss">'.$nam.'</a><br/>';
               }

}  
echo '<img src="/style/img/ind4.png" alt="*"/> <a href="http://skywap.org" class = "cvetss">Эксклюзивный портал!</a><br />';
echo '</div>';

$news_k= Core::count("SELECT COUNT(*) FROM `news`");
if($news_k){
	$qq = Core::query("SELECT * FROM `news` ORDER BY `time` DESC LIMIT 1");
 while ($news = $qq -> fetch())
        {	
echo '<div class="rr"><span class = "t100"><b>'.$news['name'].'</b></span></div></br><div class="obv">'.Protect::text(Protect::rez_text($news['text'], 100)).'</br><a href=/news/ad/'.$news['id'].'>Подробнее...</a></div>';
 }
}
echo '<div class="rr"><span class = "t100">Рейтинг | <a href="/category">Категории</a></span></div><div class="rr2"></div>';
$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` = ?", [$post['category']]) -> fetch();
		echo '<div class="topstat"><table style="width:100%" cellspacing="0" cellpadding="0"><tr>';

		echo '<td style="vertical-align:center;width:10%;"><span class = "st">'.$num.'</span></td><td style="vertical-align:top;width:80%;padding: 5px;"> ';
		
		if(isset($_GET['id_s'])){
                if($_GET['id_s']==$post['id']){
		echo '<a target="_blank" href=http://rustats.su/out?get='.$post['id'].'><font color="red">'.Protect::title($post['title']).'</font></a> ['.$post['host'].' | '.$post['hit'].']  <a href="/stat/index/'.$post['id'].'"><div style="float:right;"><img src="/style/img/rat.png"></a></div><br/>		
		'.substr($post['opis'],0,120).'...
		</div>';
}else{
		echo '<a target="_blank" href=http://rustats.su/out?get='.$post['id'].'>'.Protect::title($post['title']).'</a>['.$post['host'].' | '.$post['hit'].']  <a href="/stat/index/'.$post['id'].'"><div style="float:right;"><img src="/style/img/rat.png"></a></div><br/>		
		'.substr($post['opis'],0,120).'...
		</div>';
}}else{
                echo '<a target="_blank" href=http://rustats.su/out?get='.$post['id'].'>'.Protect::title($post['title']).'</a>['.$post['host'].' | '.$post['hit'].']   <a href="/stat/index/'.$post['id'].'"><div style="float:right;"><img src="/style/img/rat.png"></a></div><br/>		
		'.substr($post['opis'],0,120).'...
		</div>';
}
				$num = ++$num;
	
echo'</td></tr></table></div>';}
echo'<div class="pls"></div>';
	 $Navig -> str('?');
}else{
	echo '<div class="navig">Активных сайтов не найдено</div>';
}

?>