<?
include_once 'sys/inc/start.php';
include_once 'sys/inc/compress.php';
include_once 'sys/inc/sess.php';
include_once 'sys/inc/home.php';
include_once 'sys/inc/settings.php';
include_once 'sys/inc/db_connect.php';
include_once 'sys/inc/ipua.php';
include_once 'sys/inc/fnc.php';
include_once 'sys/inc/user.php';

$set['title']='Поиск анкет'; // заголовок страницы
include_once 'sys/inc/thead.php';
title();
aut();











################## go поиск в базе ##################





if (preg_match('#[^A-zА-я0-9 _\-\.,]#ui',$_POST['ank_city']))$err[]='Используются запрещенные символы';


else
{

$ank_city=NULL;
if (isset($_SESSION['ank_city']))$ank_city=esc(stripcslashes(htmlspecialchars($_SESSION['ank_city'])));
if (isset($_GET['ank_city']))$ank_city=esc(stripcslashes(htmlspecialchars($_GET['ank_city'])));
$_SESSION['ank_city']=$ank_city;
$ank_city=ereg_replace("( ){1,}","",$ank_city);}




if (isset($_GET['go']) && $ank_city!=NULL)
{
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user`  WHERE `ank_city` like '%".mysql_escape_string($ank_city)."%'"),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 "Извините, по Вашему запросу ничего не найдено";




$q=mysql_query("SELECT * FROM `user`  WHERE `ank_city` like '%".mysql_escape_string($ank_city)."%' ORDER BY rating DESC LIMIT $start, $set[p_str]");


while ($ank = mysql_fetch_array($q))
{
if($num==1){
echo "<div class='rowup'>\n";
echo " \n";
echo "".online($ank['id'])."<a href='/info.php?id=$ank[id]'><span style=\"color:$ank[color]\">$ank[nick]</span></a>\n";

echo "<br />\n";
if ($ank['pol']==1)echo "<span class=\"ank_d\">(Муж)</span>\n"; else echo "<span class=\"ank_d\">(Жен)</span> \n";

if ($ank['ank_d_r']!=NULL && $ank['ank_m_r']!=NULL && $ank['ank_g_r']!=NULL){
$ank['ank_age']=date("Y")-$ank['ank_g_r'];
if (date("n")<$ank['ank_m_r'])$ank['ank_age']=$ank['ank_age']-1;
elseif (date("n")==$ank['ank_m_r']&& date("j")<$ank['ank_d_r'])$ank['ank_age']=$ank['ank_age']-1;
echo "<span class=\"ank_d\">$ank[ank_age] лет</span>\n";
}

if ($ank['ank_city']!=NULL)echo ", <span class=\"ank_d\">$ank[ank_city]</span><br />\n";
echo "</div>\n";
$num=0;
}else{ 
echo "<div class='rowdown'>\n";
echo "\n";
echo "".online($ank['id'])."<a href='/info.php?id=$ank[id]'><span style=\"color:$ank[color]\">$ank[nick]</span></a> \n";

echo "<br />\n";
if ($ank['pol']==1)echo "<span class=\"ank_d\">(Муж)</span>\n"; else echo "<span class=\"ank_d\">(Жен)</span> \n";

if ($ank['ank_d_r']!=NULL && $ank['ank_m_r']!=NULL && $ank['ank_g_r']!=NULL){
$ank['ank_age']=date("Y")-$ank['ank_g_r'];
if (date("n")<$ank['ank_m_r'])$ank['ank_age']=$ank['ank_age']-1;
elseif (date("n")==$ank['ank_m_r']&& date("j")<$ank['ank_d_r'])$ank['ank_age']=$ank['ank_age']-1;
echo "<span class=\"ank_d\">$ank[ank_age] лет</span>\n";
}

if ($ank['ank_city']!=NULL)echo ", <span class=\"ank_d\">$ank[ank_city]</span><br />\n";
echo "</div>\n";
$num=1;}
}



if ($k_page>1)str("s.php?go&amp;",$k_page,$page); // Вывод страниц
include_once 'sys/inc/tfoot.php';
}
else          /////////// формы ввода критериев поиска             /////////// формы ввода критериев поиска
echo "<div class='rowup'>";

echo "<form method=\"post\" action=\"s.php?go\">";
//echo "<br />";
echo "Ищу<br />\n";
echo "<select name=\"pol\">\r\n";
echo "<option value=\"1\">Парня</option>\r\n";
echo "<option value=\"0\">Девушку</option>\r\n";
echo "</select><br />\r\n";

echo "";

echo "Город<br/>";
echo "<input type=\"text\" name=\"ank_city\" value=\"$ank_city\"/><br />\r\n";







echo "<br />";

echo "<input type=\"submit\" value=\"Найти\" />";
echo "</form>\n";
echo "</div>\n";



include_once 'sys/inc/tfoot.php';
?>