Файл: pages/rewrite_search.php
Строк: 74
<?php # Created by Up
include_once '../sistem/start.php';
include_once $config['OTS'].'sistem/config.php';
include_once $config['OTS'].'sistem/function.php';
include_once $config['OTS'].'sistem/db.php';
//include_once $config['OTS'].'sistem/users.php';
$config['link']=3;
$config['TITLE']='Поиск сайтов';
include_once $config['OTS'].'sistem/head.php';
$search='';
$top='';
$error=false;
if(isset($_GET['search']) and isset($_GET['top']))
{
$search=filtr($_GET['search']);
$top=((int)abs($_GET['top']));
if(!empty($search))
{
$db='(';
$text=explode(' ',mysql_escape_string(str_replace('%','',$search)));
foreach($text as $i=>$q)
{
if(mb_strlen($q)>=3)
{
$text[$i]='/'.preg_quote($q).'/iu';
$db.='`opisanie` LIKE '%'.$q.'%' OR `name` LIKE '%'.$q.'%' OR ';
}
else
unset($text[$i]);
}
$db=preg_replace('/ OR $/','',$db).')';
if(!empty($db) and count($text)<=5)
{
if($count=mysql_result(mysql_query('SELECT COUNT(*) FROM `site` WHERE'.($top!=0?' `top`=''.$top.'' and':'').' '.$db.';'),0)>=1)
{
if($page=page($count,isset($_GET['page'])?$_GET['page']:1))
{
$sql=mysql_query('SELECT * FROM `site` WHERE'.($top!=0?' `top`=''.$top.'' and':'').' '.$db.' ORDER BY `kredit` DESC LIMIT '.$page['ot'].','.$_SESSION['kol_sites'].';');
while($arr1=mysql_fetch_assoc($sql))
{
print '<a class="link"'.($_SESSION['wiev_opis']==1?' title="'.$arr1['opisanie'].'"':'').' href="../site/'.$arr1['id'].'/index.php">'.preg_replace($text,'<span class="yes">