Файл: world-faces.ru/world-faces.ru/forum/search.php
Строк: 106
<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/dbPDO.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
$set['title']='Форум - поиск';
include_once '../sys/inc/thead.php';
title();
aut(); // форма авторизации
echo "<div class="menu">n";
echo "• <a href="index.php" title="Вернуться к подфорумам">Форум</a> / Поискn";
echo "</div>n";
$search=NULL;
if (isset($_SESSION['search']))$search=$_SESSION['search'];
if (isset($_POST['search']))$search=$_POST['search'];
if ($search==NULL)
unset($_SESSION['search']);
else
$_SESSION['search']=$search;
$search=ereg_replace("( ){2,}"," ",$search);
$search=ereg_replace("^( ){1,}|( ){1,}$","",$search);
if (isset($_GET['go']) && $search!=NULL)
{
$search_a=explode(' ', $search);
for($i=0;$i<count($search_a);$i++)
{
$search_a[$i]='#'.preg_quote(esc(trim(stripcslashes(htmlspecialchars($search_a[$i]))))).'#uim';
}
$adm_add=NULL;
if (!isset($user) || $user['level']==0){
$q222=DB::$dbs->query("SELECT * FROM `forum_f` WHERE `adm` = '1'");
while ($adm_f = $q222->fetch())
{
$adm_add.="`id_forum` <> '$adm_f[id]' AND ";
}
}
$q_search=str_replace('%','',$search);
$q_search=str_replace(' ','%',$q_search);
$k_post=DB::$dbs->querySingle("SELECT COUNT(*) FROM `forum_p` WHERE$adm_add `msg` like ?",array("%$q_search%"));
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>n";
if ($k_post==0)
{
echo " <tr>n";
echo " <td class='p_t'>n";
echo "По вашему запросу ничего не найденоn";
echo " </td>n";
echo " </tr>n";
}
$q=DB::$dbs->query("SELECT * FROM `forum_p` WHERE$adm_add `msg` like ? ORDER BY `id` DESC LIMIT $start, $set[p_str]",array("%".chck($q_search)."%"));
while ($post = $q->fetch())
{
$forum =DB::$dbs->queryFetch("SELECT * FROM `forum_f` WHERE `id` =? LIMIT 1",array($post['id_forum']));
$razdel=DB::$dbs->queryFetch("SELECT * FROM `forum_r` WHERE `id` =? LIMIT 1",array($post['id_razdel']));
$them =DB::$dbs->queryFetch("SELECT * FROM `forum_t` WHERE `id` =? LIMIT 1",array($post['id_them']));
$ank =DB::$dbs->queryFetch("SELECT * FROM `user` WHERE `id` =? LIMIT 1",array($post['id_user']));
echo " <tr>n";
if ($set['set_show_icon']==2){
echo " <td class='icon48' rowspan='2'>n";
avatar($ank['id']);
echo " </td>n";
}
elseif ($set['set_show_icon']==1)
{
echo " <td class='icon14'>n";
echo "<img src='/style/themes/$set[set_them]/user/$ank[pol].png' alt='' />";
echo " </td>n";
}
echo " <td class='p_t'>n";
echo "<a href='/info.php?id=$ank[id]' title='Анкета $ank[nick]'>$ank[nick]</a> (".vr($post['time']).")n";
echo " </td>n";
echo " </tr>n";
echo " <tr>n";
if ($set['set_show_icon']==1)echo " <td class='p_m' colspan='2'>n"; else echo " <td class='p_m'>n";
echo "<a href='/forum/$forum[id]/'>$forum[name]</a> / <a href='/forum/$forum[id]/$razdel[id]/'>$razdel[name]</a> / <a href='/forum/$forum[id]/$razdel[id]/$them[id]/mark/".stripcslashes(htmlspecialchars($search))."'>$them[name]</a><br />n";
//echo esc(trim(br(bbcode(smiles(links(stripcslashes(htmlspecialchars($post['msg']))))))))."<br />n";
echo esc(preg_replace($search_a, '<span class="search_cit">\0</span>', trim(br(bbcode(stripcslashes(htmlspecialchars($post['msg'])))))))."<br />n";
echo " </td>n";
echo " </tr>n";
}
echo "</table>n";
if ($k_page>1)str("search.php?go&",$k_page,$page); // Вывод страниц
}
else
echo "Введите текст, который Вы хотите найти<br />n";
echo "<form method="post" action="search.php?go">n";
$search=stripcslashes(htmlspecialchars(esc($search)));
echo "<input type="text" name="search" maxlength="64" value="$search" />n";
echo "<input type="submit" value="Поиск" />n";
echo "</form>n";
include_once '../sys/inc/tfoot.php';
?>