Файл: modules/forum/search.php
Строк: 88
<?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 = 'forum';
$title = _t('search').' | '. _t('forum');
include_header($title);
if(isset($_GET['q']) && mb_strlen($_GET['q']) >= 3 && $_GET['where'] == 'topics')
{
$search_r = $db->query("SELECT * FROM `forum_t` WHERE `name` LIKE '%".input($_GET['q'])."%'")->rowCount();
$tpl->div('title', _t('search_topics'));
$tpl->div('menu', _t('found').': <b>'.$search_r.'</b>');
$pages = new Paginator($search_r, $ames);
if($search_r == 0)
{
$tpl->div('menu', _t('not_found'));
}
else
{
$search_q = $db->query("SELECT * FROM `forum_t` WHERE `name` LIKE '%".input($_GET['q'])."%' LIMIT $start, $ames");
while($search = $search_q->fetch())
{
$search['name'] = str_replace(input($_GET['q']), '<b>'.input($_GET['q']).'</b>', $search['name']);
echo '<div class="post">';
if ($search['closed'] == 1 && $search['attach'] == 1) echo img('pin-closed.png');
else if ($search['attach'] == 1) echo img('pin.png');
else if ($search['closed'] == 1) echo img('topic_closed.png');
else echo img('topic.png');
echo '<a href="/forum/topic'.$search['id'].'">'.$search['name'].'</a> ('. $db->query("SELECT id FROM `forum_pt` WHERE `topic_id` = '". $search['id'] ."'")->rowCount().')<a href="/forum/topic/'. $search['id'] .'/?page=end">»</a>
</div>';
}
$pages->view();
}
$tpl->div('block', NAV .' <a href="/forum/search">'. _t('search') .'</a><br/>'.
img('forum.png') .' <a href="/forum/">'. _t('forum') .'</a><br/>'
. HICO .'<a href="/">'. _t('home') .'</a>');
include_footer();
exit;
}
elseif(isset($_GET['q']) && mb_strlen($_GET['q']) >= 3 && $_GET['where'] == 'messages')
{
$search_r = $db->query("SELECT * FROM `forum_pt` WHERE `text` LIKE '%".input($_GET['q'])."%'")->rowCount();
$tpl->div('title', _t('search_messages'));
$tpl->div('menu', _t('found').': <b>'.$search_r.'</b>');
$pages = new Paginator($search_r, $ames);
if($search_r == 0)
{
$tpl->div('menu', _t('not_found'));
}
else
{
$search_q = $db->query("SELECT * FROM `forum_pt` WHERE `text` LIKE '%".input($_GET['q'])."%' ORDER BY time DESC LIMIT $start, $ames");
while($search = $search_q->fetch())
{
$search['text'] = str_replace(input($_GET['q']), '<b>'.input($_GET['q']).'</b>', $search['text']);
echo '<div class="post">';
$search_u = $db->query("SELECT * FROM `forum_t` WHERE `id` = '". $search['topic_id']."' LIMIT 1")->fetch();
$search_i = $db->query("SELECT * FROM `forum_pt` WHERE `id` = '". $search['id']."' ORDER BY time ASC LIMIT 1")->fetch();
echo ''. nick($search_i['user_id']).'<br/> '. output($search['text']).'<br/> [<small class="gray">'. rtime($search_i['time']).' / <a href="/forum/topic/'. $search['topic_id'] .'/?page=end">'. $search_u['name'] .'</a> </small>]
</div>';
}
$pages->view();
}
$tpl->div('block', NAV .' <a href="/forum/search">'. _t('search') .'</a><br/>'.
img('forum.png') .' <a href="/forum/">'. _t('forum') .'</a><br/>'
. HICO .'<a href="/">'. _t('home') .'</a>');
include_footer();
exit;
}
$tpl->div('title', _t('search').' | '. _t('forum'));
echo '<div class="menu">'._t('enter_search_key').':<br/>
<form action="/forum/search?" method="get">
<input type="text" name="q" /><br/>
'. _t('where') .':<br/>
<select name="where">
<option value="topics">'._t('in_topics_names').'</option>
<option value="messages">'._t('in_messages').'</option>
</select><br/>
<input type="submit" value="'. _t('search') .'" />
</form>
</div>';
$tpl->div('block', img('forum.png') .' <a href="/forum/">'. _t('forum') .'</a><br/>'
. HICO .'<a href="/">'. _t('home') .'</a>');
include_footer();
?>