Файл: modules/forum/section.php
Строк: 58
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
$locate = 'in_forum';
if(!isset($_GET['id'])) { redirect('/forum/'); }
$cat_id = abs(intval($_GET['id']));
if($db->query("SELECT * FROM `forum_c` WHERE `id` = '". $cat_id ."'")->rowCount() == 0) {
$title = _t('forum');
include_header($title);
$tpl->div('menu', _t('subforum_not_exists'));
$tpl->div('block', NAV.' <a href="/forum/">'. _t('forum') .'</a><br/>' . HICO .' <a href="/">'. _t('home') .'</a>');
include_footer();
exit;
}
$topicc = $db->query("SELECT * FROM `forum_c` WHERE `id` = '". $cat_id ."'")->fetch();
$title = $topicc['name'] .' | '._t('forum');
include_header($title);
$tpl->div('title', $topicc['name'] .' | '._t('forum'));
$topic_r = $db->query("SELECT * FROM `forum_t` WHERE `cat_id` = '". $cat_id ."'")->rowCount();
$pages = new Paginator($topic_r, $ames);
if($topic_r == 0) {
echo $tpl->div('menu', _t('no_topics'));
}
else {
$topic_q = $db->query("SELECT * FROM `forum_t` WHERE `cat_id` = '". $cat_id ."' ORDER BY attach DESC, time_last_post DESC LIMIT $start, $ames");
while($topic = $topic_q->fetch()) {
echo '<div class="menu">';
if ($topic['closed'] == 1 && $topic['attach'] == 1) echo img('pin-closed.png');
else if ($topic['attach'] == 1) echo img('pin.png');
else if ($topic['closed'] == 1) echo img('topic_closed.png');
else echo img('topic.png');
if ($db->query("SELECT * FROM `forum_vote` WHERE `topic_id` = '". $topic['id'] ."' AND `type` = '1'")->rowCount() > 0) echo img('rating.png');
$topic_a = $db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '". $topic['id']."' ORDER BY time DESC LIMIT 1")->fetch();
echo '<a href="/forum/topic/'. $topic['id'] .'">'. $topic['name'] .'</a> ('. $db->query("SELECT id FROM `forum_pt` WHERE `topic_id` = '". $topic['id'] ."'")->rowCount().')<a href="/forum/topic/'. $topic['id'] .'?page=end">»</a> '. (User::level() >= 5 ? ' [<a href="/forum/delete_topic/'.$topic['id'].'/">x</a> | <a href="/forum/edit_topic/'.$topic['id'].'/">+</a>]' : NULL) .'<br/> [<small class="gray">'. tnick($topic_a['user_id']).' / '. rtime($topic_a['time']).'</small>]
</div>';
}
$pages->view();
}
$fid = $db->query("SELECT f_id FROM `forum_c` WHERE `id` = '". $cat_id ."'")->fetchColumn();
$tpl->div('block', (User::logged() ? NAV.' <a href="/forum/add_topic/'. $cat_id .'/">'. _t('create_topic') .'</a><br/>' : NULL) .
NAV . ' <a href="/forum/category/'. $fid .'/">'. $db->query("SELECT name FROM `forum` WHERE `id` = '". $fid ."'")->fetchColumn().'</a><br/>' . NAV . ' <a href="/forum/">'. _t('forum') .'</a><br/>' . HICO .' <a href="/">'. _t('home') .'</a>');
include_footer();
?>