Размер файла: 2.98Kb
<?php
include '../inc/config.inc.php';
include '../inc/wap_tags.inc.php';
include '../inc/functions.inc.php';
connect_to_db();
$text = $_POST["text"];
$text = iconv('utf-8', 'windows-1251', $text);
$text = iconv('windows-1251', 'utf-8', $text);
$text = substr(eregi_replace("[^АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЬЫЭЮЯабвгдеёжзийклмнопрстуфхцчшщъьыэюяQWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm0123456789?,. -]", "", $text),0,30);
if(empty($text) && empty($_POST['where'])){
include "config.php";
include './inc/head.php';
print "<div class=\"rh\"><a href=\"/xhtml/category.xhtml\">Категория</a> | <a href=\"/xhtml/Top-100/\">ТОП-100</a> | Поиск</div>\n";
print "<div class=\"rb\">\n";
print "<div class='form'>\n";
print "<form action='/xhtml/search.xhtml' method='post'>\n";
print "Что ищем:<br />\n";
print "<input type='text' name='text' maxlength='20' /><br />\n";
print "Где ищем:<br />\n";
print "<select name='where'>\n";
print "<option value='info'>В описании</option>\n";
print "<option value='name'>В названиях</option>\n";
print "<option value='link'>В URL</option>\n";
print "</select>\n";
print "<br />\n";
print "<input type='submit' value='Найти' />\n";
print "</form>\n";
print "</div>\n";
print "</div>\n";
echo "<div class=\"rh\"><a href=\"/xhtml/Top-100/\">ТОП-100</a> | <a href=\"/xhtml/category.xhtml\">Категории</a> | <a href=\"/xhtml/search.xhtml\">Поиск</a></div>\n";
include "./inc/foot.php";
}else{
include "config.php";
include './inc/head.php';
print "<div class=\"rh\"><a href=\"/xhtml/category.xhtml\">Категория</a> | <a href=\"/xhtml/Top-100/\">ТОП-100</a> | Поиск</div>\n";
print "<div class=\"rb\">\n";
if($_POST['where'] == "name") $query = mysql_query ("SELECT * FROM `users` WHERE `site_name` LIKE '%".trim($text)."%' ORDER BY `uid`;");
if($_POST['where'] == "info") $query = mysql_query ("SELECT * FROM `users` WHERE `info` LIKE '%".trim($text)."%' ORDER BY `uid`;");
if($_POST['where'] == "link") $query = mysql_query ("SELECT * FROM `users` WHERE `link` LIKE '%".trim($text)."%' ORDER BY `uid`;");
while ($fetch = @mysql_fetch_array($query))
{
$uid = htmlspecialchars($fetch['uid']);
$link = htmlspecialchars($fetch['link']);
$info = htmlspecialchars($fetch['info']);
$info = eregi_replace($text,"<b>".$text."</b>",$info);
$i = $i + 1;
echo $i . ". <a href=\"/xhtml/outtop/".$uid."/\">".str_replace("http://", "", $link)."</a> <a href=\"/xhtml/stat/".$uid."/\">(?)</a> <br />\n".$info."<br />\n";
}
$result = @mysql_result($query, 0);
if ($result == 0)
{
print "К сожалению, результатов не найдено!<br />\n";
}
print "</div>\n";
echo "<div class=\"rh\"><a href=\"/xhtml/Top-100/\">ТОП-100</a> | <a href=\"/xhtml/category.xhtml\">Категории</a> | <a href=\"/xhtml/search.xhtml\">Поиск</a></div>\n";
include "./inc/foot.php";
}
ob_end_flush();
?>