Файл: forumm/search.php
Строк: 29
<?php
include_once '../sys/inc/thead.php';
title();
err();
$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)
{
$q_search=str_replace('%','',$search);
$q_search=str_replace(' ','%',$q_search);
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum` WHERE `type` = 'tema' AND `name` like '%".mysql_escape_string($q_search)."%' OR `text` 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="post">Извините, по Вашему запросу ничего не найдено</div>';
$q=mysql_query("SELECT * FROM `forum` WHERE `type` = 'tema' AND `name` like '%".mysql_escape_string($q_search)."%' OR `text` like '%".mysql_escape_string($q_search)."%' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
echo'<table class="post">';
while ($post = mysql_fetch_assoc($q))
{
if($num==1){echo "<div style='padding:1px;background-color:#edeff4;border-top:1px dotted #CCC'>";$num=0;}else{echo "<div style='padding:1px;background-color:#fff;border-top:1px dotted #CCC'>";$num=1;}
$us=get_user($post['id_user']);
if($post['up']>0)if($post['up']>0)echo "<img src='http://i.spaces.ru//stick.gif' alt='' /> n";
echo "<a href='/forumm/?id=$post[id]'>$post[name]</a> (".vremja($post['time']).")n";
if($post['close']==1)echo " <img src='http://i.spaces.ru//topic_locked.gif' alt='loced' />n";
echo'</div>';
}
echo'</table>';
if ($k_page>1)str("?search&go&",$k_page,$page); // Вывод страниц
}
else
echo"<span style='font-size:small;color:darkblue'><b>Текст для поиска:</b></span><br/>";
echo'<form method="post" action="?search&go" class="search">';
$search=stripcslashes(htmlspecialchars($search));
echo'<input type="text" name="search" maxlength="64" value="'.$search.'" /><br/>';
echo'<input type="submit" value="Поиск" />';
echo'</form>';
echo'<div class="foot">';
echo'<a href="/forumm">Форум</a><br />';
echo'</div>';
?>