<?php
echo '<div class="rek">';
$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 6");
 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 '<a href='.$rekl['url'].'>- '.$nam.'</a><br/>';
               }

}  
            echo '<a href=/billing/rekl>- Купить рекламу за '.Core::$config['rekl'].' wmr в сутки</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="gadget"><span><b>'.$news['name'].'</b></span><br/>
       '.Protect::text($news['text']).'<br/><br/>';
               echo '<center><a href=/news/ad/'.$news['id'].'><img src="/style/images/wap/ent.png"></a></center></div>';
 }
}
echo '<div class="retez">';
echo '<a href="/category" class="rate4">Рейтинг  <a href="/category" class="rate45">Категории</a>';
echo '</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` = ?", array($post['category'])) -> fetch();
		

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

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

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

?>