File size: 3.66Kb
<?php
// by mides, icq: 529-899-6, mail: [email protected]
require("../config.php");
require("../includes/start.php");
echo '<div class="tp">Форум</div>';
$id = intval($_REQUEST['id']);
$topic = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_topics` WHERE `id` = '$id'"));
$title = $topic['title'];
require("../includes/functions.php");
if(isset($topic['id'])){
echo '<div class="s1">'.$topic['title'].'</div><div class="list">';
$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_msg` WHERE `id_topic` = '$id'"), 0);
if($count > 0){
$pages = ceil($count/$config['onpage']);
if(isset($_REQUEST['page'])){
$page = abs(intval($_REQUEST['page']));
}else{
$page = 1;
}
$from = ($page-1)*$config['onpage'];
$result = mysql_query("SELECT * FROM `forum_msg` WHERE `id_topic` = '$id' ORDER BY `time` LIMIT $from, ".$config['onpage']."");
while($msg = mysql_fetch_assoc($result)){
if(!isset($num)) $num = 1;
$num++;
$row_class = (!($num % 2)) ? 'row1' : 'row2';
echo '<div class="'.$row_class.'">';
echo '<a href="posting.php?act=answer&id='.$msg['id'].'&page='.$pages.'">'.$msg['login'].'</a></b> <i>'.date('d.m.Y / H:i', $msg['time']).'</i>';
if($msg['login'] == $_SESSION['login'] or $_SESSION['access'] > 0){
if($msg['time']+900 > time() or $_SESSION['access'] > 0){
echo ' (<a href="posting.php?act=msg_edit&id='.$msg['id'].'">ред</a>/<a href="posting.php?act=msg_del&id='.$msg['id'].'">уд</a>)';
}
}
echo '<br/>'.nl2br($msg['text']).'<br/>';
if(!empty($msg['edit_login']) && !empty($msg['edit_time'])){
echo '<i><font color="#999999">посл. ред.: '.date('d.m.y / H:i', $msg['edit_time']).', by '.$msg['edit_login'].'</font></i><br/>';
}
echo '</div>';
}
}
if($topic['authour'] == $_SESSION['login'] or $_SESSION['access'] > 0){
if($topic['closed'] == 0){
echo '<div><a href="posting.php?act=topic_close&id='.$id.'">Закр</a>|';
}
}
if($_SESSION['access'] > 0){
if($topic['closed'] == 1){
echo '<div><a href="posting.php?act=topic_open&id='.$id.'">Откр</a>|';
}
}
if($topic['authour'] == $_SESSION['login'] or $_SESSION['access'] > 0){
echo '<a href="posting.php?act=topic_edit&id='.$id.'">Ред</a>';
}
if($_SESSION['access'] > 0){
echo '|<a href="posting.php?act=topic_move&id='.$id.'">Перем</a>|';
echo '<a href="posting.php?act=topic_del&id='.$id.'">Удал</a>';
}
if($topic['authour'] == $_SESSION['login'] or $_SESSION['access'] > 0){
echo '</div>';
}
echo '</div><div class="s1">Навигация</div><div class="s2">';
navig($page, 'topic.php?id='.$id.'&', $pages);
if($topic['closed'] == 0){
if(!empty($_SESSION['login'])){
echo 'Добавить сообщение:<br/>';
echo '<form action="posting.php?act=msg_add&id='.$topic['id'].'" method="post" name="form">';
echo '<textarea name="text" rows="3"></textarea><br/>';
echo '<input name="submit" type="submit" value="Добавить" /></form><br/>';
}else{
echo 'Вы не авторизованы для добавления сообщений!<br/><br/>';
}
}else{
echo 'Вы не можете добавить сообщение, т.к. тема закрыта!<br/><br/>';
}
echo '<a href="index.php?act=cat_view&id='.$topic['id_cat'].'">назад к темам</a><br/>';
echo '<a href="./">к разделам</a><br/>';
echo '<a href="../">на главную</a></div>';
}else{
error('Выбранной темы не существует!');
nav2('./', 'форум');
}
require("../includes/tail.php");
?>