Файл: modules/obmen/search.php
Строк: 111
<?php
/* DCMS Special
* Дата последнего редактирования 11.12.2015
* Модифицировал densnet
*/
foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
require_once "../../sys/inc/{$inc}.php";
}
$set['title'] = 'Поиск файлов'; // заголовок страницы
require_once H . 'sys/inc/thead.php';
aut();
#Навигация
echo "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/modules/obmen/'>Обменник</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'>Поиск</a></li>";
echo "</ul>";
echo "</nav>";
$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='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<i class='material-icons'>feedback</i> Нет результатов";
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 "<div class='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
if ($post['ras'] == 'zip' || $post['ras'] == 'rar') {
$r = "<i class='material-icons'>archive</i>";
} elseif ($post['ras'] == 'png' || $post['ras'] == 'jpg' || $post['ras'] == 'jpeg' || $post['ras'] == 'gif') {
$r = "<i class='material-icons'>insert_photo</i>";
} elseif ($post['ras'] == 'mp3') {
$r = "<i class='material-icons'>library_music</i>";
} elseif ($post['ras'] == 'txt') {
$r = "<i class='material-icons'>format_align_center</i>";
} elseif ($post['ras'] == 'mp4' || $post['ras'] == 'avi' || $post['ras'] == '3gp') {
$r = "<i class='material-icons'>video_library</i>";
} elseif ($post['ras'] == 'php') {
$r = "<i class='material-icons'>code</i>";
} else {
$r = "<i class='material-icons'>insert_drive_file</i>";
}
if ($set['echo_rassh'] == 1) {
$ras = ".$post[ras]";
} else {
$ras = NULL;
}
echo "<a href='/modules/obmen$dir[dir]$post[name].$post[ras]?showinfo'>$r $post[name]$ras</a><br />n";
echo "<a href='/modules/obmen$dir[dir]?'><i class='material-icons'>folder</i> $dir[name]</a>";
echo "</div>";
}
if ($k_page > 1) {
echo "<div class='list-group-item'>";
str("search.php?go&", $k_page, $page);
echo "</div>";
} // Вывод страниц
}
echo "<form method='post' action='search.php?go' class='list-group-item'>";
$search = stripcslashes(htmlspecialchars($search));
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='search' name='search' type='text' value='$search' class='validate'>";
echo "<label for='search'>Введите запрос</label>";
echo "</div>";
echo "</div>";
echo "Где искать :<br />";
echo "<select class='form-control' name='sort'>";
echo "<option value='0'>Название</option>n";
echo "<option value='1'" . ($_POST['sort'] == 1 ? " selected='selected'" : null) . ">Описание</option>n";
echo "</select><br />";
echo "<button class='waves-effect waves-light btn'><i class='material-icons'>search</i> Искать</button>";
echo "</form>";
require_once H . 'sys/inc/tfoot.php';