Вход Регистрация
Файл: search.php
Строк: 64
<?php
session_start
();
define('MTOP', 1);
$title = 'Поиск сайта';
require_once (
'system/connect.php');
require_once (
'system/core.php');
require_once (
'system/function.php');
require_once(
'head.php');

echo 
'<div class="title3">Поиск сайта</div>';
echo 
'<form action="'.htmlspecialchars($_SERVER['PHP_SELF']).'" method="POST" name="form">
<div class="title">
Введите запрос:<br/>
<input type="text" name="search" maxlenght="110" value="'
.htmlspecialchars($_POST['search']).'"/><br/>
Параметры поиска :<br/>
<select name="m">
<option value="1">url</option>
<option value="2">Название сайта</option>
<option value="3">Описание сайта</option>
</select><br/>
<input name="n" type="checkbox" value="1"/> Точный поиск<br/>
<input type="submit" name="go"value="Поиск">
</form></div>'
;
if (isset(
$_POST['go']) ) {
if (
mb_strlen($_POST['search']) < 3 || mb_strlen($_POST['search']) > 100 ) {
$error[2] = 'Длина запроса должна быть не менее 4 символов и не привышать 100 символов';
}
}
if (!empty(
$error)) {
echo 
'<div class="title">';
foreach(
$error as $value) {
echo 
"<center>$value<br /></center>";
}
echo 
'</div>';
require_once (
'foot.php');
exit();
}

$mm = isset ($_POST['m']) ? intval($_POST['m']) : '';
$mm = $mm ? $mm : rawurldecode(trim($_GET['m']));
$n = isset ($_POST['n']) ? $_POST['n'] : '';
$n = $n ? $n : rawurldecode(trim($_GET['n']));

$search = isset ($_POST['search']) ? trim($_POST['search']) : '';
$search = strtr($search, array('_' => '\_', '%' => ' ','$' => ' ', '*' => '%'));
$search = $search ? $search : rawurldecode(trim($_GET['search']));
if (
$search) {
$search_db = 'LIKE '' . mysql_real_escape_string('%' . $search . '%') . ''';
if (
$_POST['n'] == false) $search_db = 'LIKE '' . mysql_real_escape_string('%' . $search . '%') . ''';
if (
$_POST['n'] == true) {
$search_db = '= "'.mysql_real_escape_string($search).'"';
}
$zap = '`about`';
if (
$_POST['m'] == 1 || $_GET['mm'] == 1) $zap = '`url`';
if (
$_POST['m'] == 2 || $_GET['mm'] == 2) $zap = '`name`';
if (
$_POST['m'] == 3 || $_GET['mm'] == 3) $zap = '`about`';

$count = mysql_num_rows(mysql_query("SELECT * FROM `sait` WHERE ".$zap." ".$search_db." "));
if(
$count > 0)
{
$total=intval(($count-1)/$page_sait)+1; 
$page=abs(intval($_GET['page'])); 
if(empty(
$page) OR $page < 0)
{
$page = 1; 
}
if(
$page > $total)
{
$page = $total; 
}
$past=intval($count/$page_sait);  
$start=$page*$page_sait-$page_sait; 
$saits = mysql_query("SELECT * FROM `sait` WHERE ".$zap." ".$search_db." ORDER BY `id` DESC LIMIT ".$start.",".$page_sait."");
while(
$row = mysql_fetch_array($saits)) 
{
$start++;
echo 
'<div class="title"><b>'.$start.'. <a href="/out/'.$row['id'].'.php">'.$row['name'].'</a></b> (<b><a href="http://'.$set['home'].'/infos.php?id='.$row['id'].'">'.$row['hosts'].'/'.$row['hits'].'</a></b>)<br/>';
if(
mb_strlen($row['about']) > 150)
{
$text = substr($row['about'],0,150);
echo 
''.$text.'..'; 
}
else
{
echo 
''.$row['about'].'..'; 
}
echo 
'</div>';
}
navigation($all,$page_top,$page,'http://'.$set['home'].'/search?search='.$search.'&n=0&mm='.$mm.'&page=',$total);
}
else {
echo 
'<div class="title"><center>Ничего не найдено</center></div>';
}
}

require_once(
'foot.php');
?>
Онлайн: 3
Реклама