File size: 4.03Kb
<?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';} //проверка
$tema = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_tem` WHERE `id`='$id' LIMIT 1"));
if(!$tema){echo'<div class="name">Такой темы нет в БД</div>';
include_once '../sys/foot.php';} //проверка
$podcat=mysql_fetch_array(mysql_query("SELECT * FROM `forum_podcat` WHERE `id`='$tema[cat]'"));
$cat=mysql_fetch_array(mysql_query("SELECT * FROM `forum_cat` WHERE `id`='$podcat[refid]'"));
if($podcat && $cat)
{
echo'<div class="cat">
<a href="cat.php?id='.$cat['id'].'">'.output($cat['name']).'</a> / <a href="podcat.php?id='.output($podcat['id']).'">'.output($podcat['name']).'</a></div>
<div class="login">Тема: <b>'.output($tema['name']).'</b></div>';
}
if(!isset($user)){ //ДЛЯ НЕАВТОРИЗОВАННЫХ//
$count_tem=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_post` WHERE `tema`='$id'"), 0);
$page=isset($_GET['p'])?num($_GET['p']):1;
$post_q=mysql_query("SELECT * FROM `forum_post` WHERE `tema`='$id' ORDER BY `time` LIMIT ".(($page-1)*$config['points_page']).", $config[points_page]");
while($post=mysql_fetch_array($post_q))
{
echo'<div class="login"><a href="'.$HOME.'/'.num($post['id_user']).'.html">';
$user_add_mess = mysql_fetch_assoc(mysql_query("SELECT `name` FROM `user_ank` WHERE`id_user`='$post[id_user]'")); //запрос на логин юзера
echo $user_add_mess['name'].'</a>('.mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_post` WHERE `id_user`='$post[id_user]'"),0).')';
echo'<br/>Дата: '.date('d.m.y H:i',$post['time']).'<br/>
'.output($post['text']).'</div>';
}
nav($count_tem, $page, '?id='.$id.'&', $config['points_page']); //навигация
}else {//ДЛЯ АВТОРИЗОВАННЫХ
$count_tem=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_post` WHERE `tema`='$id'"), 0);
$page=isset($_GET['p'])?num($_GET['p']):1;
$post_q=mysql_query("SELECT * FROM `forum_post` WHERE `tema`='$id' ORDER BY `time` LIMIT ".(($page-1)*$user['points_page']).", $user[points_page]");
while($post=mysql_fetch_array($post_q))
{
echo'<div class="login"><a href="'.$HOME.'/'.num($post['id_user']).'.html">';
$user_add_mess = mysql_fetch_assoc(mysql_query("SELECT `name` FROM `user_ank` WHERE`id_user`='$post[id_user]'")); //запрос на логин юзера
echo $user_add_mess['name'].'</a>('.mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_post` WHERE `id_user`='$post[id_user]'"),0).')';
if($user['status']==admin){echo'<a href="panel/forum/edit_post.php?id='.num($post['id']).'"> Редактировать</a> | <a href="panel/forum/del_post.php?id='.num($post['id']).'">Удалить</a>';}
echo'<br/>Дата: '.date('d.m.y H:i',$post['time']).'<br/>
'.output($post['text']).'</div>';
}
nav($count_tem, $page, '?id='.$id.'&', $user['points_page']); //навигация
if($tema['close']==1){echo'<div class="login">Данная тема закрыта</div>';}
else{
echo'<div class="login">
Добавить сообщение<br/>
<form action="post-add.php?id='.$id.'" method="post"><input name="tema" type="hidden" value="'.$id.'" />
<textarea name="text" cols="25" rows="4"></textarea><br/>
Капча: <img src="/caps/captcha.php" /><br/>
Введите капчу: <input type="text" name="captcha" value="" size=6><br/>
<input name="" type="submit" value="Написать" /></form></div>';
if($user['status']==admin){
echo'<div class="login"><a href="panel/forum/close_theme.php?id='.num($post['id']).'">Закрыть тему</a><br/>
<a href="panel/forum/del_theme.php?id='.num($post['id']).'">Удалить тему</a></div>';
}
}
}
echo'<div class="login"><a href="index.php">В Форум</a></div>';
echo'<div class="login">Ссылка на тему:<br/> <input type="text" name="url" value="'.$HOME.'/forum/tema.php?id='.$id.'" size=15></div>';
include_once '../sys/foot.php';
?>