Размер файла: 2.84Kb
<? $page_name="Форум"; $dir='../'; include("../include/1.php"); require "../include/avto.php";
if(!isset($_GET['id']))exit("<b>CMS by SHuRiK error: не выбрана категория</b>");
$id=$_GET['id'];
//////////////////////////////////////////
$num = 10;
@$page = $_GET['page'];
$result00 = mysql_query("SELECT COUNT(*) FROM `shurik_f_tem` where `cat`='$id'");
$temp = mysql_fetch_array($result00);
$posts = $temp[0];
$total = (($posts - 1) / $num) + 1;
$total = intval($total);
$page = intval($page);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
///////////////////////////////////////////
$tem_1=mysql_query("select * from `shurik_f_tem` where `cat`='$id' order by `time` desc limit $start,$num");
if(@mysql_num_rows($tem_1) != 0){
$tem_2=mysql_fetch_array($tem_1);
do{$id_tem=$tem_2['id']; $postov=mysql_num_rows(mysql_query("select * from `shurik_f_post` where tema='$id_tem'"));
if($tem_2['close']==1)echo "[#]";
echo "<a href=tema.php?id=$tem_2[id]>$tem_2[name]</a> ($postov)<br/>";}
while($tem_2=mysql_fetch_array($tem_1));
//////////////////////////
$url_for_pstr="cat.php?id=$id&page=";
if($page - 5 > 0) $page5left = ' <a href='.$url_for_pstr.($page - 5) .'>'. ($page - 5) .'</a> | ';
if($page - 4 > 0) $page4left = ' <a href='.$url_for_pstr.($page - 4) .'>'. ($page - 4) .'</a> | ';
if($page - 3 > 0) $page3left = ' <a href='.$url_for_pstr.($page - 3) .'>'. ($page - 3) .'</a> | ';
if($page - 2 > 0) $page2left = ' <a href='.$url_for_pstr.($page - 2) .'>'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = ' <a href='.$url_for_pstr.($page - 1) .'>'. ($page - 1) .'</a> | ';
if($page + 5 <= $total) $page5right = ' | <a href='.$url_for_pstr.($page + 5) .'>'. ($page + 5) .'</a>';
if($page + 4 <= $total) $page4right = ' | <a href='.$url_for_pstr.($page + 4) .'>'. ($page + 4) .'</a>';
if($page + 3 <= $total) $page3right = ' | <a href='.$url_for_pstr.($page + 3) .'>'. ($page + 3) .'</a>';
if($page + 2 <= $total) $page2right = ' | <a href='.$url_for_pstr.($page + 2) .'>'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href='.$url_for_pstr.($page + 1) .'>'. ($page + 1) .'</a>';
if($page - 1 > 0) $nazad = '<a href='.$url_for_pstr.($page - 1) .'>Назад</a>';
if($page + 1 <= $total) $vpered = '<a href='.$url_for_pstr.($page + 1) .'>Далее</a>';
// Вывод меню если страниц больше одной
if ($total > 1)
{
Error_Reporting(E_ALL & ~E_NOTICE);
echo $pervpage.$page5left.$page4left.$page3left.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$page3right.$page4right.$page5right.$nextpage.'<br>'.$nazad.' | '.$vpered;
}
////////////////////////////
}
else echo "Тем нет";
echo "<br><br><a href=index.php>Форум</a> | <a href=new-topic.php?id=$id>Создать тему</a> | <a href=cat.php?id=$id>Обновить</a>";
include("../include/2.php"); ?>