Файл: forums/includ/search.php
Строк: 27
<?
$search=NULL;
if (isset($_SESSION['search']))$search=$_SESSION['search'];
if (isset($_POST['search']))$search=$_POST['search'];
$_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_a2[$i]='<span class="search_c">'.stripcslashes(htmlspecialchars($search_a[$i])).'</span>';
$search_a[$i]=stripcslashes(htmlspecialchars($search_a[$i]));
}
$q_search=str_replace('%','',$search);
$q_search=str_replace(' ','%',$q_search);
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forums_thems` WHERE `msg` like '%".mysql_escape_string($q_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='msg'>Извините, по Вашему запросу ничего не найдено</div>";
$q=mysql_query("SELECT * FROM `forums_thems` WHERE `msg` like '%".mysql_escape_string($q_search)."%' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
$i=0;
while ($them=mysql_fetch_assoc($q)){
$ank=get_user($them['id_user']);
echo "<a href='them.php?id=".$them['id']."'><div class='forum'><img src='img/t.png'> ".output_text($them['name'])." n";
echo" <span style='float:right;border:1px solid gray;backgraund:whitesmoke;border-radius:10px'><b>".mysql_result(mysql_query("SELECT COUNT(*) FROM `forums_post` WHERE `id_them` = '$them[id]'"),0)."</b></span><br/>";
echo "<b>$ank[nick]</b> | <b>".vremja($them['time'])."</b>";
echo "</div></a>";
$i++;
}
if ($k_page>1)str("index.php?go&",$k_page,$page);
}
echo "<div class='gmenu'><img src='img/s.png'> Поиск по форуму:</div>";
echo "<form method='post' action='index.php?go' class='search'>";
$search=stripcslashes(htmlspecialchars($search));
echo "<input type='text' name='search' maxlength='64' value='$search' style='width:70%'/> <input type='submit' value='Поиск' /></form>";
if (isset($_GET['go'])) include_once '../sys/inc/tfoot.php';
?>