Файл: other/search.php
Строк: 29
<?php
require_once('../core/start.php');
$title = 'Поиск';
require_once(root.'core/header.php');
echo '<div class="ot4">'.$title.'</div>';
if(isset($_GET['new'])){
unset($_SESSION['msg']);
}
$msg=NULL;
if(isset($_POST['msg'])) $msg = secur($_POST['msg']);
elseif (isset($_GET['msg'])) $msg = secur($_GET['msg']);
elseif (isset($_SESSION['msg'])) $msg = secur($_SESSION['msg']);
$_SESSION['msg']=$msg;
$msg = $msg ? $msg : rawurldecode(trim($msg));
$msg = preg_replace("/[^wx7F-xFFs]/", " ", $msg);
if ($msg!=NULL){
$msg_a = explode(' ', $msg);
for($i=0;$i<count($msg_a);$i++){
$msg_a[$i]='#'.preg_quote($msg_a[$i]).'#uim';
}
$q_msg = str_replace('%','',$msg);
$q_msg = str_replace(' ','%',$q_msg);
$k_post = core::$dbs->querySingle("SELECT COUNT(id) FROM `blog` WHERE `tags` like '%".$q_msg."%' AND `text` LIKE ?",array("%$q_msg%"));
$n = new pager($k_post, $end, '?msg='.$q_msg.'&');
$array = core::$dbs->query("SELECT * FROM `blog` WHERE `tags` like '%".$q_msg."%' AND `text` LIKE ? ORDER BY `time` DESC LIMIT $n->start,$end",array("%$q_msg%"));
if ($k_post == 0) {
err('По запросу '.$q_msg.' ничего не найдено');
} else {
while($arr = $array->fetch()){
$message = (mb_strlen($arr['text'])>120 ? mb_substr($arr['text'],0,120, 'UTF-8') . '...': out($arr['text']) . '');
echo '<div class="vib"><b>'.stripslashes($arr['name']).'</b> ['.times($arr['time']).']</div>
<div class="block">
<p>' . $message .'</p><p><br/> '.(strlen($arr['text'])>120 ? '<a class="lenk" href="/blog/'.$arr['latname'].'.html">Далее →</a> |':NULL).' <a class="lenk" href="/comment/'.$arr['id'].'">Мнения ('.core::$dbs->querySingle("SELECT COUNT(id) from `comments` where `blog` = ?",array($arr['id'])).')</a></p></div>';
}
}
echo $n->pag();
echo '<div class="block"><a href="?new">Новый поиск</a></div>';
} else {
echo '<div class="block">Введите текст, который Вы хотите найти:<br/><form method="post" action="?">Текст:<br/><input type="text" name="msg" value="'.$msg.'" /><br/><input type="submit" name="" value="Искать"/></form></div>';
}
require_once(root.'core/footer.php');
?>