Файл: poisk.php
Строк: 89
<?php
include_once 'inc/bd.php';
include_once 'inc/fun.php';
$title = 'Поиск';
include_once 'inc/v.php';
####
echo '<div class="rmenu"><strong>Поиск по блогам</strong></div>';
####
$search = html(ms(rawurldecode($_GET['s'])));
//echo '<div class="menu"><form action="" method="GET">';
//echo '<input type="text" maxlength="50" value="'.$search.'" name="s" /> ';
//echo '<input type="submit" value="Поиск" name="submit" /><br />';
//echo '</form></div>';
$search = substr($search,0,50);
####Errors!####
$error = false;
if ($search && mb_strlen($search) < 3) $error = 'Общая длина поискового запроса должна быть не менее 3 букв.';
if ($search && !$error)
{
####
echo '<div class="info">Результаты поиска по запросу <strong>'.$search.'</strong>:</div>';
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `text` WHERE `text` LIKE '%".$search."%' OR `name` LIKE '%".$search."%';"), 0);
####
$get = num($_GET['page']);
if(isset($get)){$page = $get;}else{$page=1;}
$str = ceil($all/$npage);
if(!$str) $pages = 1;
if($page>$str or $page<=0) $page=1;
if($start>$all or $start<=0) $start = 0;
if($page) $start = ($page - 1) * $npage;
else $start = 0;
####
if($all>0)
{
$res = mysql_query("SELECT * FROM `text` WHERE `text` LIKE '%".$search."%' OR `name` LIKE '%".$search."%' ORDER BY `id` DESC LIMIT $start,$npage");
while ($row = mysql_fetch_assoc($res))
{
$id = num($row['id']);
$cat = num($row['cat_id']);
$catnames = mysql_fetch_assoc(mysql_query("SELECT * FROM `cat` WHERE `id`='$cat'"));
if(empty($catnames)) {$catname = 'Нет категории';} else{$catname = html($catnames['name']);}
$date = $row['date'];
$news = num($row['news']);
$comment = num($row['comment']);
$comm = html($row['comm']);
$name = html($row['name']);
$text = html($row['text']);
$text = anonc($text,$anonc);
$text = nl2br($text);
$text = adminbb(parsebb(smiles($text)));
$text = $text.'...';
####
$nname = mysql_fetch_assoc(mysql_query("SELECT * FROM `comment` WHERE `text_id` = '$id' ORDER BY `id` DESC LIMIT 1"));
$user = antirek(html($nname['user']));
if ($user == $adminlogin) {$user = '<span style="color:#900">'.$user.' (УКДПЕ)</font>';}
if (!empty($user)) {$lcom = ' <sup>'.$user.'</sup>';} else {$lcom = '';}
if (!empty($news)){$div = '<div class="info"><strong>Новость: ';}else{$div = '<div class="menu"><strong>';}
####
echo $div.'<a href="'.$home.'/blog/'.$id.'">'.$name.'</a></strong> | '.$date.'<hr>
<span class="anonc">'.$text.'</span><br/>
<a href="'.$home.'/blog/'.$id.'">Далее →</a> ';
if ($comment !== 1){
echo '| <a href="'.$home.'/comment/'.$id.'">Комменты</a> ('.$comm.') '.$lcom.'';
}
echo '</div>';
}
}
else
{
echo '<div class="menu">Ни чего не найдено</div>';
}
echo '<div class="nmenu">Всего совпадений: '.$all.'<hr/>';
if ($all > $npage)
{
####
$pp = $page - 2;
$pp2 = $page + 3;
$backpage = $page - 1;
$uppage = $page + 1;
if ($str>1){
if ($page > 1)
echo '<a class="str" href="'.$home.'/poisk.php?page='.$backpage.'&s='.$search.'">«</a> ';
if($pp<$all && $pp>0 && $page>3)
echo '<a class="str" href="'.$home.'/poisk.php?page=1&s='.$search.'">1</a> ... ';
for($i=$pp; $i<$pp2;$i++)
{
if($i<$all && $i>0)
{
if ($i > $str )
break;
if ($page==$i)
echo '<span class="str_active"><b>'.$i.'</b></span> ';
else echo '<a class="str" href="'.$home.'/poisk.php?page='.$i.'&s='.$search.'">'.$i.'</a> ';
}
}
if ($i <= $str) {if($pp2<$all) echo ' ... <a class="str" href="'.$home.'/poisk.php?page='.$str.'&s='.$search.'">'.$str.'</a>';}
if ($page < $str)
{
echo '<a class="str" href="'.$home.'/poisk.php?page='.$uppage.'&s='.$search.'">»</a> ';
}
}
####
}
echo '</div>';
}
else
{
if ($error)
echo '<div class="err">' . $error . '</div>';
echo '<div class="amenu"><span class="small">Длина запроса: максимум 50 символов, лишний текст будет обрезан.<br />Поиск нечувствителен к регистру букв</span></div>';
}
include_once 'inc/n.php';
?>