Файл: test.masteram.us/search.php
Строк: 250
<?php
include 'Core.php';
$set['title']='Знакомства'; // заголовок страницы
include_once 'sys/inc/thead.php';
$pol=NULL;
if (isset($_SESSION['pol']))$pol=$_SESSION['pol'];
if (isset($_POST['pol']))$pol=$_POST['pol'];
$_SESSION['pol']=$pol;
$pol=ereg_replace("( ){1,}","",$pol);
$city2=mysql_fetch_array(mysql_query("SELECT * FROM `city` WHERE `name`='$_POST[city]' LIMIT 1"));
$mycity=NULL;
if (isset($_SESSION['mycity']))$mycity=esc(stripcslashes(htmlspecialchars($_SESSION['mycity'])));
if (isset($city2['city_id']))$mycity=esc(stripcslashes(htmlspecialchars($city2['city_id'])));
$_SESSION['mycity']=$mycity;
$mycity=ereg_replace("( ){1,}","",$mycity);
$age=NULL;
if (isset($_SESSION['age']))$age=$_SESSION['age'];
if (isset($_POST['age']))$age=$_POST['age'];
$_SESSION['age']=$age;
$age=ereg_replace("( ){1,}","",$age);
$age1=NULL;
if (isset($_SESSION['age1']))$age1=$_SESSION['age1'];
if (isset($_POST['age1']))$age1=$_POST['age1'];
$_SESSION['age1']=$age1;
$age1=ereg_replace("( ){1,}","",$age1);
$online=NULL;
if (isset($_SESSION['online']))$online=$_SESSION['online'];
if (isset($_POST['online']))$online=$_POST['online'];
$_SESSION['online']=$online;
$online=ereg_replace("( ){1,}","",$online);
if (isset($_GET['go'])){
if ($online==0){
if ($age1!=0 && $age!=0) $k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `pol` = '".$pol."' AND `date_last` > '".(time()-600)."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` >= '$age' AND `ank_g_r` <= '$age1' AND `aktivzn` = '1'"),0);
else if ($age1==0 && $age==0) $k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `pol` = '".$pol."' AND `date_last` > '".(time()-600)."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `aktivzn` = '1'"),0);
else if ($age1!=0 && $age==0) $k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `pol` = '".$pol."' AND `date_last` > '".(time()-600)."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` <= '$age1' AND `aktivzn` = '1'"),0);
else if ($age1==0 && $age!=0) $k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `pol` = '".$pol."' AND `date_last` > '".(time()-600)."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` >= '$age' AND `aktivzn` = '1'"),0);
}else{
if ($age1!=0 && $age!=0) $k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `pol` = '".$pol."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` >= '$age' AND `ank_g_r` <= '$age1' AND `aktivzn` = '1'"),0);
else if ($age1==0 && $age==0) $k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `pol` = '".$pol."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `aktivzn` = '1'"),0);
else if ($age1!=0 && $age==0) $k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `pol` = '".$pol."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` <= '$age1' AND `aktivzn` = '1'"),0);
else if ($age1==0 && $age!=0) $k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `pol` = '".$pol."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` >= '$age' AND `aktivzn` = '1'"),0);
}
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>n";
if ($k_post==0)
{
echo " <tr>n";
echo " <td class='p_t'>n";
echo "Извините, по Вашему запросу ничего не найдено";
echo " </td>n";
echo " </tr>n";
}
if ($online==0){
if ($age1!=0 && $age!=0) $q=mysql_query("SELECT * FROM `user` WHERE `pol` = '".$pol."' AND `date_last` > '".(time()-600)."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` >= '$age' AND `ank_g_r` <= '$age1' AND `aktivzn` = '1' ORDER BY rating DESC LIMIT $start, $set[p_str]");
else if ($age1==0 && $age==0) $q=mysql_query("SELECT * FROM `user` WHERE `pol` = '".$pol."' AND `date_last` > '".(time()-600)."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `aktivzn` = '1' ORDER BY rating DESC LIMIT $start, $set[p_str]");
else if ($age1!=0 && $age==0) $q=mysql_query("SELECT * FROM `user` WHERE `pol` = '".$pol."' AND `date_last` > '".(time()-600)."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` <= '$age1' AND `aktivzn` = '1' ORDER BY rating DESC LIMIT $start, $set[p_str]");
else if ($age1==0 && $age!=0) $q=mysql_query("SELECT * FROM `user` WHERE `pol` = '".$pol."' AND `date_last` > '".(time()-600)."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` >= '$age' AND `aktivzn` = '1' ORDER BY rating DESC LIMIT $start, $set[p_str]");
}else{
if ($age1!=0 && $age!=0) $q=mysql_query("SELECT * FROM `user` WHERE `pol` = '".$pol."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` >= '$age' AND `ank_g_r` <= '$age1' AND `aktivzn` = '1' ORDER BY rating DESC LIMIT $start, $set[p_str]");
else if ($age1==0 && $age==0) $q=mysql_query("SELECT * FROM `user` WHERE `pol` = '".$pol."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `aktivzn` = '1' ORDER BY rating DESC LIMIT $start, $set[p_str]");
else if ($age1!=0 && $age==0) $q=mysql_query("SELECT * FROM `user` WHERE `pol` = '".$pol."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` <= '$age1' AND `aktivzn` = '1' ORDER BY rating DESC LIMIT $start, $set[p_str]");
else if ($age1==0 && $age!=0) $q=mysql_query("SELECT * FROM `user` WHERE `pol` = '".$pol."' AND `mycity` like '%".mysql_escape_string($mycity)."%' AND `ank_g_r` >= '$age' AND `aktivzn` = '1' ORDER BY rating DESC LIMIT $start, $set[p_str]");
}
while ($ank = mysql_fetch_array($q))
{
if ($k_post==1)
{
echo " <td class='p_t'>n";
echo "".online($ank['id'])."<a href='/info.php?id=$ank[id]'>";
echo "".adm($ank['id'])."</a>";
echo " </td>n";
echo " </tr>n";
echo " <tr>n";
if ($set['set_show_icon']==1)echo " <td class='p_m' colspan='2'>n"; else echo " <td class='p_m'>n";
if ($ank['pol']==1)
echo "(М)</a>n";
else
echo "(Ж)</a>n";
if ($ank['familiya']!=NULL)echo "$ank[familiya]</a> </a>";
else
echo "</a> </a>n";
if ($ank['ank_name']!=NULL)echo "<span class="ank_d">$ank[ank_name]</span>";
else
echo "";
echo "</a> </a>n";
$q1=mysql_fetch_array(mysql_query("SELECT * FROM `city` WHERE `city_id`='$ank[mycity]' LIMIT 1"));
$stra=$q1[country_id];
echo "".city($ank['id'])."</a>";
echo "$q1[name]</br>";
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_n">Возраст:</span> <span class="ank_d">$ank[ank_age]</span><br />n";
}
if (otkuda($ank['url']))echo "<span class="ank_n">Где:</span> <span class="ank_d"><a href='$ank[url]'>".otkuda($ank['url'])."</a></span>n";
echo " </td>n";
echo " </tr>n";
}}
echo "</table>n";
if ($k_page>1)str("?",$k_page,$page); // Вывод страниц
include_once 'sys/inc/tfoot.php';
}else{
if (isset($_GET['count'])){
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `country`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>";
if ($k_post==0)
{
echo " <tr>";
echo " <td class='p_t'>";
echo "Нет результатов";
echo " </td>";
echo " </tr>";
}
$q=mysql_query("SELECT * FROM `country` LIMIT $start, $set[p_str]");
while ($count = mysql_fetch_array($q))
{
echo " <td class='p_t'>";
echo "<a href='?region&id=$count[country_id]'>$count[name]";
echo " </td>";
echo " </tr>";
echo " <tr>";
}
echo "</table>";
if ($k_page>1)str("?count&",$k_page,$page);
}else{
//////////////
if (isset($_GET['region'])){
$id_country=(int)abs((int)$_GET['id']);
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `region` WHERE `country_id` = $id_country"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>";
if ($k_post==0)
{
echo " <tr>";
echo " <td class='p_t'>";
echo "Нет результатов";
echo " </td>";
echo " </tr>";
}
$q=mysql_query("SELECT * FROM `region` WHERE `country_id` = $id_country LIMIT $start, $set[p_str]");
while ($count = mysql_fetch_array($q))
{
echo " <td class='p_t'>";
echo "<a href='?gorod&id=$count[region_id]'>$count[name]";
echo " </td>";
echo " </tr>";
echo " <tr>";
}
echo "</table>";
if ($k_page>1)str("?region&id=$id_country&",$k_page,$page); // Вывод страниц
}else{
//////////////////////////
if (isset($_GET['gorod'])){
$id_siti=(int)abs((int)$_GET['id']);
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `city` WHERE `region_id` = $id_siti"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>";
if ($k_post==0)
{
echo " <tr>";
echo " <td class='p_t'>";
echo "Нет результатов";
echo " </td>";
echo " </tr>";
}
$q=mysql_query("SELECT * FROM `city` WHERE `region_id` = $id_siti LIMIT $start, $set[p_str]");
while ($count = mysql_fetch_array($q))
{
echo " <td class='p_t'>";
echo "<a href='?city=$count[city_id]'>$count[name]";
echo " </td>";
echo " </tr>";
echo " <tr>";
}
echo "</table>";
if ($k_page>1)str("?gorod&id=$id_siti&",$k_page,$page); // Вывод страниц
}else{
title();
err();
aut();
$id_siti=(int)abs((int)$_GET['city']);
$city=mysql_fetch_array(mysql_query("SELECT * FROM `city` WHERE `city_id`='$id_siti' LIMIT 1"));
echo "<form method="post" action="search.php?go">";
//echo "</br>";
if($id_siti=='0'){
echo "Город:</a>";
echo "<a href='?count'>Выбрать</a><br/>";
echo "<input type="text" name="city" value="$city[name]" maxlength="40"/><br/>r";
}else{
echo "Город:<br/>";
echo "<input type="text" name="city" value="$city[name]" maxlength="40"/> <br/>r";
}
echo "Искать:<br/>";
echo "<select name="pol">r";
echo "<option value="1">Парня</option>r";
echo "<option value="0">Девушку</option>r";
echo "</select></br>r";
echo "Год рождения:<br/>r";
echo "От: <input type="text" value="" name="age" size="4" maxlength="4" /></a>";
echo "</a>До: <input type="text" value="" name="age1" size="4" maxlength="4" />";
echo "<br/>";
echo "Онлайн:<br/>";
echo "<select name="online">r";
echo "<option value="1">Не важно</option>r";
echo "<option value="0">Да</option>r";
echo "</select><br/>r";
echo "<br/>";
echo "<input type="submit" value="Найти" />";
echo "</form>";
}}}}
include_once 'sys/inc/tfoot.php';
?>