Файл: masteram_us/blogs/search.php
Строк: 68
<?php
require_once ('../shaxty.php');
check_login();
$title = 'Поиск';
$align = 'left';
include_once (H.'shaxty/head.php');
echo $div4.'<b>Поиск</b>'.$div9;
if(isset($_GET['new'])){
unset($_SESSION['msg']);
unset($_SESSION['s']);
}
if($level>=5){
if(isset($_GET['delblog'])) {
mysql_query("DELETE FROM `blogs` WHERE tip = 'msg' and id = '".check(intval($_GET['delblog']))."'");
mysql_query("DELETE FROM `blog_komm` where blog = '".check(intval($_GET['delblog']))."'");
header ('Location: ?');
}
}
$msg=NULL;
$s=NULL;
if (isset($_POST['msg']))$msg=check($_POST['msg']);
else if (isset($_GET['msg']))$msg=check($_GET['msg']);
else if (isset($_SESSION['msg']))$msg=check($_SESSION['msg']);
$_SESSION['msg']=$msg;
if (isset($_POST['s']))$s=check($_POST['s']);
elseif (isset($_GET['s']))$s=check($_GET['s']);
else if (isset($_SESSION['s']))$s=check($_SESSION['s']);
$_SESSION['s']=$s;
/*$msg=preg_replace("( ){2,}"," ",$msg);
$msg=preg_replace("^( ){1,}|( ){1,}$","",$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);
if($s=='key')$sql = " and `klych` like '%".$q_msg."%'";
else if($s=='msg')$sql = " and `msg` like '%".$q_msg."%'";
else if($s=='about')$sql = " and `about` like '%".$q_msg."%'";
$k_post=mysql_result(mysql_query("select COUNT(*) from blogs WHERE tip = 'msg' ".$sql." and html = 0;"),0);
echo $div1.'<b>По запросу "'.$q_msg.'" найдено: '.$k_post.'</b>'.$div9;
echo '<dl></dl>';
if(empty($_GET['order']))$order = 'time';
else $order = check($_GET['order']);
echo 'Сортировать по: '; // ,'rur-Деньги'
$arr = array('time-Время','name-Имя','yes-Рейтинг','chit-Просмотры');
foreach($arr as $v){
list ($o,$n) = explode('-',$v);
if($order!=$o)echo '<a href="?order='.$o.'">'.$n.'</a>|';
else echo ''.$n.'|';
}
if($order == 'time') $order1 = '`time` DESC';
elseif($order == 'name') $order1 = '`name` DESC';
elseif($order == 'chit') $order1 = '`chit` DESC';
elseif($order == 'yes') $order1 = '`yes` DESC ,`no` ASC';
echo '<br /><br />';
if ($k_post == 0) {
echo "По запросу "".$q_msg."" ничего не найдено<br/>";
} else {
if(!isset($user['id']))$user['max'] = 5;
$max = $user['max'];
$k_page=k_page($k_post,$max);
$page=page($k_page);
$start=$max*$page-$max;
$q2 = mysql_query("select * from `blogs` WHERE tip = 'msg' ".$sql." and html = 0 order by ".$order1." limit $start, $max;");
$d==1;
while($a = mysql_fetch_array($q2)){
$d++;
if(is_integer($d / 2)) echo '<div class="second_name">'; else echo $div2;
$cat=mysql_fetch_array(mysql_query("select * from blogs where tip = 'cat' and `id` = '".$a['refid']."';"));
if($level>=5)$moders = "<a href="/blogs/edit.php?blog=".$a['id']."">[Ред.]</a>|<a href="?delblog=".$a['id']."">[Удал.]</a>";
echo "<img src="img/blog2.png" alt=""/> <b><a href="/blogs/".$a['id']."">".$a['name']."</a></b> (".times($a['time']).") $moders $div9".$a['about']."<br/><img src="img/next.gif" alt=""/> <a href="/blogs/".$a['id']."">Читать полностью</a><dt></dt>
<img src="img/comments.gif" alt=""/> <a href="/blogs/".$a['id']."?komm">Комментарии</a>(".mysql_result(mysql_query("select count(*) as num from blog_komm where `blog` = '".$a['id']."'"),0).")
<br /><img src="img/p2.png" alt=""/> Категория: <a href="cat.php?id=".$cat['id']."">".$cat['name']."</a><br />
<img src="img/ico_inte.png" alt=""/> Автор: ".nik($a['user_id'])."<br />";
if ($a['klych'] != ''){
echo '<img src="img/tag.gif" alt=""/> ';
$record=split(",", $a['klych']);
$num=count($record);
if(!isset($s))$s=1;
$max=round(($num/10)+0.45);
for ($i=0;$i<$num;$i++){
$z++;
$adr=$record[$i];
if($z>0) $zp = ', '; else $zp = '';
if($adr===$q_msg)echo '<b>'.$adr.'</b>'.$zp;
else echo '<a href="/blogs/search.php?s=key&msg='.$adr.'">'.$adr.'</a>'.$zp;
}
}
echo '<dl></dl>';
}
if ($k_page>1){
echo '<br /><dl><dt></dt></dl>';
str("?order=$order&",$k_page,$page); // Вывод страниц
echo '<br /><dl><dt></dt></dl>';
}
}
echo '<br /><div class="button5"><a href="?new">Новый поиск</a></div><br />';
}else{
echo "<br />Введите текст, который Вы хотите найти<br />n";
echo "<form method="post" action="search.php">n";
echo "<input type="text" name="msg" value="$msg" /><br />n";
echo "Поиск в:<br/>";
echo "<input type="radio" name="s" value="msg" checked="checked"/>Текстах<br />";
echo "<input type="radio" name="s" value="about"/>Описаниях<br />";
echo "<input type="radio" name="s" value="key"/>Ключевых словах<br />";
echo "<br /><input class="ibutton" type="submit" value="Найти" />n";
echo "</form>n";
}
echo '<br />';
echo $div1.'<a href="index.php">Блоги</a>'.$div9;
include_once (H.'shaxty/foot.php');
?>