Файл: modules/downloads/search.php
Строк: 110
<?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_downloads';
$title = _t('search').' | '. _t('downloads');
include_header($title);
if(isset($_GET['q']) && mb_strlen($_GET['q']) >= 3 && $_GET['where'] == 'names') {
$search_r = $db->query("SELECT * FROM `downloads_files` WHERE `name` LIKE '%".input($_GET['q'])."%'")->rowCount();
$tpl->div('title', _t('in_files_names'));
$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 `downloads_files` 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">
'.dlext($search['ext']).'
<a href="/downloads/file/'. $search['id'] .'/">'. $search['name'] .'</a> ('.strtoupper($search['ext']).')
</div>';
}
$pages->view();
}
$tpl->div('block', NAV .' <a href="/downloads/search">'. _t('search') .'</a><br/>'.
img('download.png') .' <a href="/downloads/">'. _t('downloads') .'</a><br/>'
. HICO .'<a href="/">'. _t('home') .'</a>');
include_footer();
exit;
} elseif(isset($_GET['q']) && mb_strlen($_GET['q']) >= 3 && $_GET['where'] == 'desc') {
$search_r = $db->query("SELECT * FROM `downloads_files` WHERE `description` LIKE '%".input($_GET['q'])."%'")->rowCount();
$tpl->div('title', _t('in_files_desc'));
$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 `downloads_files` WHERE `description` LIKE '%".input($_GET['q'])."%' LIMIT $start, $ames");
while($search = $search_q->fetch()) {
$search['description'] = str_replace(input($_GET['q']), '<b>'.input($_GET['q']).'</b>', $search['description']);
echo '<div class="post">
'.dlext($search['ext']).'
<a href="/downloads/file/'. $search['id'] .'/">'. $search['name'] .'</a> ('.strtoupper($search['ext']).')<br/>
'. $search['description'].'
</div>';
}
$pages->view();
}
$tpl->div('block', NAV .' <a href="/downloads/search">'. _t('search') .'</a><br/>'.
img('download.png') .' <a href="/downloads/">'. _t('downloads') .'</a><br/>'
. HICO .'<a href="/">'. _t('home') .'</a>');
include_footer();
exit;
}
$tpl->div('title', _t('search').' | '. _t('downloads'));
echo '<div class="menu">'._t('enter_search_key').':<br/>
<form action="/downloads/search?" method="get">
<input type="text" name="q" /><br/>
'. _t('where') .':<br/>
<select name="where">
<option value="names">'._t('in_files_names').'</option>
<option value="desc">'._t('in_files_desc').'</option>
</select><br/>
<input type="submit" value="'. _t('search') .'" />
</form>
</div>';
$tpl->div('block', img('download.png') .' <a href="/downloads/">'. _t('downloads') .'</a><br/>'
. HICO .'<a href="/">'. _t('home') .'</a>');
include_footer();
?>