Файл: modules/foto/search.php
Строк: 54
<?php
/* DCMS Special
* Дата последнего редактирования 01.02.2016
* Модифицировал densnet
*/
foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
require_once "../../sys/inc/$inc.php";
}
$set['title'] = lang('Поиск фотографий');
require_once H . 'sys/inc/thead.php';
aut(); // форма авторизации
#Навигация
echo "<div class='card-header'>";
echo "<a href='/' data-toggle='tooltip' data-placement='right' title='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
echo "<a href='/modules/foto/'>" . lang('Фотоальбомы') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
echo lang('Поиск');
echo "</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);
echo "<form class='list-group-item' method="post" action="search.php?go">" . lang('Введите часть текста или название фото') . "<br />";
$usearch = stripcslashes(htmlspecialchars($search));
echo "<input type="text" name="search" maxlength="16" value="$search" class='form-control'/><br />n";
echo "<button class='btn btn-secondary btn-sm'><i class='fa fa-search fa-fw'></i> " . lang('Искать') . "</button>";
echo "</form>n";
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);
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` where `name` 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'];
$q = mysql_query("SELECT * FROM `gallery_foto` WHERE `name` like '%" . mysql_real_escape_string($q_search) . "%' LIMIT $start, $set[p_str]");
if ($k_post == 0) {
$doc->NoResult();
}
if ($k_post > 0) {
echo "<div class='list-group-item'>n";
echo "Найдено результатов: $k_post n";
echo "</div>n";
while ($post = mysql_fetch_assoc($q)) {
$f = $post['id'];
$foto = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery_foto` WHERE `id` = '" . $f . "' LIMIT 1"));
$komm = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_komm` WHERE `id_foto` = '$post[id]'"), 0);
$gallery = mysql_fetch_assoc(mysql_query("SELECT * FROM `gallery` WHERE `id`='" . $foto['id_gallery'] . "' LIMIT 1"));
$ank_p = get_user($gallery['id_user']);
echo '<div class="list-group-item-komm">';
echo toOutput($post['name']);
echo " <br />n";
echo "<div class='photos'>";
echo "<div class='photos_blok'><center><i class='fa fa-star fa-fw'></i> <b>" . $post['rating'] . "</b> <i class='fa fa-comments fa-fw'></i> <b>$komm</b></center></div>";
echo "<a href='/modules/foto/$ank_p[id]/$gallery[id]/$post[id]/'>";
echo "<img style='width:100px;height:100px;' src='/modules/foto/foto150/$foto[id].$foto[ras]' alt='Фото_$foto[id]'/>";
echo "</a></div>";
echo " </div>n";
}
}
if ($k_page > 1) {
str('?go&', $k_page, $page);
}
}
require_once H . 'sys/inc/tfoot.php';