Файл: cat.php
Строк: 60
<?php
define('MKTOP', 1);
require_once ('system/connect.php');
require_once ('system/core.php');
require_once ('system/function.php');
switch($act){
default:
$title = 'Категории';
require_once ('head.php');
$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 `ban` = '0'"));
echo '<a class="link" href = "/cat_'.$cat['id'].'.php">'.$cat['name'].' <span class="stat">'.$count_sites.'</span></a>';
if(isset($user_data) AND $user_data['level'] == 3)
echo '<div class="text"><a href="/adminka/category.php?act=del&id='.$cat['id'].'">Удалить</a> <a href="/adminka/category.php?act=edit&id='.$cat['id'].'">Изменить</a></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');
$count = mysql_num_rows(mysql_query("SELECT * FROM `sait` WHERE `category` = '".$id."' AND `status` = '1' AND `ban` = '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;
echo '<div class="nav">';
if($_GET['sort'] == 'hosts' OR $_GET['sort']==null) echo 'Хосты'; else echo '<a href="/cat/'.$id.'/sort/hosts.php">Хосты</a>'; echo ' | ';
if($_GET['sort'] == 'hits') echo 'Хиты'; else echo '<a href="/cat/'.$id.'/sort/hits.php">Хиты</a>'; echo ' | ';
if($_GET['sort'] == 'in') echo 'В топ'; else echo '<a href="/cat/'.$id.'/sort/in.php">В топ</a>'; echo ' | ';
if($_GET['sort'] == 'out') echo 'Из топа'; else echo '<a href="/cat/'.$id.'/sort/out.php">Из топа</a>';
echo '</div>';
if($_GET['sort'] == 'hits') $sort= 'hits';
elseif($_GET['sort'] == 'in') $sort= 'in';
elseif($_GET['sort'] == 'out') $sort= 'out';
else $sort= 'hosts';
$saits = mysql_query("SELECT * FROM `sait` WHERE `category` = '".$id."' AND `status` = '1' AND `ban` = '0' ORDER BY `".$sort."` DESC LIMIT ".$start.",".$page_sait."");
while($row = mysql_fetch_array($saits)){
$start++;
echo '<a class="link" href="/out/'.$row['id'].'.php">'.$start.') '.$row['name'].' <span class="stat">'.$row['hosts'].'/'.$row['hits'].'</span></a>';
if(mb_strlen($row['about']) > 50){
$text = mb_substr($row['about'], 0, 50, 'utf-8');
echo '<a class="link" href="/info/'.$row['id'].'.php">'.$text.'...</a>';
}
else echo '<a class="link" href="/info/'.$row['id'].'.php">'.$row['about'].'</a>';
if(isset($user_data) AND $user_data['level'] >= 2){
echo '<div class="text"><a href="/adminka/platforms.php?act=edit_sait&id='.$row['id'].'">Редактировать</a> ';
echo '<a href="/adminka/platforms.php?act=ban&id='.$row['id'].'">Заблокировать</a> ';
echo '<a href="/adminka/platforms.php?act=del_sait&id='.$row['id'].'">Удалить</a></div>';
}
}
navigation($count,$page_sait,$page,'cat.php?id='.$id.'&sort='.$sort.'&',$total);
}
else{
echo '<div class="text">В данной категории нет активных сайтов</div>';
}
echo '<a class="link" href="/cat.php">Категории</a>';
}
else{
$title = 'Ошибка';
require_once ('head.php');
echo '<div class="text">Данной категории несуществует</div>';
echo '<a class="link" href="/cat.php">Категории</a>';
}
break;
}
require_once ('foot.php');
?>