Файл: page/forum/search.php
Строк: 49
<?php
$title = 'Поиск по форуму';
require_once($_SERVER["DOCUMENT_ROOT"]."/inc/head.php");
if (isset($active) && $sys['modules']['forum'] == 1) {
echo '<div class="title">Поиск по форуму</div>
<div class="menu">
<form action="" method="GET">
<input type="text" name="search" value="'.$search.'">
<input type="submit" value="Поиск">
</form></div>';
if ($search) {
$keywords = preg_replace("/[s,]+/", "|", $search);
$stmt_num = $connect->prepare("select count(*) from `topic` where `name` rlike :keywords or `text` rlike :keywords");
$stmt_num->bindValue(':keywords', $keywords);
$stmt_num->execute();
$count_res = $stmt_num->fetchColumn();
if ($count_res == 0) {
echo '<div class="menu">Ничего не найдено!</div>';
} else {
echo '<div class="menu">Найдено по запросу: '.$count_res.'</div>';
$type = 3;
$page = new Pagination($count_res, 10);
$page->setLink('?search=' . $search . '&');
$data = $connect->prepare("select * from `topic` where `name` rlike :keywords or `text` rlike :keywords order by `up` desc limit :start, 10");
$data->bindValue(':keywords', $keywords);
$data->bindValue(':start', $page->start, PDO::PARAM_INT);
$data->execute();
$sql = $data->fetchAll();
foreach ($sql as $row) {
// количество комментариев
$count_comm = Comments::CountMess($row['id'], $type);
echo '<div class="forlink"><a href="/forum/topic/'.$row['id'].'" class="links">'.($row['status'] == 1 ? '<img src="/img/post.png" alt="post">' : '<img src="/img/locked.png" alt="locked">') . $row['name'].'<div class="chi">'.$count_comm.'</div></a></div>';
}
$page->navigation();
}
}
echo '<div class="forlink"><a href="/forum" class="links" ><img src="/img/forum.png" alt="">Форум</a></div>';
} else {
header('Location: /');
}
require($_SERVER["DOCUMENT_ROOT"]."/inc/foot.php");
?>