<?php
define('MTOP', 1);
require_once ('system/connect.php');
require_once ('system/core.php');
require_once ('system/function.php');
switch($act){
default:
$title = 'Категории';
require_once ('head.php');
echo '<div class="title2"><b>Категории</b></div>';
$gold = mysql_query('SELECT * FROM `sait` WHERE `status` = "1" AND `ban` = "0" AND `gold` > "'.time().'" ORDER BY RAND() LIMIT 2');
while($row=mysql_fetch_array($gold)){
echo '<div class="lt"><small><b><font color="#CE0025">G</font><font color="#8A006F">O</font><font color="#4600B9">L</font><font color="#2400DE">D</font></b></small> <a href="/out.php?id='.$row['id'].'" rel="nofollow"  target="_blank" title="Посетить wap сайт '.$row['url'].'"><b>'.$row['url'].'</b></a><br/>'.$row['about'].'<br/></div>';
}
$cats = mysql_query("SELECT * FROM `cat` ORDER BY `position`");
while($cat = mysql_fetch_array($cats)){
$count_sites = mysql_num_rows(mysql_query("SELECT * FROM `sait` WHERE `category` = '".$cat['id']."' AND `status` = '1' AND `hosts` > '0'"));

echo '<div class = "lt"><a href = "/m/category/view/'.$cat['id'].'"><img src="'.$HOME.'/images/arrow-point-to-right.png" alt="yamus">  '.$cat['name'].'</a> ('.$count_sites.')</div>';

}
break;

case 'view':
$isset = mysql_query("SELECT * FROM `cat` WHERE `id` = '".$id."'");
if(mysql_num_rows($isset) > 0){
$catt = mysql_fetch_array($isset);
$title = $catt['name'];
require_once ('head.php');
echo '<div class="title"><a href="/m/category">Категории</a> | '.$catt['name'].'</div>';
$gold = mysql_query('SELECT * FROM `sait` WHERE `status` = "1" AND `ban` = "0" AND `gold` > "'.time().'" ORDER BY RAND() LIMIT 2');
while($row=mysql_fetch_array($gold)){
echo '<div class="lt"><small><b><font color="#CE0025">G</font><font color="#8A006F">O</font><font color="#4600B9">L</font><font color="#2400DE">D</font></b></small> <a href="/out.php?id='.$row['id'].'" rel="nofollow"  target="_blank" title="Посетить wap сайт '.$row['url'].'"><b>'.$row['url'].'</b></a><br/>'.$row['about'].'<br/></div>';
}
$count = mysql_num_rows(mysql_query("SELECT * FROM `sait` WHERE `category` = '".$id."' AND `status` = '1' AND `hosts` > '0'"));
if($count > 0){
$total=intval(($count-1)/$page_sait)+1;
$page=abs(intval($_GET['page']));
if(empty($page) OR $page < 0) $page = 1;
if($page > $total) $page = $total;
$past=intval($count/$page_sait);
$start=$page*$page_sait-$page_sait;
$saits = mysql_query("SELECT * FROM `sait` WHERE `category` = '".$id."' AND `status` = '1' AND `ban` = '0' AND `hosts` > '0' ORDER BY `hosts` DESC LIMIT ".$start.",".$page_sait."");

while($row = mysql_fetch_array($saits)){
$start++;



if($row['id'] == $_GET['id_site']) {
$red = '<font color="red">'.$row['url'].'</font>';
} else {
$red = buildTextGradient($row['url'], array($row['n1'], $row['n2']));
}

echo '<table width="100%" cellpadding="5" cellspacing="0"  class="main"><tbody><tr>
                <td width="1%" style="padding: 9px;"><span class="mobile-icon">'.$start.'</span></td>
                <td width="89%" style="padding: 9px;"> <img src="https://ioav.ru/fv/'.$row['url'].'" alt="favicon"> <a href="/out.php?id='.$row['id'].'" rel="nofollow"  target="_blank" title="Посетить wap сайт '.$row['url'].'"><b>'.$red.'</b></span></a> <b> '.($row['category']==4 ? '<img src="'.$HOME.'/images/18.png" alt="*">':'') .'
				
				<span class="badge"><span class="hosts">'.$row['hosts'].'</span> <span class="hits">'.$row['hits'].'</span></span></b> <br>';
                if(mb_strlen($row['about']) > 65){
$text = mb_substr($row['about'], 0, 65, 'utf-8');
echo ''.$text.'..';
}else{
echo ''.$row['about'].'';
}
echo '</td>
                <td width="10%" style="padding: 0px;"> <a href="/stats/'.$row['id'].'"><img src="'.$HOME.'/images/ico-stat.png" alt="*" title="Статистика сайта"></a></td>
                
            </tr>
        </tbody></table>';	


}

navigation($count,$page_sait,$page,'cat.php?id='.$id.'&sort='.$sort.'&',$total);
}
else{
echo '<div class="main">В данной категории нет активных сайтов</div>';
}
}
else{
$title = 'Ошибка';
require_once ('head.php');
echo '<div class="title3">Ошибка</div>';
echo '<div class="title"><center>Данной категории не существует</center></div>';
}
break;
}
require_once ('foot.php');
?>