<?php
$version=$HTTP_GET_VARS['version'];
include "xconf.php";
header("Cache-Control: no-cache");
///////////////////////
include "fo.php";
$version=trim($version);
if ($version=="xhtml"){
$version=xhtml;
include "xhtml_head.php";
$div_s="<div class=\"a\">";
$div_ss="<div class=\"b\">";
$div_e="</div>";
if(!isset($s)){
print "$div_ss
<p align=\"left\">Пoиcк Пo Kaтaлoгy";
print"
$div_e $div_s
<form action=\"search.php?version=xhtml\" method=\"post\">
Гдe иcкaть:<select name=\"s\">
<option value=\"1\">B нaзвaнии</option>
<option value=\"2\">B oпиcaнии</option>
<option value=\"3\">B url</option>
</select><br/>
Teкcт: <input type=\"text\" name=\"text\" maxlength=\"1000\"/>
<postfield name=\"s\" value=\"$(s)\"/>
<postfield name=\"text\" value=\"$(text)\"/>
<input type=\"hidden\" name=\"seenform\" value=\"add\"> <br/><br/>
<input type=\"submit\" value=\"Иcкaть\">
</form>
$div_e
";
}
elseif(empty($s)||empty($text)){print"$div_s<small>He ввeдeн тeкcт пoиcкa! <a href=\"search.php?version=$version\">Bвecти!</a></small><br/>$div_e";}
else{
$s=intval($s);
$text=coding_cool(substr(trim($text), 0, 1000));
if(empty($page)){$page=0;}
if($s==1){
if($active_site==1){
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(title))>0 and activ='1' and counter>'0');");}else{
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(title))>0 and activ='1');");}}
elseif($s==2){
if($active_site==1){
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(about))>0 and activ='1' and counter>'0');");}else{
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(about))>0 and activ='1');");}}
else{
if($active_site==1){
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(link))>0 and activ='1' and counter>'0');");}else{
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(link))>0 and activ='1');");}}
$num_of_rows=mysql_num_rows($q);
$total_mat_number=$num_of_rows;
$total_pages=ceil($total_mat_number/$mat_per_page);
if($s==1){
if($active_site==1){
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(title))>0 and activ='1' and counter>'0') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}else{
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(title))>0 and activ='1') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}}
elseif($s==2){
if($active_site==1){
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(about))>0 and activ='1' and counter>'0') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}else{
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(about))>0 and activ='1') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}}
else{
if($active_site==1){
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(link))>0 and activ='1' and counter>'0') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}else{
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(link))>0 and activ='1') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}}
while($data=mysql_fetch_array($prints)){
print "$div_s<small><b>".$data['title']."</b><br/>";
print $data['about']."<br/>";
print "<small><u>Из кaтaлoгa:</u> ".$data['outcounter']."<br/>";
print "<u>B кaтaлoг:</u> ".$data['counter']."</small><br/>";
print "<a href=\"out.php?go=".$data['link']."\">".$data['link']."</a></small><br/><br/>$div_e";}
print "<small>";
for ($i=0; $i<$total_pages; $i++){
$page_number=$i*$mat_per_page;
if($page_number!=$page){print "<a href=\"search.php?s=$s&text=$text&apm;version=$version\">[".($i+1)."]</a>";}else{
print "[".($i+1)."]";}}
print "</small>";
if($total_mat_number==0){print "$div_s<small>Пo вaшeмy зaпpocy ничeгo нe нaйдeнo!</small><br/>$div_e";}}
print"$div_ss<br/>*****<br/><a href=\"./?version=$version\">B Kaтaлoг</a><br/>*****<br/>
</p>
$div_e";
}
else {
$version=wml;
include "wml_head.php";
print "<p align=\"left\">";
if(!isset($s)){
print"<small>Где искать:</small> <select name=\"s\">
<option value=\"1\">В названии</option>
<option value=\"2\">В описании</option>
<option value=\"3\">В url</option>
</select><br/>
<small>Текст:</small> <input type=\"text\" name=\"text\" maxlength=\"1000\"/><br/>
<small><anchor>Иcкaть »
<go href=\"search.php?version=$version\" method=\"post\">
<postfield name=\"s\" value=\"$(s)\"/>
<postfield name=\"text\" value=\"$(text)\"/>
</go></anchor></small><br/>";}
elseif(empty($s)||empty($text)){print"<small>Не введен текст поиска! <a href=\"search.php?version=$version\">Ввести!</a></small><br/>";}
else{
$s=intval($s);
$text=coding_cool(substr(trim($text), 0, 1000));
if(empty($page)){$page=0;}
if($s==1){
if($active_site==1){
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(title))>0 and activ='1' and counter>'0');");}else{
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(title))>0 and activ='1');");}}
elseif($s==2){
if($active_site==1){
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(about))>0 and activ='1' and counter>'0');");}else{
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(about))>0 and activ='1');");}}
else{
if($active_site==1){
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(link))>0 and activ='1' and counter>'0');");}else{
$q=mysql_query("select id from `cool_site` where (locate(lower('$text'),lower(link))>0 and activ='1');");}}
$num_of_rows=mysql_num_rows($q);
$total_mat_number=$num_of_rows;
$total_pages=ceil($total_mat_number/$mat_per_page);
if($s==1){
if($active_site==1){
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(title))>0 and activ='1' and counter>'0') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}else{
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(title))>0 and activ='1') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}}
elseif($s==2){
if($active_site==1){
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(about))>0 and activ='1' and counter>'0') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}else{
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(about))>0 and activ='1') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}}
else{
if($active_site==1){
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(link))>0 and activ='1' and counter>'0') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}else{
$prints = mysql_query("select * from `cool_site` where (locate(lower('$text'),lower(link))>0 and activ='1') order by counter desc limit ".$page.",".($page+$mat_per_page).";");}}
while($data=mysql_fetch_array($prints)){
print "<small><b>".$data['title']."</b><br/>";
print $data['about']."<br/>";
print "<small><u>Из каталога:</u> ".$data['outcounter']."<br/>";
print "<u>В каталог:</u> ".$data['counter']."</small><br/>";
print "<a href=\"out.php?go=".$data['link']."\">".$data['link']."</a></small><br/><br/>";}
print "<small>";
for ($i=0; $i<$total_pages; $i++){
$page_number=$i*$mat_per_page;
if($page_number!=$page){print "<a href=\"search.php?s=$s&text=$text&version=$version\">[".($i+1)."]</a>";}else{
print "[".($i+1)."]";}}
print "</small>";
if($total_mat_number==0){print "<small>Пo вaшeмy зaпpocy ничeгo нe нaйдeнo!</small><br/>";}}
print"<br/><small>*****<br/><a href=\"./?version=$version\">B Kaтaлoг</a><br/>*****<br/>
</small>
</p>
";}
if ($version=="xhtml"){
include "xhtml3_down.php";
$version=xhtml;
}
else {
include "wml3_down.php";
}
?>