Просмотр файла modules/forum/topic.php

Размер файла: 5.2Kb
<?php
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.ru	  *
**********************************/
$locate	= 'in_forum';
if(!isset($_GET['topic_id'])) { header('Location:/forum/'); }
$topic_id = abs(intval($_GET['topic_id']));
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('menu', $lang->word('topic_not_exists'));
	$tpl->div('block', NAV.' <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();
$title = $topict['name'] .' | '.$lang->word('forum');
require_once(SYS.'/view/header.php');
$tpl->div('title', $topict['name'] .' | '.$lang->word('forum'));
$tpl->div('menu', (isset($user) && $topict['closed'] == 0 ? NAV .'<a href="/forum/add_post/'. $topic_id .'"/>'. $lang->word('add_message') .'</a><br/>' : NULL));
$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()) {
		$tpl->div('post', nick($topic['user_id']).' (<small><span  class="gray">'. rtime($topic['time']).'</span></small>) '.(isset($user) ? '['.($user['id'] != $topic['user_id'] ? '<a href="/forum/'.(isset($user) && $settings['fast_mess'] == 'yes' ? 'topic' : 'add_post/'). $topic['topic_id'] .'/?page=end&amp;reply_to='.tnick($topic['user_id']).'">'. $lang->word('reply').'</a> | <a href="/forum/'.(isset($user) && $settings['fast_mess'] == 'yes' ? 'topic' : 'add_post/'). $topic['topic_id'] .'/?page=end&amp;quote='. $topic['id'] .'">'. $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'].'/">'.img('delete.png').'</a> | <a href="/forum/edit_post/'.$topic['id'].'/'.$topic['topic_id'].'/">'.img('edit.png').'</a>' : NULL).']':NULL).'<br/> '. output($topic['text']) .'</a>'. ($topic['count_edit'] > 0?'<small style="font-size: xx-small"><br />_______________<br />Last edit: '. date('d.m.Y, H:i', $topic['edit_time']) .' by '. tnick($topic['edit_user_id']) .'. Total: '. $topic['count_edit'] .' times</small><br/>':NULL) .'
		'.(!empty($topic['file']) ? '<br/>_______________<br/><a href="/files/forum/'.$topic['file'].'">'.$topic['file'].'</a> ('.size($topic['file_size']).')' : NULL).'');
	}
	$pages->view('/forum/topic'. $topic_id .'/?');
}
if(isset($user) && $settings['fast_mess'] == 'yes' && $topict['closed'] == 0) {
	$tpl->div('menu', '<form action="/forum/add_post/'. $_GET['topic_id'] .'/?act=create" method="post">
			<b>'. $lang->word('message') .'</b>:<br/>
			<textarea name="text" rows="5" cols="26">'.(isset($_GET['reply_to']) ? '[b]'.$_GET['reply_to'].'[/b], ' : NULL) . (isset($_GET['quote']) ? "[b]".tnick($db->query("SELECT user_id FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."' AND `id` = '". $_GET['quote'] ."'")->fetchColumn())."[/b] ".date('d.m.Y, H:i', $db->query("SELECT time FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."' AND `id` = '". $_GET['quote'] ."'")->fetchColumn())."\n[quote]\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/>
			<input name="create" type="submit" value="'. $lang->word('create') .'" /><br/>
		</form>');
	}
echo '<div class="block">'; 
					if(isset($user) && $topict['closed'] == 0) { echo ''.NAV .'<a href="/forum/add_post/'. $topic_id .'"/>'. $lang->word('add_message') .'</a><br/>'; }
					if(($user['level']>=5 || $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 NAV . '<a href="/forum/topic/close/'. $topict['id'].'/">'. $lang->word('close') .'</a><br/>'; } elseif(($user['level']>=5 || $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 NAV . '<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/>'; }
echo '</div>';
$tpl->div('block', NAV.' <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');
?>