Файл: moduls/forum/them.php
Строк: 55
<?php
include_once $_SERVER["DOCUMENT_ROOT"].'/system/base.php';
$id = abs(intval($_GET['id']));
$c = $con->query("SELECT * FROM `forum_theme` WHERE `id` = '".$id."'")->fetch_assoc();
$title = 'Тема форума '.$c['name'].'';
include_once $_SERVER["DOCUMENT_ROOT"].'/style/head.php';
aut();
if($c){
if(isset($_POST['add'])){
$text = filtr($_POST['text']);
if(mb_strlen($text) < '1' or mb_strlen($text) > '5400') $err = 'Текст либо менее 1 либо более 5400 символов';
if($err){
err($err);
}else{
if($c['status'] == 'open'){
$con->query("UPDATE `forum_theme` SET `up` = '".time()."' WHERE `id` = '".$id."'");
$con->query("INSERT INTO `forum_msg` (`text`, `id_theme`, `id_user`, `time`) VALUES ('".$text."', '".$id."', '".$user['id']."', '".time()."')");
$con->query("UPDATE `user` SET `money` = `money`+'".$sett['money_f_msg']."' WHERE `id` = '".$user['id']."'");
header('Location: ?');
}elseif($c['status'] == 'closed' and $user['admin_level']>=1){
$con->query("UPDATE `forum_theme` SET `up` = '".time()."' WHERE `id` = '".$id."'");
$con->query("INSERT INTO `forum_msg` (`text`, `id_theme`, `id_user`, `time`) VALUES ('".$text."', '".$id."', '".$user['id']."', '".time()."')");
$con->query("UPDATE `user` SET `money` = `money`+'".$sett['money_f_msg']."' WHERE `id` = '".$user['id']."'");
header('Location: ?');
}
}
}
if($user['admin_level']>=1){$admin = '<a href="/forum/del_them/'.$c['id'].'">[Уд]</a> <a href="/forum/edit_them/'.$c['id'].'">[Изм]</a>';}else{$admin ='';}
echo '<div class="razdel"><b>Название</b> : '.$c['name'].' ('.data($c['time']).') '.$admin.'</div>';
echo '<div class="forum_text">'.text($c['text']).'</div>';
echo '<div class="link"><b>Автор</b> : '.user($c['id_user']).' </div>';
# НИЖЕ ВЫВОД СООБЩЕНИЙ
$k_post = $con->query('SELECT * FROM `forum_msg` WHERE `id_theme` = "'.$id.'"')->num_rows;
$k_page = k_page($k_post,10);
$page = page($k_page);
$start = 10*$page-10;
$c2 = $con->query("SELECT * FROM `forum_msg` WHERE `id_theme` = '".$id."' ORDER BY `id` DESC LIMIT $start, 10");
if($k_post<1) err('Сообщений еще нет');
while($w = $c2->fetch_assoc()){
if($w['id_user'] != $user['id']){$ot = '<br><a href="/forum/otvet/'.$w['id'].'">[Ответить]</a>';}else{$ot = '';}
if($user['admin_level']>=1){$madmin = '<a href="/forum/del_msg/'.$w['id'].'">[Уд]</a> <a href="/forum/edit_msg/'.$w['id'].'">[Изм]</a>';}else{$madmin ='';}
echo '<div class="post">'.user($w['id_user']).' <small>('.data($w['time']).')</small><br>
'.text($w['text']).'<br>'.$ot.' '.$madmin.'</div>';
}
if($k_post > '10') { echo str('?',$k_page,$page.''); }
# ФОРМА ВВОДА
if($c['status'] != 'closed'){
echo '<div class="other"><form action="" method="POST"><center><textarea name="text"></textarea><br/><input type="submit" name="add" value="Отправить"></form></center></div>';
}else{
err('Тема закрыта');
if($user['admin_level']>=1){
echo '<div class="other"><form action="" method="POST"><center><textarea name="text"></textarea><br/><input type="submit" name="add" value="Отправить"></form></center></div>';
}
}
}else{
err('Ошибка');
}
include_once $_SERVER["DOCUMENT_ROOT"].'/style/foot.php';
?>