Просмотр файла cat/search.php

Размер файла: 4.06Kb
<?php
require ("cfg.php");
header ("Content-type:text/vnd.wap.wml; charset=utf-8");

print"<?xml version=\"1.0\" encoding=\"utf-8\"?>
<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">
<wml><head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>
<card id=\"сatalog\" title=\"Поиск в каталоге\">
<p align=\"left\">";

if(!isset($s)){
print"
<small>Искомое слово:</small><br/> <input type=\"text\" name=\"text\" maxlength=\"1000\"/><br/>
<small>Искать в:</small><br/> <select name=\"s\">
<option value=\"1\">Названии</option>
<option value=\"2\">Описании</option>
<option value=\"3\">Url</option>
</select><br/>
<small><anchor>[Искать]
<go href=\"search.php\" 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\">Ввести!</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=\"from.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&amp;text=$text\">[".($i+1)."]</a>";}else{
print "[".($i+1)."]";}}
print "</small>";
if($total_mat_number==0){print "<small>Ничего не найдено!</small><br/>";}}

print"<br/><small><a href=\"./\">Каталог</a><br/>
</small>
</p></card></wml>";
?>