Файл: modules/forum/topic.php
Строк: 116
<?php
if(isset($user)) {
$locate = 'in_forum';
if(!isset($_GET['topic_id'])) { header('Location:/forum/'); }
$topic_id = abs(intval($_GET['topic_id']));
if(isset($user)){$db->query("UPDATE `notify` SET `read` = '1' WHERE `request_id` = '$topic_id' AND `user_id` = '".$user['id']."' AND `type` = 'notify_topic_reply'");}
if($db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."'")->rowCount() == 0) {
$title = $lang->word('forum');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('forum'));
$tpl->div('menu', $lang->word('topic_not_exists'));
$tpl->div('block', img('forum.png').' <a href="/forum/">'. $lang->word('forum') .'</a><br/>' . HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
exit;
}
$topict = $db->query("SELECT * FROM `forum_t` WHERE `id` = '". $topic_id ."'")->fetch();
if (isset($_GET['pod'])) {
if ($db->query("SELECT * FROM `forum_pod` WHERE `topic_id` = '". $topic_id ."' AND `user` = '". $user['id'] ."'")->rowCount() == 0) {
$db->query("INSERT INTO `forum_pod` SET `user` = '". $user['id'] ."', `topic_id` ='". $topic_id ."', `time` = '". time() ."'");
} else {
$db->query("DELETE FROM `forum_pod` WHERE `user` = '". $user['id'] ."' AND `topic_id` ='". $topic_id ."'");
}
header('Location:/forum/topic'. abs(intval($topic_id)).'');
}
$title = $topict['name'] .' | '.$lang->word('forum');
require_once(SYS.'/view/header.php');
$tpl->div('title', $topict['name'] .' | '.$lang->word('forum'));
if(isset($_GET['act']) && $_GET['act'] == 'spam') {
$tpl->div('block', $lang->word('spam') .' <b>'.$system['spam_forum'].'</b> '.$lang->word('sec'));
}
//if(isset($user) && $topict['closed'] == 0) {
//echo '<div class="menu">'. NAV .'<a href="/forum/add_post/'. $topic_id .'"/>'. $lang->word('add_message') .'</a><br/></div>';
//}
if(isset($user)) {
echo '<div class="menu"><center>'. ($db->query("SELECT * FROM `forum_pod` WHERE `topic_id` = '". $topic_id ."' AND `user` = '". $user['id'] ."'")->rowCount() == 0 ? '<a href="/forum/topic'. $topic_id .'?pod">Подписаться к обсуждению</a>':'<a href="/forum/topic'. $topic_id .'?pod">Отписаться от обсуждения</a>').'</center></div>';
}
$topic_r = $db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."'")->rowCount();
$pages = new Paginator($topic_r, $ames);
if($topic_r == 0) {
echo $tpl->div('menu', $lang->word('no_posts'));
}
else {
$topic_q = $db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."' ORDER BY time ASC LIMIT $start, $ames");
while($topic = $topic_q->fetch()) {
$top = $db->query("SELECT * FROM `forum_evaluation` WHERE `topic_id` = '". $topic_id ."' AND `user_id` = '". $user['id'] ."' AND `user_post` = '". $topic['user_id'] ."'")->rowCount();
$tpl->div('post', nick($topic['user_id']).' (<small><span class="gray">'. rtime($topic['time']).'</span></small>) '.(isset($user) && $top <= 0 && $topic['user_id'] != $user['id'] ? '[<span class="green"><a href="/forum/post_evaluation.php?id='.$topic['id'].'&act=plus">+1</a></span> | <span class="red"><a href="/forum/post_evaluation.php?id='.$topic['id'].'&act=minus">-1</a></span>]' : '').'<br/>'. output($topic['text']) .'</a>'. ($topic['count_edit'] > 0?'<small style="font-size: xx-small"><br />Пост изменил <b>'. tnick($topic['edit_user_id']) .'</b> ('. rtime($topic['edit_time']) .') ['. $topic['count_edit'] .']</small>':NULL) .'
'.(!empty($topic['file']) ? '<br/><div style="border: dotted 1px;"><a href="/files/forum/'.$topic['file'].'">'.$topic['file'].'</a> ['.size($topic['file_size']).']</div>' : NULL).' <br />
'.(isset($user) ? ' '.($user['id'] != $topic['user_id'] && $topict['closed'] == 0 ? '<a href="/forum/'.(isset($user) && $settings['fast_mess'] == 'yes' ? 'topic' : 'add_post/'). $topic['topic_id'] .'/?page=end&reply_to='.tnick($topic['user_id']).'" title="'. $lang->word('reply') .'">[Отв]</a> <a href="/forum/'.(isset($user) && $settings['fast_mess'] == 'yes' ? 'topic' : 'add_post/'). $topic['topic_id'] .'/?page=end&quote='. $topic['id'] .'" title="'. $lang->word('quote') .'"> [Цит]</a>': NULL) . ($user['level'] == 3 || $user['level'] >= 5 || $user['id'] == $topic['user_id'] ? ' <a href="/forum/delete_post/'.$topic['id'].'/'.$topic['topic_id'].'/" title="'. $lang->word('delete') .'"> [Уд]</a> <a href="/forum/edit_post/'.$topic['id'].'/'.$topic['topic_id'].'/" title="'. $lang->word('edit') .'"> [Ред]</a>' : NULL).'':NULL).'
');
}
$pages->view('/forum/topic'. $topic_id .'/?');
}
if(isset($user) && $settings['fast_mess'] == 'yes' && $topict['closed'] == 0) {
echo '<div class="menu"><form action="/forum/add_post/'. $_GET['topic_id'] .'/?act=create'.(isset($_GET['reply_to']) ? '&reply_to='.input($_GET['reply_to']).'' : NULL).(abs(intval($_GET['quote'])) ? '"e='.abs(intval($_GET['quote'])).'' : NULL).'" method="post">
<b>'. $lang->word('message') .'</b>:<br/>';
require_once(SYS.'/inc/bb.php');
echo '<textarea name="text" id="view_bar">'.(isset($_GET['reply_to']) ? '[b]'.input($_GET['reply_to']).'[/b], ' : NULL) . (isset($_GET['quote']) ? "[quote][i][b]".tnick($db->query("SELECT user_id FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."' AND `id` = '". abs(intval($_GET['quote'])) ."'")->fetchColumn())."[/b] ".date('d.m.Y, H:i', $db->query("SELECT time FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."' AND `id` = '". abs(intval($_GET['quote'])) ."'")->fetchColumn())."[/i]:n".preg_replace("/[quote]|[/quote]/i", '', $db->query("SELECT text FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."' AND `id` = '". abs(intval($_GET['quote'])) ."'")->fetchColumn())."n[/quote] " : NULL).'</textarea><br/>
[ <a href="/pages/smiles.php">'. $lang->word('smiles') .'</a> | <a href="/pages/tags.php">'. $lang->word('tags') .'</a> ]<br/><input name="create" type="submit" value="'. $lang->word('create') .'" /><br/>
</form></div>';
}
echo '<div class="block">';
if(isset($user) && $topict['closed'] == 0) { echo ''.'<a href="/forum/add_post/'. $topic_id .'"/>'. $lang->word('add_message') .'</a>'; }
if(($user['level']>=3 || $user['id'] == $db->query("SELECT user_id FROM `forum_pt` WHERE `topic_id` = '". $topict['id']."' ORDER BY time ASC LIMIT 1")->fetchColumn()) && $topict['closed'] == 0) { echo ' | <a href="/forum/topic/close/'. $topict['id'].'/">'. $lang->word('close') .'</a><br/>'; } elseif(($user['level']>=3 || $user['id'] == $db->query("SELECT user_id FROM `forum_pt` WHERE `topic_id` = '". $topict['id']."' ORDER BY time ASC LIMIT 1")->fetchColumn()) && $topict['closed'] == 1) { echo'<a href="/forum/topic/open/'. $topict['id'].'/">'. $lang->word('open') .'</a><br/>'; }
//if($user['level']>=6 && $topict['attach'] == 0) { echo NAV . '<a href="/forum/topic/attach/'. $topict['id'].'/">'. $lang->word('attach') .'</a><br/>'; } elseif($user['level']>=6 && $topict['attach'] == 1) { echo NAV . '<a href="/forum/topic/unpin/'. $topict['id'].'/">'. $lang->word('unpin') .'</a><br/>'; }
//if($user['level']>=5) { echo NAV . '<a href="/forum/per_topic/'. $topict['id'].'/">'. $lang->word('per_topic') .'</a><br/>';}
echo '</div>';
$tpl->div('block', img('new_topic.png').' <a href="/forum/cat/'. $topict['cat_id'] .'/">'.$db->query("SELECT name FROM `forum_c` WHERE `id` = '". $topict['cat_id']."'")->fetchColumn().'</a><br/>' . HICO .' <a href="/">'. $lang->word('home') .'</a>');
require_once(SYS.'/view/footer.php');
} else {
$title = 'Форум';
require_once(SYS.'/view/header.php');
$tpl->div('title', 'Форум');
$tpl->div('menu', '<center>Форум доступен только зарегистрированным пользователям!</center>');
$tpl->div('block',HICO .'<a href="/">'. $lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');
}
?>