Файл: cat.php
Строк: 92
<?php
include_once 'inc/bd.php';
include_once 'inc/fun.php';
$id = num($_GET['cat']);
if (!empty($id))
{$whatis = mysql_fetch_assoc(mysql_query("SELECT * FROM `cat` WHERE `id` = '$id' "));
$title = 'Категория "'.html($whatis['name']).'"';}
else {$title = 'Категории';}
include_once 'inc/v.php';
####
if (empty($id))
{
####
$allw = mysql_result(mysql_query("SELECT COUNT(*) FROM `cat`"), 0, 0);
$allstat = mysql_result(mysql_query("SELECT COUNT(*) FROM `text` where `checked`='1'"), 0, 0);
####
echo '<div class="rmenu">Всего категорий: <strong>'.$allw.' </strong></div>';
####
echo '<div class="menu"><strong><a href="'.$home.'/all.php">Все записи</a></strong> ('.$allstat.')<br/><span class="small">Записи из всех категорий</span></div>';
####
$sql = mysql_query("SELECT * FROM `cat` ORDER BY `id` DESC");
while ($row = mysql_fetch_assoc($sql))
{
$cat_id = num($row['id']);
$kolst = mysql_result(mysql_query("SELECT COUNT(*) FROM `text` WHERE `cat_id`= '$cat_id'"), 0, 0);
$about = html($row['about']);
$name = html($row['name']);
echo '<div class="menu"><strong><a href="'.$home.'/cat/'.$cat_id.'">'.$name.'</a></strong> ('.$kolst.')<br/><span class="small">'.$about.'</span></div>';
}
####
}
else
{
####
if (mysql_num_rows(mysql_query("SELECT * FROM `cat` WHERE `id` = '$id'"))==0)
{echo '<div class="err">Нет такой категории!</div>';}
else
{
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `text` WHERE `cat_id` = '$id'"), 0, 0);
####
$getpage = num($_GET['page']);
if(isset($getpage))
{$page = $getpage;}
else{$page=1;}
$str = ceil($all/$npage);
if(!$str) $pages = 1;
if($page>$str or $page<=0) $page=1;
if($start>$all or $start<=0) $start = 0;
if($page) $start = ($page - 1) * $npage;
else $start = 0;
####
if ($all > 0)
{
####
$allst = mysql_result(mysql_query("SELECT COUNT(*) FROM `text` WHERE `cat_id`= '$id'"), 0, 0);
echo '<div class="rmenu">Всего статей в категории: <strong>'.$allst.' </strong></div>';
####
$sql_text = mysql_query("SELECT * FROM `text` WHERE `cat_id` = '$id' ORDER BY `id` DESC LIMIT $start,$npage");
while ($row = mysql_fetch_assoc($sql_text))
{
$idk = num($row['id']);
$cat = num($row['cat_id']);
$catnames = mysql_fetch_assoc(mysql_query("SELECT * FROM `cat` WHERE `id`='$cat'"));
if(empty($catnames)) {$catname = 'Нет категории';} else{$catname = html($catnames['name']);}
$date = $row['date'];
$news = num($row['news']);
$comment = num($row['comment']);
$comm = html($row['comm']);
$name = html($row['name']);
$text = html($row['text']);
$text = anonc($text,$anonc);
$text = nl2br($text);
$text = adminbb(parsebb(smiles($text)));
$text = $text.'...';
####
$nname = mysql_fetch_assoc(mysql_query("SELECT * FROM `comment` WHERE `text_id` = '$idk' ORDER BY `id` DESC LIMIT 1"));
$user = antirek(html($nname['user']));
if ($user == $adminlogin) {$user = '<span style="color:#900">'.$user.' (УКДПЕ)</font>';}
if (!empty($user)) {$lcom = ' <sup>'.$user.'</sup>';} else {$lcom = '';}
if (!empty($news)){$div = '<div class="info"><strong>Новость: ';}else{$div = '<div class="menu"><strong>';}
####
echo $div.'<a href="'.$home.'/blog/'.$idk.'">'.$name.'</a></strong> | '.$date.'<hr>
<span class="anonc">'.$text.'</span><br/>
<a href="'.$home.'/blog/'.$idk.'">Далее →</a>';
if ($comment !== 1){
echo ' | <a href="'.$home.'/comment/'.$idk.'">Комменты</a> ('.$comm.') '.$lcom.'';
}
echo '</div>';
}
####
$pp = $page - 2;
$pp2 = $page + 3;
$backpage = $page - 1;
$uppage = $page + 1;
if ($str>1){
echo '<div class="nmenu">';
if ($page > 1)
echo '<a class="str" href="'.$home.'/cat/'.$id.'/'.$backpage.'">«</a> ';
if($pp<$all && $pp>0 && $page>3)
echo '<a class="str" href="'.$home.'/cat/'.$id.'/1">1</a> ... ';
for($i=$pp; $i<$pp2;$i++)
{
if($i<$all && $i>0)
{
if ($i > $str )
break;
if ($page==$i)
echo '<span class="str_active"><b>'.$i.'</b></span> ';
else echo '<a class="str" href="'.$home.'/cat/'.$id.'/'.$i.'">'.$i.'</a> ';
}
}
if ($i <= $str) {if($pp2<$all) echo ' ... <a class="str" href="'.$home.'/cat/'.$id.'/'.$str.'">'.$str.'</a>';}
if ($page < $str)
{
echo '<a class="str" href="'.$home.'/cat/'.$id.'/'.$uppage.'">»</a> ';
}
echo '</div>';
}
####
}
else {echo '<div class="menu">Статей в категории нет!</div>';}
####
}
####
}
####
include_once 'inc/n.php';
?>