Файл: modules/obmen/search.php
Строк: 82
<?php
/* Мод "Обменник"
* Версия v0.0.1
* Дата последнего редактирования 29.11.2014
* Двиг DCMS Special
* Модифицировал densnet
* Файл search.php
* Описание: поиск файлов
*/
require_once '../../sys/inc/start.php';
require_once H.'sys/inc/compress.php';
require_once H.'sys/inc/sess.php';
require_once H.'sys/inc/settings.php';
require_once H.'sys/inc/db_connect.php';
require_once H.'sys/inc/ipua.php';
require_once H.'sys/inc/fnc.php';
require_once H.'sys/inc/user.php';
$set['title'] = 'Поиск файлов'; // заголовок страницы
require_once H.'sys/inc/thead.php';
title();
aut();
#Навигация
echo "<div class = 'razd'><a href = '/index.php'>Главная</a> > <a href = '/modules/obmen/'>Зона обмена</a> > <b>Поиск</b></div>";
$search = NULL;
if (isset($_SESSION['search'])) {
$search = $_SESSION['search'];
}
if (isset($_POST['search'])) {
$search = $_POST['search'];
}
$_SESSION['search'] = $search;
$search = preg_replace("#( ){2,}#", " ", $search);
$search = preg_replace("#^( ){1,}|( ){1,}$#", "", $search);
if (isset($_GET['go']) && $search != NULL) {
$search_a = explode(' ', $search);
for ($i = 0; $i < count($search_a); $i++) {
$search_a2[$i] = '<b>' . stripcslashes(htmlspecialchars($search_a[$i])) . '</b>';
$search_a[$i] = stripcslashes(htmlspecialchars($search_a[$i]));
}
$q_search = str_replace('%', '', $search);
$q_search = str_replace(' ', '%', $q_search);
if ($_POST['sort'] != 1) {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `name` like '%" . mysql_real_escape_string($q_search) . "%'"), 0);
} else {
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `obmennik_files` WHERE `opis` like '%" . mysql_real_escape_string($q_search) . "%'"), 0);
}
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo img('error.png') . " Нет результатов";
echo "</div>";
}
if ($_POST['sort'] != 1) {
$q = mysql_query("SELECT * FROM `obmennik_files` WHERE `name` like '%" . mysql_real_escape_string($q_search) . "%' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
} else {
$q = mysql_query("SELECT * FROM `obmennik_files` WHERE `opis` like '%" . mysql_real_escape_string($q_search) . "%' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
}
$i = 0;
while ($post = mysql_fetch_assoc($q)) {
$ras = $post['ras'];
$file = H . "sys/obmen/files/$post[id].dat";
$name = $post['name'];
$size = $post['size'];
$dir = mysql_fetch_array(mysql_query("SELECT * FROM `obmennik_dir` WHERE `id` = '$post[id_dir]' LIMIT 1"));
echo "<table class = 'razd'><tr><td class = 'icon14'>";
if (is_file(H . "style/img/files/$post[ras].png")) {
echo "<img src = '/style/img/files/$post[ras].png'/>";
} else {
echo img('file.png');
}
echo "</td><td class = 'null'>";
if ($set['echo_rassh'] == 1) {
$ras = ".$post[ras]";
} else {
$ras = NULL;
}
echo "<a href='/modules/obmen$dir[dir]$post[name].$post[ras]?showinfo'>$post[name]$ras</a><br />n";
echo '<br /> Папка: <a href="/modules/obmen' . $dir['dir'] . '?">' . $dir['name'] . '</a>';
echo "</td></tr></table>";
}
if ($k_page > 1) {
str("search.php?go&", $k_page, $page);
print '<br />';
} // Вывод страниц
}
echo "<form method="post" action="search.php?go" class="razd">n";
$search = stripcslashes(htmlspecialchars($search));
echo "<input type="text" name="search" maxlength="64" value="$search" /><br />n";
echo "Где искать :<br />";
echo "<select name="sort">n";
echo "<option value='0'>Название</option>n";
echo "<option value='1'" . ($_POST['sort'] == 1 ? " selected='selected'" : null) . ">Описание</option>n";
echo "</select> ";
echo "<button class = 'clik'>".img('sear.png')."</button>";
echo "</form>n";
require_once H.'sys/inc/tfoot.php';