Файл: modules/forum/view/search.php
Строк: 38
<?php
/* Мод "Форум"
* Версия v0.0.1
* Дата последнего редактирования 27.11.2014
* Двиг DCMS Special
* Модифицировал densnet
* Автор yadalay
* Файл search.php
* Описание: поиск по форуму
*/
$set['title'] = 'Поиск по форуму';
require_once H.'sys/inc/thead.php';
title() . aut();
#Навигация
echo "<div class = 'navigation'><a href = '/index.php'>Главная</a> > <a href = '".DIR_FORUM."'>Форум</a> > <b>Поиск</b></div>";
if (isset($_POST['search']) || isset($_SESSION['search'])) {
if (!isset($_POST['search']) && isset($_SESSION['search'])) {
$search = $_SESSION['search'];
} else {
$search = mysql_real_escape_string(trim($_POST['text']));
$_SESSION['search'] = mb_strtolower($search);
}
if (mb_strlen($search) < 3) {
echo "<div class = 'errs'>Слишком короткий текст.</div>";
} else {
$k_post = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_themes` WHERE `name` LIKE "%' . $_SESSION['search'] . '%" OR `description` LIKE "%' . $_SESSION['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'>По Вашему запросу ничего не найдено.</div>";
} else {
echo "<div class = 'razd'>Вы ввели: <b>".text::toOutput($_SESSION['search'])."</b></div>";
$themes = mysql_query('SELECT * FROM `forum_themes` WHERE `name` LIKE "%' . $_SESSION['search'] . '%" OR `description` LIKE "%' . $_SESSION['search'] . '%" ORDER BY `time_post` ASC LIMIT ' . $start . ', ' . $set['p_str']);
while ($theme = mysql_fetch_object($themes)) {
$theme->name = str_replace($_SESSION['search'], $_SESSION['search'], mb_strtolower($theme->name));
$theme->description = str_replace($_SESSION['search'], $_SESSION['search'], mb_strtolower($theme->description));
$razdel = mysql_fetch_object(mysql_query('SELECT `id`, `id_forum` FROM `forum_razdels` WHERE `id` = ' . $theme->id_razdel));
$forum = mysql_fetch_object(mysql_query('SELECT `id`, `access` FROM `forum` WHERE `id` = ' . $razdel->id_forum));
if ($forum->access == 0 || (isset($user) && $forum->access == 1 && $user['group_access'] > 7) || (isset($user) && $forum->access == 2 && $user['group_access'] > 1)) {
$count_posts = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_posts` WHERE `id_theme` = ' . $theme->id), 0);
if ($theme->reason_close != NULL) {
$type = '_close';
} elseif ($theme->type == 1) {
$type = '_up';
} else {
$type = NULL;
}
echo "<table class = 'razd'><tr><td class = 'null'>";
echo "<span style = 'float:right;'>";
echo "<a class = 'count'>" . img('comment_white.png') . " $count_posts</a>";
echo "</span>";
echo "<img src = '/style/img/theme$type.png' />";
echo "<a href = '".DIR_FORUM."$forum->id/$razdel->id/$theme->id.html'>" . text::toOutput($theme->name, 1, 1, 0, 0, 0) . "</a> (" . date::time($theme->time) . ")<br />";
echo text::toOutput($theme->description);
} else {
continue;
}
echo "</td></tr></table>";
}
if ($k_page > 1) {
str('/modules/forum/search/', $k_page, $page);
}
}
}
}
echo "<form action = '".DIR_FORUM."search.html' method = 'post' class = 'razd'>";
echo "<b>Введите текст (мин. 3 символа):</b><br />";
echo "<input type = 'text' name = 'text' value = '" . ((isset($_SESSION['search'])) ? text::toOutput($_SESSION['search']) : NULL) . "' /><br />";
echo "<input type = 'submit' name = 'search' value = 'Поиск' /></form>";
echo "<div class = 'razd'>" . img('left.png') . " <a href = '".DIR_FORUM."'>Вернуться в форум</a></div>";