Файл: jokes/search.php
Строк: 55
<?php
include_once '../sys/inc/home.php';
include_once H.'sys/inc/start.php';
include_once H.'sys/inc/compress.php';
include_once H.'sys/inc/sess.php';
include_once H.'sys/inc/settings.php';
include_once H.'sys/inc/db_connect.php';
include_once H.'sys/inc/ipua.php';
include_once H.'sys/inc/fnc.php';
include_once H.'sys/inc/user.php';
$set['title']="Анекдоты - Поиск";
include_once H.'sys/inc/thead.php';
title();
aut();
$search=NULL;
if (isset($_SESSION['search']))$search=$_SESSION['search'];
if (isset($_POST['search']))$search=$_POST['search'];
$_SESSION['search']=$search;
$search=str_replace("( ){2,}"," ",$search);
$search=str_replace("^( ){1,}|( ){1,}$","",$search);
if (isset($_GET['go']) && $search!=NULL){
$search_a=explode(' ', $search);
for($i=0;$i<count($search_a);$i++){
$search_a2[$i]=''.stripcslashes(htmlspecialchars($search_a[$i])).'';
$search_a[$i]=stripcslashes(htmlspecialchars($search_a[$i]));
}
$q_search=str_replace('%','',$search);
$q_search=str_replace(' ','%',$q_search);
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `jokes` WHERE `msg` like '%".mysql_real_escape_string($q_search)."%'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0)echo "<div class='msg'>Извините, по Вашему запросу ничего не найдено</div>";
$q=mysql_query("SELECT * FROM `jokes` WHERE `msg` like '%".mysql_real_escape_string($q_search)."%' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while ($joke=mysql_fetch_assoc($q)){
$ank=get_user($joke['id_user']);
echo "<a href='joke.php?id=".$joke['id']."'><div class='nav2'><img src='img/joke.png'> ".htmlspecialchars($joke['name'])." | <img src='img/view.png'> $joke[view]<br/><b>$ank[nick]</b> | <b>".vremja($joke['time'])."</b></div></a>";
}
if ($k_page>1)str("?go&",$k_page,$page);
}
echo "<form method='post' action='?go'>";
$search=stripcslashes(htmlspecialchars($search));
echo "Что ищем?<br/><input type='text' name='search' maxlength='64' value='$search'> <input type='submit' value='Поиск' /></form>";
echo "<a href='index.php'><div class='foot'><img src='/style/icons/str2.gif'> Анекдоты</div></a>";
include_once H.'sys/inc/tfoot.php';
?>