Файл: forum/post/topic/index.php
Строк: 113
<?
require_once '../../../core/system.php';
echo only_reg();
echo ban();
if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_topic` WHERE `id` = '".intval($_GET['id'])."'"),0) == true){
$topic = mysql_fetch_assoc(mysql_query("SELECT * FROM `forum_topic` WHERE `id` = '".intval($_GET['id'])."'"));
}else{
$_SESSION['err'] = "Топик не найден!";
header('Location: /forum/');
exit();
}
if($user['prava'] == 5){
if(isset($_GET['postd'])){
mysql_query("DELETE FROM `forum_comm` where `id` = '".abs(intval($_GET['postd']))."' limit 1");
}
}
$header = $topic[name];
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$topic[id_user]'"));
if($ank[prava] == 5)$color = 'quality-5';
if($ank[prava] == 4)$color = 'Moder';
if($ank[prava] == 0)$color = '';
require_once '../../../core/head.php';
if(isset($_GET['menu'])) {
if($user[prava] > 2){
echo "<div class='player'>";
echo "<img src='/images/icon/arrow.png'> <a class='grey' href='/forum/post/topic/$topic[id]/'>Меню Топика</a> | <a href='/forum/post/topic/topic_red.php?id=$topic[id]'>Редактировать</a> | <a href='/forum/post/topic/close.php?id=$topic[id]'>Удалить</a>";
if($topic[close] == 0){
echo " | <a href='/forum/post/topic/topic_close.php?id=$topic[id]'>Закрыть</a>";
}else{
echo " | <a href='/forum/post/topic/topic_no_close.php?id=$topic[id]'>Открыть</a>";
}
if($topic[verh] == 0){
echo " | <a href='/forum/post/topic/topic_verh.php?id=$topic[id]'>Прикрепить</a>";
}else{
echo " | <a href='/forum/post/topic/topic_no_verh.php?id=$topic[id]'>Открепить</a>";
}
echo "</div>";
echo "<div class='mini-line'></div>";
}
}else{
if($user[prava] > 2){
echo "<div class='player'>";
echo "<img src='/images/icon/arrow.png'> <a href='?menu=$topic[id]'>Меню Топика</a>";
echo "</div>";
echo "<div class='mini-line'></div>";
}
}
echo "<div class='player'>";
echo online($ank[id]);
echo " <a href='/user/$ank[id]/'>$ank[nick]</a>, <span class='dgreen'>".vremja($topic[time])."</span><br>";
echo "<span class='$color'>".smiles($topic[msg])."</span>";
echo "</div><div class='mini-line'></div>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_comm` WHERE `id_topic` = '$topic[id]'"),0);
echo "<div class='player center'>Всего комментариев ($k_post)</div>";
echo "<div class='mini-line'></div>";
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
if(isset($_POST['msg'])){
$msg = check($_POST['msg']);
if(strlen($msg) < 10 or strlen($msg) > 1000) $err = 'Длина сообщения должна быть в пределах 10 - 1000 символов';
if(!isset($err)) {
mysql_query("INSERT INTO `forum_comm` SET `id_user` = '$user[id]', `id_topic` = '$topic[id]', `msg` = '$msg', `time` = '".time()."'");
header("Location: /forum/post/topic/$topic[id]/?page=end");
$_SESSION['message'] = 'Сообщение добавлено!';
exit();
}else{
header("Location: /forum/post/topic/$topic[id]/?page=end");
$_SESSION['err'] = $err;
// Вывод ошибки
exit();
}
}
$q = mysql_query("SELECT * FROM `forum_comm` WHERE `id_topic` = '$topic[id]' ORDER BY `id` ASC LIMIT $start, $set[p_str]");
if($k_post == 0)echo "<div class='player grey'>Нет комментариев</div><div class='mini-line'></div>";
while($post = mysql_fetch_assoc($q)) {
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$post[id_user]' LIMIT 1"));
if($ank[prava] == 5 )$color = 'Admin';
if($ank[prava] == 4 )$color = 'Moder';
if($ank[prava] == 0 )$color = 'white';
echo "<div class='player'>";
if($ank[ban] == 1){
echo online($ank[id]);
echo " <a href='/user/$ank[id]/'>$ank[nick]</a> ";
echo "<a href='?comm=$ank[id]&page=end'>(»)</a>, ";
echo "<span class='white'>".vremja($post[time])."</span><br>";
echo "<span class='grey'>Это сообщение ушло париться с автором в баню!</span>";
}else{
echo online($ank[id]);
echo " <a href='/user/$ank[id]/'>$ank[nick]</a> ";
echo "<a href='?comm=$ank[id]&page=end'>(»)</a> ".($user['prava'] == 5?'(<a href="?id='.$topic['id'].'&postd='.$post['id'].'">x</a>)':null).", ";
echo "<span class='white'>".vremja($post[time])."</span><br>";
echo '<span class="'.$color.'">'.smiles($post['msg']).'</span>';
}
echo "</div>";
echo "<div class='dot-line'></div>";
}
if ($k_page>1){
str('?',$k_page,$page); // Вывод страниц
echo "<div class='mini-line'></div>";
}
if($topic[close] == 0){
if(isset($_GET['comm'])){
$ank2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id` = '$_GET[comm]'"));
echo '<form class="player" method="post" action="/forum/post/topic/'.$topic[id].'/">
<textarea name="msg" rows = "4" cols ="15" class = "text large">'.$ank2[nick].', </textarea><br />
<span class="btn"><span class="end"><input class="label" type="submit" value="Отправить">Отправить</span></span>
</form>';
}else{
echo '<form class="player" method="post" action="/forum/post/topic/'.$topic[id].'/">
<textarea name="msg" rows = "4" cols ="15" class = "text large"></textarea><br />
<span class="btn"><span class="end"><input class="label" type="submit" value="Отправить">Отправить</span></span>
</form>';
}
}else{
echo "<div class='player red'>Топик закрыт!</div>";
}
echo "<div class='mini-line'></div>";
echo "<div class='player menuList'>";
echo "<li><a href='/forum/post/$topic[id_razdel]/'><img src='/images/icon/section.png'>Вернутся в раздел</a></li>";
echo "</div>";
require_once '../../../core/foot.php';
?>