Файл: public_html/modules/downloads/search.php
Строк: 118
<?php
/**********************************
* @package: PerfCMS *
* @year: 2012 *
* @author: Artas *
* @link: http://perfcms.net *
* ------------------------------- *
* @package: PerfCMS Ultra *
* @year: 2013 *
* @author: wanya26ua & Tesla *
* @link: http://perfclub.ru *
**********************************/
$locate = 'in_downloads';
$title = $lang->word('search').' | '. $lang->word('downloads');
require_once(SYS .'/view/header.php');
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', $lang->word('in_files_names'));
$tpl->div('menu', $lang->word('found').': <b>'.$search_r.'</b>');
$pages = new Paginator($search_r, $ames);
if($search_r == 0) {
$tpl->div('menu', $lang->word('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('/downloads/search?q='.input($_GET['q']).'&where=names&');
}
$tpl->div('block', NAV .' <a href="/downloads/search">'. $lang->word('search') .'</a><br/>'.
img('download.png') .' <a href="/downloads/">'. $lang->word('downloads') .'</a><br/>'
. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS .'/view/footer.php');
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', $lang->word('in_files_desc'));
$tpl->div('menu', $lang->word('found').': <b>'.$search_r.'</b>');
$pages = new Paginator($search_r, $ames);
if($search_r == 0) {
$tpl->div('menu', $lang->word('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('/downloads/search?q='.input($_GET['q']).'&where=desc&');
}
$tpl->div('block', NAV .' <a href="/downloads/search">'. $lang->word('search') .'</a><br/>'.
img('download.png') .' <a href="/downloads/">'. $lang->word('downloads') .'</a><br/>'
. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS .'/view/footer.php');
exit;
}
$tpl->div('title', $lang->word('search').' | '. $lang->word('downloads'));
echo '<div class="menu">'.$lang->word('enter_search_key').':<br/>
<form action="/downloads/search?" method="get">
<input type="text" name="q" /><br/>
'. $lang->word('where') .':<br/>
<select name="where">
<option value="names">'.$lang->word('in_files_names').'</option>
<option value="desc">'.$lang->word('in_files_desc').'</option>
</select><br/>
<input type="submit" value="'. $lang->word('search') .'" />
</form>
</div>';
$tpl->div('block', img('download.png') .' <a href="/downloads/">'. $lang->word('downloads') .'</a><br/>'
. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS .'/view/footer.php');
?>