Файл: modules/forum/view/search.php
Строк: 60
<?php
/* DCMS Special
* Дата последнего редактирования 12.12.2015
* Модифицировал densnet
* Автор yadalay
*/
$set['title'] = 'Поиск по форуму';
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='alert alert-danger'>Слишком короткий текст.</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 = 'alert alert-danger'>По Вашему запросу ничего не найдено.</div>";
} else {
echo "<div class = 'list-group-item'>Вы ввели: <b>" . 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 = "<span class='fa fa-file-text fa-fw'></span> " . toOutput($theme->name, 1, 1, 0, 0, 0) . " <span class='fa fa-lock'></span>";
} elseif ($theme->type == 1) {
$type = "<span class='fa fa-file-text fa-fw'></span> " . toOutput($theme->name, 1, 1, 0, 0, 0) . " <span class='fa fa-paperclip'></span>";
} else {
$type = "<span class='fa fa-file-text fa-fw'></span> " . toOutput($theme->name, 1, 1, 0, 0, 0) . "";
}
echo "<div class='list-group-item'>";
echo "<span style = 'float:right;'>";
echo "<span class='fa fa-comment fa-fw'></span> $count_posts";
echo "</span>";
echo "<a href = '" . DIR_FORUM . "$forum->id/$razdel->id/$theme->id.html'>$type</a>";
echo " <span style = 'color: #9197a3;' title='" . date::time($theme->time) . "'>" . date::timek($theme->time) . "</span><br />";
echo user($theme->id_user) . " ";
$continue = (mb_strlen($theme->description) > 150) ? '...' : NULL;
echo "<span style = 'color: #9197a3;'>";
echo toOutput($theme->description);
echo "</span>";
echo "</div>";
} else {
continue;
}
echo "</td></tr></table>";
}
if ($k_page > 1) {
str(DIR_FORUM . 'search/', $k_page, $page);
}
}
}
}
echo "<form action='" . DIR_FORUM . "search.html' method = 'post' class = 'list-group-item' style='border-bottom: 1px solid #dcdee3;'>";
echo "Введите текст (мин. 3 символа):<br />";
echo "<input class='form-control' type='text' name='text' value='" . ((isset($_SESSION['search'])) ? toOutput($_SESSION['search']) : NULL) . "' /><br />";
echo "<button name='search' class='btn btn-success'>Поиск</button>";
echo "</form>";
echo "<div class = 'list-group-item'><a href = '" . DIR_FORUM . "'><span class='fa fa-arrow-left fa-fw'></span> Вернуться в форум</a></div>";