View file forum/podcat.php

File size: 2.6Kb
<?php
require '../sys/dbconnect.php';
include_once '../sys/head.php';
$id=num($_GET['id']);
if(empty($id)){echo'<div class="name">Ошибка</div>';
include_once '../sys/foot.php';}    //проверка
$query=mysql_fetch_array(mysql_query("SELECT * FROM `forum_podcat` WHERE `id`='$id' LIMIT 1"));
if(!$query){echo'<div class="name">Такой подкатегории нет в БД</div>';
include_once '../sys/foot.php';} //проверка

$cat=mysql_fetch_array(mysql_query("SELECT * FROM `forum_cat` WHERE `id`=$query[refid]"));
if(!$cat){echo'<div class="name">Не найдено</div>';
include_once '../sys/foot.php';}
echo'<div class="cat"><a href="cat.php?id='.num($cat['id']).'">'.output($cat['name']).'</a></b> / <b>'.output($query['name']).'</b></div>';

if(!isset($user)){ 
$count_tem=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_tem` WHERE `cat`='$id'"), 0);
$page=isset($_GET['p'])?num($_GET['p']):1;

$tem_q=mysql_query("SELECT * FROM `forum_tem` WHERE `cat`='$id' ORDER BY `id` DESC LIMIT ".(($page-1)*$config['points_page']).", $config[points_page]");
while($tema=@mysql_fetch_array($tem_q)) 
{
$us_q=@mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='$posl_post[id_user]'"));
echo'<div class="main">
	 <a href="tema.php?id='.num($tema['id']).'">'.output($tema['name']).'</a> ('.mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_post` WHERE `tema`='$tema[id]'"), 0).')  ';if($tema['close']==1){echo' ### ';};echo'</div>';
}
nav($count_tem, $page, '?id='.$id.'&amp;', $config['points_page']); //навигация
}
else//ДЛЯ АВТОРИЗОВАННЫХ
{
$count_tem = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_tem` WHERE `cat`='$id'"), 0);
$page = isset($_GET['p'])?num($_GET['p']):1;

$tem_q = mysql_query("SELECT * FROM `forum_tem` WHERE `cat`='$id' ORDER BY `id` DESC LIMIT ".(($page-1)*$user['points_page']).", $user[points_page]");
while($tema=@mysql_fetch_array($tem_q)) 
{
echo'<div class="main">';
$us_q=@mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='$posl_post[id_user]'"));
echo'<a href="tema.php?id='.num($tema['id']).'">'.output($tema['name']).'</a> ('.mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_post` WHERE `tema`='$tema[id]'"), 0).')';if($tema['close']==1){echo' #Тема закрыта# ';};echo'</div>';
echo '</div>'; 
}
nav($count_tem, $page, '?id='.$id.'&amp;', $user['points_page']); //навигация
echo'<div class="cat"><a href="new-topic.php?id='.$id.'">Создать тему</a></div>
	 <div class="login"><a href="index.php">В Форум</a></div>';
}
include_once '../sys/foot.php';
?>