Файл: modules/share/search.php
Строк: 101
<?php
if(isset($user)) {
$locate = 'in_share';
$title = $lang->word('search').' | '. $lang->word('share');
require_once(SYS .'/view/header.php');
if(isset($_GET['q']) && mb_strlen($_GET['q']) >= 3 && $_GET['where'] == 'names') {
$search_r = $db->query("SELECT * FROM `share_files` WHERE `name` LIKE '%".input($_GET['q'])."%'")->rowCount();
$tpl->div('title', $lang->word('search_topics'));
$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 `share_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">
'.(preg_match('/jpeg|jpg|gif|png|bmp/i', $search['ext']) ? img('image.png') : NULL).'
'.(preg_match('/jar|sis|sisx|jad|apk/i', $search['ext']) ? img('application.png') : NULL).'
'.(preg_match('/mp4|3gp|avi|flv/i', $search['ext']) ? img('video.png') : NULL).'
'.(preg_match('/mp3|aac|amr|wav|midi|mid/i', $search['ext']) ? img('music.png') : NULL).'
'.(preg_match('/zip|rar|tar.gz|7z/i', $search['ext']) ? img('box.png') : NULL).'
<a href="/share/file/'. $search['id'] .'/">'. $search['name'] .'</a> ('.strtoupper($search['ext']).')
</div>';
}
$pages->view('/share/search?q='.input($_GET['q']).'&where=names&');
}
$tpl->div('block', img('share.png') .' <a href="/share/">'. $lang->word('share') .'</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 `share_files` WHERE `text` LIKE '%".input($_GET['q'])."%'")->rowCount();
$tpl->div('title', $lang->word('search_messages'));
$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 `share_files` WHERE `text` LIKE '%".input($_GET['q'])."%' 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">
'.(preg_match('/jpeg|jpg|gif|png|bmp/i', $search['ext']) ? img('image.png') : NULL).'
'.(preg_match('/jar|sis|sisx|jad|apk/i', $search['ext']) ? img('application.png') : NULL).'
'.(preg_match('/mp4|3gp|avi|flv/i', $search['ext']) ? img('video.png') : NULL).'
'.(preg_match('/mp3|aac|amr|wav|midi|mid/i', $search['ext']) ? img('music.png') : NULL).'
'.(preg_match('/zip|rar|tar.gz|7z/i', $search['ext']) ? img('box.png') : NULL).'
<a href="/share/file/'. $search['id'] .'/">'. $search['name'] .'</a> ('.strtoupper($search['ext']).')<br/>
'. $search['text'].'
</div>';
}
$pages->view('/share/search?q='.input($_GET['q']).'&where=desc&');
}
$tpl->div('block', img('share.png') .' <a href="/share/">'. $lang->word('share') .'</a><br/>'
. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS .'/view/footer.php');
exit;
}
$tpl->div('title', $lang->word('search').' | '. $lang->word('share'));
echo '<div class="menu">'.$lang->word('enter_search_key').':<br/>
<form action="/share/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('share.png') .' <a href="/share/">'. $lang->word('share') .'</a><br/>'
. HICO .'<a href="/">'. $lang->word('home') .'</a>');
require_once(SYS .'/view/footer.php');
} else {
$title = 'Загруз-центр';
require_once(SYS.'/view/header.php');
$tpl->div('title', 'Загруз-центр');
$tpl->div('menu', '<center>Загруз-центр доступен только зарегистрированным пользователям!</center>');
$tpl->div('block',HICO .'<a href="/">'. $lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');
}
?>