Файл: search.php
Строк: 225
<?
include 'connect.php';
if (isset($_GET['submit'])) {
$sex = check($_GET['sex']);
$family = num($_GET['family']);
$orientation = num($_GET['orientation']);
$age1 = num($_GET['age1']);
$age2 = num($_GET['age2']);
$city = check(substr($_GET['city'], 0, 100));
$online = num($_GET['online']);
header ("Location: search.php?act=go&sex=$sex&age1=$age1&age2=$age2&city=$city&family=$family&orientation=$orientation&online=$online");
}
switch ($_GET['act']) {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Результат ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
case 'go':
if($u['setting_users_list']) $count = $u['setting_users_list']; else $count = 10;
$sex = $_GET['sex'];
if($sex == 'zh' || $sex == 'm') $sexq = "AND `sex` = '".$sex."'"; else $sexq = "";
$family = $_GET['family'];
if($family == '1' || $family == '2' || $family == '3' || $family == '4' || $family == '5' || $family == '6') $familyq = "AND `family` = '".$family."'"; else $familyq = "";
$orientation = $_GET['orientation'];
if($orientation == '1' || $orientation == '2' || $orientation == '3' || $orientation == '4') $orientationq = "AND `orientation` = '".$orientation."'"; else $orientationq = "";
$age1 = $_GET['age1'];
if ($age1 > 0 && $age1 < 90){
$year = date('Y') - $age1 + 1;
$age1q = "AND `anketa_byear` > '0' AND `anketa_byear` < '".$year."'";
} else { $age1q = ""; }
$age2 = $_GET['age2'];
if ($age2 > 0 && $age2 < 90){
$year = date('Y') - $age2 - 1;
$age2q = "AND `anketa_byear` > '0' AND `anketa_byear` > '".$year."'";
} else { $age2q = ""; }
$city = check(substr($_GET['city'], 0, 100));
if($city) $cityq = "AND `anketa_city` = '".$city."'"; else $cityq = "";
$online = $_GET['online'];
if($online) $onlineq = "AND `online` > '".(time()-$system['online_time'])."'"; else $onlineq = "";
if($sexq || $familyq || $orientationq || $age1q || $age2q || $cityq || $onlineq) $where = "WHERE `id` > '0'"; else $where = "";
$title = $title.' | Поиск людей';
include 'head.php';
echo '<div class="title">';
echo '<img src="ico/heart.png" alt="!"/> <a href = "search.php"> Знакомства</a> <b> Просмотр </b>';
echo '</div>';
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` $where $sexq $familyq $orientationq $age1q $age2q $onlineq $cityq "), 0);
echo '<div class = "nav">Найдено: <b>'.$all.'</b> пользователей</div>';
if($all > 0){
$total = intval(($all - 1) / $count) + 1;
$page = num($_GET['page']);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $count - $count;
$result = mysql_query("SELECT * FROM `users` $where $sexq $familyq $orientationq $age1q $age2q $onlineq $cityq ORDER BY rating DESC LIMIT $start, $count");
while($user = mysql_fetch_assoc($result)){
echo $i % 2 ? '<div class="div">' : '<div class="div">';
if(ban($user['id'])){
echo ''.ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'"><del>'.$user['login'].'</del></a> '.online($user['online']).' ';
} else {
echo ''.ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'">'.$user['login'].'</a> '.online($user['online']).' ';
}
if($user['rating']>=1000 && $user['rating']<=1999)echo "<img src='ico/b.png' alt='' class='icon'</a>n";
if($user['rating']>=2000 && $user['rating']<=2999)echo "<img src='ico/s.png' alt='' class='icon'</a>n";
if($user['rating']>=3000)echo "<img src='ico/z.png' alt='' class='icon'</a>n";
echo '<br/>';
echo '</div>';
$i++;
}
navigation($page, $total,'search.php?act=go&sex='.$sex.'&age1='.$age1.'&age2='.$age2.'&city='.$city.'&family='.$family.'&online='.$online.'&');
} else {
echo '<div class="div"> Пользователей не найдено !</div>';
}
echo '</div>';
include 'foot.php';
break;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Поля для поиска ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
default:
$title = $title.' | Знакомства';
include 'head.php';
require('core/ava_min.php');
echo '<div class="title"> <img src="ico/heart.png" alt="!"/> <b>Знакомства</b></div>';
if($_GET['search']) {
echo '<div class="div">';
echo '<form action="search.php" method=get>';
echo 'Пол: <br/><select name="sex">
<option value="0">- Не выбран -</option>
<option value="zh">Женский</option>
<option value="m">Мужской</option>
</select><br/>';
echo 'Семейное положение:<br/>
<select name="family">
<option value="0">- Семейное положение -</option>
<option value="1">Не женат/Не замужем</option>
<option value="2">Есть подруга/Есть друг</option>
<option value="3">Помолвлен/Помолвлена</option>
<option value="4">Женат/Замужем</option>
<option value="5">Всё сложно</option>
<option value="6">В активном поиске</option>
</select></br>';
echo 'Ориентация:<br/>
<select name="orientation">
<option value="0">- Ориентация -</option>
<option value="1">Гетеро</option>
<option value="2">Гей</option>
<option value="3">Лесби</option>
<option value="4">Би</option>
</select></br>';
echo 'Возраст: <br/> От: <input type=text SIZE=2 name=age1 maxlength=2> До: <input type=text SIZE=2 name=age2 maxlength=2><br/>';
echo 'Город: <br/><input type=text name=city maxlength=50><br/>';
echo '<input name="online" type="checkbox" value="1"> На сайте<br/>';
echo '<input type=submit name="submit" value="Найти" class="submit white"/></form>';
echo '</div>';
include 'foot.php';
exit;
}
echo '<div class="nav">';
$cusers_zh = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `sex` = 'zh'"), 0);
echo '<img src = "ico/w.png"> <a href = "search.php?act=go&sex=zh"> Девушки</a> ('.$cusers_zh.')</br>';
$cusers_m = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `sex` = 'm'"), 0);
echo '<img src = "ico/man.png"> <a href = "search.php?act=go&sex=m"> Парни</a> ('.$cusers_m.')</br>';
$cusers = mysql_result(mysql_query("SELECT COUNT(*) FROM `users`"), 0);
echo '<img src="ico/search.gif"> <a href = "search.php?search=1">Поиск</a>';
echo '</div>';
if($u['setting_users_list']) $count = $u['setting_users_list']; else $count = 10;
$all = mysql_result(mysql_query("SELECT COUNT(*) FROM `users`"), 0);
if($all > 0){
$total = intval(($all - 1) / $count) + 1;
$page = num($_GET['page']);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $count - $count;
$result = mysql_query("SELECT * FROM `users` ORDER BY `id` ASC LIMIT $start, $count");
while($user = mysql_fetch_assoc($result)){
echo $i % 2 ? '<div class="div">' : '<div class="div">';
if(ban($user['id'])){
echo ''.ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'"><del>'.$user['login'].'</del></a> '.online($user['online']).'';
} else {
echo ''.ico($user['sex'],$user['admin']).' <a href = "/'.$user['id'].'">'.$user['login'].'</a> '.online($user['online']).'';
}
if($user['rating']>=1000 && $user['rating']<=1999)echo "<img src='ico/b.png' alt='' class='icon'</a>n";
if($user['rating']>=2000 && $user['rating']<=2999)echo "<img src='ico/s.png' alt='' class='icon'</a>n";
if($user['rating']>=3000)echo "<img src='ico/z.png' alt='' class='icon'</a>n";
echo '<br/>';
echo '</div>';
$i++;
}
echo '</div>';
navigation($page, $total,'search.php?&');
}else{
echo '<div class="div"> Пользователей не найдено !</div>';
}
echo '</div>';
include 'foot.php';
break;
}
?>