Файл: loads/search.php
Строк: 42
<?php
require '../system/sid.php';
require '../system/config.php';
include '../system/user.php';
whorm(0, 'loads');
include '../system/head.php';
include '../system/navigator.php';
$do = (isset($_GET['do'])) ? $_GET['do'] : NULL;
switch($do) {
default:
echo $div_title . 'WAP-скрипты' . $div_end .
$div_menu . '
<img src="../ico/up.gif" alt=""/> <a href="index.php?">WAP-скрипты</a>
' . $block . '
<b>Поиск</b><br/>
<a href="pop.php?">Популярные</a> |
<a href="new.php?">Новые</a>
' . $div_end;
if (isset($_GET['reload'])) {
// новый поиск
unset($_SESSION['Lsearch']);
header('Location: search.php?');
}
if (isset($_REQUEST['go'])) {
if (empty($_POST['Lsearch'])) $Fsearch = my_check($_POST['load_search']);
if (empty($_SESSION['Lsearch'])) $_SESSION['Lsearch'] = $Fsearch;
$where = my_int($_POST['where']);
if ($where == 1) $_where = '`title`';
elseif ($where == 2) $_where = '`info`';
if (empty($_SESSION['Lwhere'])) $_SESSION['Lwhere'] = $_where;
if (empty($_SESSION['Lsearch'])) {
err('Поисковой запрос не введен!');
include '../system/foot.php';
exit();
}
echo 'Вы искали: <b>' . $_SESSION['Lsearch'] . '</b>
<a href="search.php?reload"><img src="../ico/delete.png" alt=""/></a>' . $block;
$s = mysql_result(mysql_query("SELECT COUNT(id) FROM `loads_f` WHERE $_SESSION[Lwhere] LIKE '%".$_SESSION['Lsearch']."%'"), 0);
$n = new navigator($s, 10, '?');
$view = mysql_query("SELECT * FROM `loads_f` WHERE $_SESSION[Lwhere] LIKE '%".$_SESSION['Lsearch']."%' ORDER BY `id` DESC {$n->limit}");
if ($s != FALSE) {
$i = 0;
while($a = mysql_fetch_assoc($view)) {
$ext = strtolower(end(explode('.', $a['url'])));
#######################
if ($ext == 'zip') $format = '<img src="img/zip.gif" alt="*"/> ';
elseif ($ext == 'rar') $format = '<img src="img/rar.gif" alt="*"/> ';
elseif ($ext == 'gz') $format = '<img src="img/gz.gif" alt="*"/> ';
elseif ($ext == 'tar') $format = '<img src="img/tar.gif" alt="*"/> ';
else $format = '<img src="img/unknown.gif" alt="*"/> ';
#######################
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $format . ' <a href="info-'.$a['id'].'">' . $a['title'] . '</a>' . $div_end;
}
} else {
echo $n->navi();
echo 'По запросу ' . $_SESSION['Lsearch'] . ' ничего не найдено!';
unset($_SESSION['Lwhere']);
unset($_SESSION['Lsearch']);
}
}
echo '<FORM method="POST" action="search.php?">
<label>Найти:</label><br/>
<input type="text" name="load_search"/>
<br/>
<label>Искать по:</label><br/>
<select name="where">
<option value="1">названию</option>
<option value="2">описанию</option>
</select>
<br/>
<input type="submit" name="go" value="Найти"/>
</FORM>';
break;
}
include '../system/foot.php';
?>