Файл: soc-set/moduls/search/index.php
Строк: 141
<?php
require_once('../../core/start.php');
check_auth();
head('Поиск по сайту');
panel();
echo DIV_BLOCK . '
<form action="'.HOME.'/search/" method="post">
<div style="font: 11px Tahoma;"> <input name="sql" style = "border: 1px solid #d8d8d8; font-family : Tahoma; color: #686868; padding: 5px; margin:1px; border-radius: 3px; width:80%;"/>
<input type="submit" value="Поиск"/>
</div>
</form>' . CLOSE_DIV;
$sql = html($_POST['sql']);
if (empty($sql)) {
$sql = html($_SESSION['search']);
} else {
$_SESSION['search'] = $sql;
}
switch ($_GET['act']) {
default:
$count = DB::$dbs->querySingle("SELECT COUNT(`user_id`) FROM ".USERS." WHERE `nick` LIKE '%".$sql."%'");
echo DIV_LI . '<a href="'.HOME.'/search/user/">Пользователи</a> <span class="count">'.$count.'</span>' . CLOSE_DIV;
$count = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".BLOG." WHERE `title` LIKE '%".$sql."%' OR `blog` LIKE '%".$sql."%'");
echo DIV_LI . '<a href="'.HOME.'/search/blog/">Блоги</a> <span class="count">'.$count.'</span>' . CLOSE_DIV;
$count = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".FORUMS_THEME." WHERE `name` LIKE '%".$sql."%'");
echo DIV_LI . '<a href="'.HOME.'/search/forumt/">Темы на форуме</a> <span class="count">'.$count.'</span>' . CLOSE_DIV;
$count = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".FORUM_POST." WHERE `msg` LIKE '%".$sql."%'");
echo DIV_LI . '<a href="'.HOME.'/search/forump/">Посты на форуме</a> <span class="count">'.$count.'</span>' . CLOSE_DIV;
$count = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".GROUPS." WHERE `name` LIKE '%".$sql."%' OR `info` LIKE '%".$sql."%'");
echo DIV_LI . '<a href="'.HOME.'/search/group/">Сообщества</a> <span class="count">'.$count.'</span>' . CLOSE_DIV;
$count = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LIB_ARTICL." WHERE `title` LIKE '%".$sql."%' OR `info` LIKE '%".$sql."%'");
echo DIV_LI . '<a href="'.HOME.'/search/lib/">Статьи в библиотеке</a> <span class="count">'.$count.'</span>' . CLOSE_DIV;
break;
case 'user':
echo DIV_AUT . '<b>Поиск пользователей</b>' . CLOSE_DIV;
$sql = html($_SESSION['search']);
$count = DB::$dbs->querySingle("SELECT COUNT(`user_id`) FROM ".USERS." WHERE `nick` LIKE '%".$sql."%'");
if (empty($count)) {
echo DIV_LI . 'Без результата' . CLOSE_DIV;
} else {
$n = new Navigator($count,10,'&act=' . html($_GET['act']) . '&');
$sql = DB::$dbs->query("SELECT * FROM ".USERS." WHERE `nick` LIKE '%".$sql."%' ORDER BY `user_id` DESC LIMIT {$n->start()}, 10");
while($ank = $sql -> fetch()) {
echo DIV_BLOCK . '<b>' . userLink($ank['user_id']) . '</b><br />' . $ank['name'] . ', (' . (!empty($ank['age']) ? 'Возраст: ' . $ank['age'] : 'возраст не указан') . ') <br />' . city($ank['city']) . CLOSE_DIV;
}
echo $n->navi();
}
break;
case 'blog':
echo DIV_AUT . '<b>Поиск в блоге</b>' . CLOSE_DIV;
$sql = html($_SESSION['search']);
$count = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".BLOG." WHERE `title` LIKE '%".$sql."%' OR `blog` LIKE '%".$sql."%'");
if (empty($count)) {
echo DIV_LI . 'Без результата' . CLOSE_DIV;
} else {
$n = new Navigator($count,10,'&act=' . html($_GET['act']) . '&');
$sql = DB::$dbs->query("SELECT * FROM ".BLOG." WHERE `title` LIKE '%".$sql."%' OR `blog` LIKE '%".$sql."%' ORDER BY `id` DESC LIMIT {$n->start()}, 10");
while($blog = $sql -> fetch()) {
echo DIV_BLOCK . $blog['title'] . ' | ' . userLink($blog['user_id']) . '<br />';
echo '<form action="'.HOME.'/blog/'.$blog['id'].'/" method="POST"><input type="submit" value="Подробнее" /></form>';
echo CLOSE_DIV;
}
echo $n->navi();
}
break;
case 'forumt':
echo DIV_AUT . '<b>Поиск тем на форуме</b>' . CLOSE_DIV;
$sql = html($_SESSION['search']);
$count = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".FORUMS_THEME." WHERE `name` LIKE '%".$sql."%'");
if (empty($count)) {
echo DIV_LI . 'Без результата' . CLOSE_DIV;
} else {
$n = new Navigator($count,10,'&act=' . html($_GET['act']) . '&');
$sql = DB::$dbs->query("SELECT * FROM ".FORUMS_THEME." WHERE `name` LIKE '%".$sql."%' ORDER BY `id` DESC LIMIT {$n->start()}, 10");
while($theme = $sql -> fetch()) {
$posts = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".FORUMS_POST." WHERE `theme_id` = ? ", array($theme['id']));
echo DIV_LI . '<a href="'.HOME.'/forum/'.$theme['forum_id'].'/'.$theme['forumc_id'].'/'.$theme['id'].'/">'.$theme['name'].'</a> ['.$posts.']' . CLOSE_DIV;
}
echo $n->navi();
}
break;
case 'forump':
echo DIV_AUT . '<b>Поиск постов на форуме</b>' . CLOSE_DIV;
$sql = html($_SESSION['search']);
$count = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".FORUM_POST." WHERE `msg` LIKE '%".$sql."%'");
if (empty($count)) {
echo DIV_LI . 'Без результата' . CLOSE_DIV;
} else {
$n = new Navigator($count,10,'&act=' . html($_GET['act']) . '&');
$sql = DB::$dbs->query("SELECT * FROM ".FORUM_POST." WHERE `msg` LIKE '%".$sql."%' ORDER BY `id` DESC LIMIT {$n->start()}, 10");
while($post = $sql -> fetch()) {
echo DIV_BLOCK;
echo '<b>' . userLink($post['user_id']) . '</b> [' . vrem($post['time']) . ']<br />';
if (!empty($post['ct'])) {
$ct = DB::$dbs->queryFetch("SELECT `msg` FROM ".FORUMS_POST." WHERE `id` = ? ", array($post['ct']));
echo DIV_CT . '<small><b>Цитата:</b></small><br />' . text($ct['msg']) . CLOSE_DIV;
}
echo text($post['msg']);
if (!empty($post['file'])) {
$path = '../../files/forum/'.$post['file'];
$size = get_size(filesize($path));
$path_info = pathinfo($path);
echo '<br /><br />Прикреплен файл: <a href="'.HOME.'/files/forum/'.$post['file'].'"><b>[Скачать]</b></a> ['.$path_info['extension'].'] ['.$size.']<br />';
}
echo '<br /><br /><b>Тема:</b><br />';
$theme = DB::$dbs->queryFetch("SELECT * FROM ".FORUMS_THEME." WHERE `id` = ? ", array($post['theme_id']));
$posts = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".FORUMS_POST." WHERE `theme_id` = ? ", array($post['theme_id']));
echo '<a href="'.HOME.'/forum/'.$post['forum_id'].'/'.$post['forumc_id'].'/'.$post['theme_id'].'/">'.$theme['name'].'</a> ['.$posts.']<br />';
echo CLOSE_DIV;
}
echo $n->navi();
}
break;
case 'group':
echo DIV_AUT . '<b>Поиск сообществ</b>' . CLOSE_DIV;
$sql = html($_SESSION['search']);
$count = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".GROUPS." WHERE `name` LIKE '%".$sql."%' OR `info` LIKE '%".$sql."%'");
if (empty($count)) {
echo DIV_LI . 'Без результата' . CLOSE_DIV;
} else {
$n = new Navigator($count,10,'&act=' . html($_GET['act']) . '&');
$sql = DB::$dbs->query("SELECT * FROM ".GROUPS." WHERE `name` LIKE '%".$sql."%' OR `info` LIKE '%".$sql."%' ORDER BY `id` DESC LIMIT {$n->start()}, 10");
while($group = $sql -> fetch()) {
echo DIV_BLOCK;
echo '<a href="'.HOME.'/groups/'.$group['id'].'/"><b>' . $group['name'] . '</b></a> ['.$group['peoples'].' чел.]<br />';
echo $group['info'] . '<br />';
echo CLOSE_DIV;
}
echo $n->navi();
}
break;
case 'lib':
echo DIV_AUT . '<b>Поиск статей в библиотеке</b>' . CLOSE_DIV;
$sql = html($_SESSION['search']);
$count = DB::$dbs->querySingle("SELECT COUNT(`id`) FROM ".LIB_ARTICL." WHERE `title` LIKE '%".$sql."%' OR `info` LIKE '%".$sql."%'");
if (empty($count)) {
echo DIV_LI . 'Без результата' . CLOSE_DIV;
} else {
$n = new Navigator($count,10,'&act=' . html($_GET['act']) . '&');
$sql = DB::$dbs->query("SELECT * FROM ".LIB_ARTICL." WHERE `title` LIKE '%".$sql."%' OR `info` LIKE '%".$sql."%' ORDER BY `id` DESC LIMIT {$n->start()}, 10");
while($articl = $sql -> fetch()) {
echo DIV_LI . '<a href="'.HOME.'/lib/'.$articl['folder_id'].'/'.$articl['folderc_id'].'/'.$articl['id'].'/">'.$articl['title'].'</a>' . CLOSE_DIV;
}
echo $n->navi();
}
break;
}
if (isset($_GET['act'])) {
echo DIV_LI . '<a href="'.HOME.'/search/">Вернуться назад</a>' . CLOSE_DIV;
}
$array = array();
nav($array);
require_once('../../core/stop.php');
?>