View file search.php

File size: 10.72Kb
<?php
header('Pragma: no-cache');
if (empty($v)) {
header("Content-type:text/vnd.wap.wml;charset=utf-8"); }
else {
header("Content-type:text/html; charset=utf-8");
}
include("config.php");
$new=rand(1,9999);
head($v,$title);

switch ($do) {
default:
if (empty($v)) {
echo "Что ищем?:<br/>
</small><input type=\"text\" name=\"why$new\" maxlength=\"500\"/><small><br/>
Искать по:<br/>
</small><select name=\"w\">
<option value=\"1\">Заголовку</option>
<option value=\"2\">Инфе</option>
<option value=\"3\">Адресу</option>
</select><small><br/>
Где искать:<br/>
</small><select name=\"cat\">";
$q=mysql_query("select * from `cat_cats` where 1 order by por asc");
while($datas = @mysql_fetch_array($q)){
echo "<option value=\"".$datas['id']."\">".$datas['name']."</option>";}
echo "</select><small><br/>";
echo "Транслит [<a href=\"search.php?do=tr\">?</a>]:<br/>";
echo "</small><select name=\"tr\">";
echo "<option value=\"off\">Выключен</option>";
echo "<option value=\"on\">Включен</option>";
echo "</select><small><br/>";
echo "<anchor>Искать &#8594;<go href=\"search.php?do=ok\" method=\"post\">
<postfield name=\"why\" value=\"$(why$new)\"/>
<postfield name=\"w\" value=\"$(w)\"/>
<postfield name=\"cat\" value=\"$(cat)\"/>
<postfield name=\"tr\" value=\"$(tr)\"/>
</go></anchor><br/>---<br/>";
} else {

echo "<div class=\"wich\"><form name=\"form\" action=\"search.php?do=ok&amp;v=html\" method=\"post\">";
echo "Что ищем?:<br/>";
echo "<input class=\"input\" name=\"why\" type=\"text\" maxlength=\"500\"/><br/>";
echo "Искать по:<br/>";
echo "<select class=\"input\" name=\"w\">";
echo "<option value=\"1\">Заголовку</option>";
echo "<option value=\"2\">Инфе</option>";
echo "<option value=\"3\">Адресу</option>";
echo "</select><br/>";
echo "Где искать:<br/>";
echo "<select class=\"input\" name=\"cat\">";
$q=mysql_query("select * from `cat_cats` where 1 order by por asc");
while($datas = @mysql_fetch_array($q)){
echo "<option value=\"".$datas['id']."\">".$datas['name']."</option>";}
echo "</select><br/>";
echo "Транслит [<a href=\"search.php?do=tr&amp;v=html\">?</a>]:<br/>";
echo "<select class=\"input\" name=\"tr\">";
echo "<option value=\"off\">Выключен</option>";
echo "<option value=\"on\">Включен</option>";
echo "</select><br/>";
echo "<input class=\"input\" type=\"submit\" value=\"Искать\">";
echo "</form></div>";}
break;

case 'ok':
function trun_to_rus($str)
{$str=str_replace("ch","ч",$str);
$str=str_replace("sc","щ",$str);
$str=str_replace("ye","э",$str);
$str=str_replace("yu","ю",$str);
$str=str_replace("ya","я",$str);
$str=str_replace("CH","Ч",$str);
$str=str_replace("SC","Щ",$str);
$str=str_replace("\"\"","Ъ",$str);
$str=str_replace("\"","ъ",$str);
$str=str_replace("''","Ь",$str);
$str=str_replace("'","ь",$str);
$str=str_replace("YE","Э",$str);
$str=str_replace("YU","Ю",$str);
$str=str_replace("YA","Я",$str);
$str=strtr($str,array("a"=>"a","b"=>"б","v"=>"в","g"=>"г","d"=>"д","e"=>"e","j"=>"ж","z"=>"з","i"=>"и","y"=>"й","k"=>"к","l"=>"л","m"=>"м","n"=>"н","o"=>"o","p"=>"п","r"=>"р","s"=>"c","t"=>"т","u"=>"у","f"=>"ф","h"=>"x","c"=>"ц","w"=>"ш","x"=>"ы","A"=>"A","B"=>"Б","V"=>"B","G"=>"Г","D"=>"Д","E"=>"E","J"=>"Ж","Z"=>"З","I"=>"И","Y"=>"Й","K"=>"K","L"=>"Л","M"=>"M","N"=>"H","O"=>"O","P"=>"П","R"=>"P","S"=>"C","T"=>"T","U"=>"У","F"=>"Ф","H"=>"X","C"=>"Ц","W"=>"Ш","X"=>"Ы"));
return $str;}
if($tr == "on") {
$why=trun_to_rus($why);}
$s=intval($s);
$w=intval($w);
$cat=intval($cat);
$why=check(substr(trim($why), 0, 500));
@mysql_query("SELECT `id` FROM `cat_cats` WHERE `id`='$cat';");
if (mysql_affected_rows() == 0) {$error="Такого раздела каталога не существует!";}
if (!$why) {$error="Вы не ввели текст поиска!";}
if (!$w) {$error="Вы не ввели \"Искать по?\"!";}

if (!$error) {
if($w==1){
if($active_site==1){
$q=mysql_query("select id from `cat_users` where (locate(lower('$why'),lower(title))>0 and cat='$cat' and activ='1' and incat>'0');");}else{
$q=mysql_query("select id from `cat_users` where (locate(lower('$why'),lower(title))>0 and cat='$cat' and activ='1');");}}
elseif($w==2){
if($active_site==1){
$q=mysql_query("select id from `cat_users` where (locate(lower('$why'),lower(info))>0 and cat='$cat' and activ='1' and incat>'0');");}else{
$q=mysql_query("select id from `cat_users` where (locate(lower('$why'),lower(info))>0 and cat='$cat' and activ='1');");}}
else{
if($active_site==1){
$q=mysql_query("select id from `cat_users` where (locate(lower('$why'),lower(site))>0 and cat='$cat' and activ='1' and incat>'0');");}else{
$q=mysql_query("select id from `cat_users` where (locate(lower('$why'),lower(site))>0 and cat='$cat' and activ='1');");}}
$all=mysql_num_rows($q);
$koll=mysql_fetch_row(mysql_query("SELECT `kol` FROM `cat_set`;"));
$koll=$koll['0'];
if(empty($s))$s=1;
$p=round($koll*($s-1));

if($w==1){
if($active_site==1){
$prints = mysql_query("select * from `cat_users` where (locate(lower('$why'),lower(title))>0 and cat='$cat' and activ='1' and incat>'0') order by incat desc limit $p,$koll;");}else{
$prints = mysql_query("select * from `cat_users` where (locate(lower('$why'),lower(title))>0 and cat='$cat' and activ='1') order by incat desc limit  $p,$koll;");}}
elseif($w==2){
if($active_site==1){
$prints = mysql_query("select * from `cat_users` where (locate(lower('$why'),lower(info))>0 and cat='$cat' and activ='1' and incat>'0') order by incat desc limit $p,$koll;");}else{
$prints = mysql_query("select * from `cat_users` where (locate(lower('$why'),lower(info))>0 and cat='$cat' and activ='1') order by incat desc limit $p,$koll;");}}
else{
if($active_site==1){
$prints = mysql_query("select * from `cat_users` where (locate(lower('$why'),lower(site))>0 and cat='$cat' and activ='1' and incat>'0') order by incat desc limit $p,$koll;");}else{
$prints = mysql_query("select * from `cat_users` where (locate(lower('$why'),lower(site))>0 and cat='$cat' and activ='1') order by incat desc limit $p,$koll;");}}

if (mysql_affected_rows() == 0) {
if (!empty($v)) {echo "<div class=\"wich\">";}
echo "Ничего не найдено!:(";
if (empty($v)) {echo "<br/>---<br/>";}
else {echo "</div>";}
} else {
while ($memb=mysql_fetch_array($prints)) {
if (!empty($v)) {echo "<div class=\"wich\" style=\"text-align: left\">";}
echo "&#187; <a href=\"out.php?id=$memb[id]\">$memb[title]</a><br/>";
echo "<u>Сайт</u>: $memb[site]<br/>";
echo "<u>Инфа</u>: $memb[info]<br/>";
$ncat=mysql_fetch_row(mysql_query("SELECT `name` FROM `cat_cats` WHERE `id`='$memb[cat]';"));
echo "<u>Раздел</u>: $ncat[0]<br/>";
echo "IN: <u>$memb[incat]</u> | OUT: <u>$memb[outcat]</u><br/>";
if (!empty($v)) {echo "</div>";}
else {echo "---<br/>";}}



$next=$s+1;
$prev=$s-1;
$nxpg=$s*$koll;
$toend=ceil($all/$koll);

if (empty($v)) { //version
if($s>1) {
echo "<a href=\"search.php?do=ok&amp;cat=$cat&amp;why=$why&amp;w=$w&amp;tr=$tr&amp;s=$prev\">&#8592; Назад</a>";
if ($nxpg<$all) {echo "|";}
else {echo "<br/>";}}
if ($nxpg<$all) {
echo "<a href=\"search.php?do=ok&amp;cat=$cat&amp;why=$why&amp;w=$w&amp;tr=$tr&amp;s=$next\">Далее &#8594;</a><br/>";}
if ($s>2) {
echo "<a href=\"search.php?do=ok&amp;cat=$cat&amp;why=$why&amp;w=$w&amp;tr=$tr\">&#8592; В начало</a>";
if ($all>$koll*2 && $s!=$toend) {echo "|";}
else {echo "<br/>";}}
if ($all>$koll*2 && $s!=$toend) {
echo "<a href=\"search.php?do=ok&amp;cat=$cat&amp;why=$why&amp;w=$w&amp;tr=$tr&amp;s=$toend\">В конец &#8594;</a><br/>";}
} else {
echo "<div class=\"other\" style=\"text-align: left\">";
if($s>1) {
echo "<a href=\"search.php?do=ok&amp;cat=$cat&amp;why=$why&amp;w=$w&amp;tr=$tr&amp;s=$prev&amp;v=html\">&#8592; Назад</a>";
if ($nxpg<$all) {echo "|";}
else {echo "<br/>";}}
if ($nxpg<$all) {
echo "<a href=\"search.php?do=ok&amp;cat=$cat&amp;why=$why&amp;w=$w&amp;tr=$tr&amp;s=$next&amp;v=html\">Далее &#8594;</a><br/>";}
if ($s>2) {
echo "<a href=\"search.php?do=ok&amp;cat=$cat&amp;why=$why&amp;w=$w&amp;tr=$tr&amp;v=html\">&#8592; В начало</a>";
if ($all>$koll*2 && $s!=$toend) {echo "|";}
else {echo "<br/>";}}
if ($all>$koll*2 && $s!=$toend) {
echo "<a href=\"search.php?do=ok&amp;cat=$cat&amp;why=$why&amp;w=$w&amp;tr=$tr&amp;s=$toend&amp;v=html\">В конец &#8594;</a><br/>";}
echo "</div>";
}
}
} //error
else {
if (!empty($v)) {echo "<div class=\"wich\">";}
echo "$error";
if (empty($v)) {echo "<br/>---<br/>";}
else {echo "</div>";}}

break;

case 'tr':
if (!empty($v)) {echo "<div class=\"wich\">";}
echo "При включеном транслите транслируется название и описание сайта!<br/>";
if (!empty($v)) {echo "</div><div class=\"wich\">";}
else {echo "---<br/>";}
?>
Прaвилa трaнcлитa<br/>
a(A)-a(A)<br/>
б(Б)-b(B)<br/>
в(B)-v(V)<br/>
г(Г)-g(G)<br/>
д(Д)-d(D)<br/>
e(E)-e(E)<br/>
ж(Ж)-j(J)<br/>
з(З)-z(Z)<br/>
и(И)-i(I)<br/>
й(Й)-y(Y)<br/>
к(K)-k(K)<br/>
л(Л)-l(L)<br/>
м(M)-m(M)<br/>
н(H)-n(N)<br/>
o(O)-o(O)<br/>
п(П)-p(P)<br/>
р(P)-r(R)<br/>
c(C)-s(S)<br/>
т(T)-t(T)<br/>
у(У)-u(U)<br/>
ф(Ф)-f(F)<br/>
x(X)-h(H)<br/>
ц(Ц)-c(C)<br/>
ч(Ч)-ch(CH)<br/>
ш(Ш)-w(W)<br/>
щ(Щ)-sc(SC)<br/>
ъ(Ъ)-"("")<br/>
ы(Ы)-x(X)<br/>
ь(Ь)-'('')<br/>
э(Э)-ye(YE)<br/>
ю(Ю)-yu(YU)<br/>
я(Я)-ya(YA)<br/>
<?
echo "<a href=\"search.php?v=$v\">Поиск</a><br/>";
if (empty($v)) {echo "---<br/>";}
else {echo "</div>";}
break;

} //switch!
if (empty($v)) { //version
echo "<u>WML</u>|<a href=\"search.php?do=$do&amp;why=$why&amp;v=html&amp;w=$w&amp;cat=$cat&amp;s=$s\">HTML</a><br/>";
if (isset($do)) {echo "<a href=\"search.php\">&#8592; Поиск</a><br/>";}
echo "<a href=\"$site\">&#8592; В каталог</a><br/>
<a href=\"$index\">&#8592; На главную</a>";
}else {
echo "<div class=\"other\" style=\"text-align: left\">";
echo "<a href=\"search.php?do=$do&amp;why=$why&amp;w=$w&amp;cat=$cat&amp;s=$s\">WML</a>|<u>HTML</u><br/>";
if (isset($do)) {echo "<a href=\"search.php?v=html\">&#8592; Поиск</a><br/>";}
echo "<a href=\"$site?v=html\">&#8592; В каталог</a><br/>
<a href=\"$index\">&#8592; На главную</a>";
echo "</div>";
}
if (empty($v)) {
echo '</small></p></card></wml>';}
else {
echo "</small>";
echo "</body>
</html>";}
@mysql_close($mysql);
/*
ВНИМАНИЕ!!! СКРИПТ РАЗРЕШЕННО РАСПРОСТРАНЯТЬ ТОЛЬКО АВТОРУ (GuT'y) СКРИПТА !!!
ПЕРЕПРОДАВАТЬ! ДАВАТЬ КОМУ ТО НА РЕДАКТИРОВАНИЕ! ПРОСТО ДАВАТЬ КАК ДРУГУ ИЛИ ВЫКЛАДЫВАТЬ НА ХАЛЯВУ - ЗАПЕРЕЩЕНО !!!
ИНАЧЕ БУДУТ ПРОБЛЕМЫ :-)))
*/
?>