Файл: love/index.php
Строк: 369
<?php
require '../sid.php';
require '../config.php';
$link = connect_db();
if (!empty($_SESSION['us'])) {
list($user, $id, $ps) = check_login($link);
whorm(0, 'love');
}
include '../head.php';
include '../navigator.php';
$do = (isset($_GET['do'])) ? $_GET['do'] : NULL;
switch($do) {
default:
echo $div_title . 'Поиск пользователя' . $div_end . $div_left;
unset($_SESSION['nikname']);
unset($_SESSION['ot']);
unset($_SESSION['do']);
unset($_SESSION['sex']);
unset($_SESSION['orient']);
unset($_SESSION['status']);
unset($_SESSION['target']);
unset($_SESSION['mycity']);
unset($_SESSION['foto']);
unset($_SESSION['onsite']);
if (isset($_GET['del'])) {
mysql_query("UPDATE `users` SET `s_city` = '' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: index.php?' . $ref);
}
$_citi = mysql_fetch_array(mysql_query("SELECT `city_name` FROM `geo_cities` WHERE `city_id` = '$user[s_city]'"));
if (!empty($user['s_city'])) {
$s_city = '<a href="index.php?do=city">' . $_citi[0] . '</a>
<a href="index.php?del"><img src="../ico/delete.gif" alt=""/></a>';
} else {
$s_city = '<b>Все города</b>';
}
echo $div_menu . '
<a href="index.php?do=users">Знакомства</a>
' . $div_end . '
<fieldset>
<FORM method="POST" action="index.php?do=result">
<label>Возраст:</label><br/>
От <input type="text" name="ot" size="2" maxlength="2"/>
До <input type="text" name="do" size="2" maxlength="2"/>
<br/>
<label>Пол:</label><br/>
<select name="sex">
<option value="0">Пол</option>
<option value="2">Мужской</option>
<option value="1">Женский</option>
</select>
<br/>
<label>Ориентация:</label><br/>
<select name="orient">
<option value="0">Ориентация</option>
<option value="1">Гетеро</option>
<option value="2">Би</option>
<option value="3">Гей/Лесби</option>
</select>
<br/>
<label>Семейное положение:</label><br/>
<select name="status">
<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/>
<label>Цель знакомства:</label><br/>
<select name="target">
<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>
<option value="7">Виртуальный секс</option>
<option value="8">Предлагаю интим за деньги</option>
<option value="9">Ищу интим за деньги</option>
<option value="10">Брак, создание семьи</option>
<option value="11">Рождение, воспитание ребенка</option>
<option value="12">Брак для вида</option>
<option value="13">Совместная аренда жилья</option>
<option value="14">Занятия спортом</option>
</select>
<br/>
<label>Город:</label> ' . $s_city . ' (<a href="index.php?do=city">выбрать</a>)
<br/>
<input type="checkbox" name="mycity" value="1"/> Свой город
<br/>
<input type="checkbox" name="foto" value="1"/> С фотографией
<br/>
<input type="checkbox" name="onsite" value="1"/> На сайте
<br/>
<input type="submit" name="search" value="Найти"/>
</FORM>
</fieldset>
<label>Простой поиск:</label><br/>
<FORM method="POST" action="index.php?do=view">
<input type="text" name="nikname"/>
<br/>
<label>В поиске можно указывать ник, id</label><br/>
<input type="submit" name="gosearch" value="Найти"/>
</FORM>';
echo $div_end;
break;
case result:
echo $div_title . 'Результаты поиска' . $div_end . $div_left . '
<img src="../ico/search.gif" alt=""/> <a href="index.php?'.$ref.'">Новый поиск</a><br/>
' . $div_menu;
if (isset($_GET['new_all'])) {
$sql_sort = ' `id` DESC ';
echo '<b>Новые</b> |
<a href="index.php?do=result&rating_all">По рейтингу</a> |
<a href="index.php?do=result&last_all">Последние</a>' . $div_end;
} elseif (isset($_GET['rating_all'])) {
$sql_sort = ' `ank_rating` + `rating` DESC ';
echo '<a href="index.php?do=result&new_all">Новые</a> |
<b>По рейтингу</b> |
<a href="index.php?do=result&last_all">Последние</a>' . $div_end;
} elseif (isset($_GET['last_all'])) {
$sql_sort = ' `id` ASC ';
echo '<a href="index.php?do=result&new_all">Новые</a> |
<a href="index.php?do=result&rating_all">По рейтингу</a> |
<b>Последние</b>' . $div_end;
} else {
$sql_sort = ' `onl` DESC ';
echo '<a href="index.php?do=result&new_all">Новые</a> |
<a href="index.php?do=result&rating_all">По рейтингу</a> |
<b>Последние</b>' . $div_end;
}
if (isset($_POST['ot'])) $ot = my_int($_POST['ot']);
if (isset($_POST['do'])) $do = my_int($_POST['do']);
if (isset($_POST['sex'])) $sex = my_int($_POST['sex']);
if (isset($_POST['orient'])) $orient = my_int($_POST['orient']);
if (isset($_POST['status'])) $status = my_int($_POST['status']);
if (isset($_POST['target'])) $target = my_int($_POST['target']);
if (isset($_POST['mycity'])) $mycity = my_int($_POST['mycity']);
if (isset($_POST['foto'])) $foto = my_int($_POST['foto']);
if (isset($_POST['onsite'])) $onsite = my_int($_POST['onsite']);
if (isset($_SESSION['ot'])) $ot = my_int($_SESSION['ot']);
if (isset($_SESSION['do'])) $do = my_int($_SESSION['do']);
if (isset($_SESSION['sex'])) $sex = my_int($_SESSION['sex']);
if (isset($_SESSION['orient'])) $orient = my_int($_SESSION['orient']);
if (isset($_SESSION['status'])) $status = my_int($_SESSION['status']);
if (isset($_SESSION['target'])) $target = my_int($_SESSION['target']);
if (isset($_SESSION['mycity'])) $mycity = my_int($_SESSION['mycity']);
if (isset($_SESSION['foto'])) $foto = my_int($_SESSION['foto']);
if (isset($_SESSION['onsite'])) $onsite = my_int($_SESSION['onsite']);
$_SESSION['ot'] = $ot;
$_SESSION['do'] = $do;
$_SESSION['sex'] = $sex;
$_SESSION['orient'] = $orient;
$_SESSION['status'] = $status;
$_SESSION['target'] = $target;
$_SESSION['mycity'] = $mycity;
$_SESSION['foto'] = $foto;
$_SESSION['onsite'] = $onsite;
// выбор возраста ОТ
if ($ot != 0) {
$s_age_ot = '>= ' . $ot;
} else {
$s_age_ot = "LIKE '%'";
}
// выбор возраста ДО
if ($do != 0) {
$s_age_do = '<= ' . $do;
} else {
$s_age_do = "LIKE '%'";
}
// выбор пола
if ($sex == 1) {
$_sex = '= ' . 1;
} elseif ($sex == 2) {
$_sex = '= ' . 2;
} else {
$_sex = "LIKE '%'";
}
// выбор семейного положения
if ($sex == 1 && $status == 1) {
$_stat = "= 'Не замужем'";
} elseif ($sex == 1 && $status == 2) {
$_stat = "= 'Есть друг'";
} elseif ($sex == 1 && $status == 3) {
$_stat = "= 'Помолвлена'";
} elseif ($sex == 1 && $status == 4) {
$_stat = "= 'Замужем'";
} elseif ($sex == 2 && $status == 1) {
$_stat = "= 'Не женат'";
} elseif ($sex == 2 && $status == 2) {
$_stat = "= 'Есть подруга'";
} elseif ($sex == 2 && $status == 3) {
$_stat = "= 'Помолвлен'";
} elseif ($sex == 2 && $status == 4) {
$_stat = "= 'Женат'";
} else {
$_stat = "LIKE '%'";
}
// выбор ориентации
if ($orient == 1) {
$_orient = "= 'Гетеро'";
} elseif ($orient == 2) {
$_orient = "= 'Би'";
} elseif ($orient == 3) {
$_orient = "= 'Гей/Лесби'";
} else {
$_orient = "LIKE '%'";
}
// выбор целей знакомства
if ($target == 1) {
$_target = "`tar_1` != '' AND";
} elseif ($target == 2) {
$_target = "`tar_2` != '' AND";
} elseif ($target == 3) {
$_target = "`tar_3` != '' AND";
} elseif ($target == 4) {
$_target = "`tar_4` != '' AND";
} elseif ($target == 5) {
$_target = "`tar_5` != '' AND";
} elseif ($target == 6) {
$_target = "`tar_6` != '' AND";
} elseif ($target == 7) {
$_target = "`tar_7` != '' AND";
} elseif ($target == 8) {
$_target = "`tar_8` != '' AND";
} elseif ($target == 9) {
$_target = "`tar_9` != '' AND";
} elseif ($target == 10) {
$_target = "`tar_10` != '' AND";
} elseif ($target == 11) {
$_target = "`tar_11` != '' AND";
} elseif ($target == 12) {
$_target = "`tar_12` != '' AND";
} elseif ($target == 13) {
$_target = "`tar_13` != '' AND";
} elseif ($target == 14) {
$_target = "`tar_14` != '' AND";
}
// выбор города
if ($mycity == 1 && $user['city'] == 0) {
$_citi = 0;
} elseif ($mycity == 1 && $user['city'] != 0) {
$_citi = '= ' . $user['city'];
} elseif ($mycity == 0 && $user['s_city'] != 0) {
$_citi = '= ' . $user['s_city'];
} else {
$_citi = "LIKE '%'";
}
// с фото или без
if ($foto == 1) {
$_foto = "`img` != ''";
} else {
$_foto = "`img` LIKE '%'";
}
// онлайн или офлайн
if ($onsite == 1) {
$_on = "`onl` + '200' > '" . time() . "'";
} else {
$_on = "`onl` LIKE '%'";
}
$look = mysql_result(mysql_query("SELECT COUNT(*) FROM `users`
WHERE
`age` {$s_age_ot} AND
`age` {$s_age_do} AND
`sex` {$_sex} AND
`sp_st` {$_stat} AND
`orient` {$_orient} AND
{$_target}
`city` {$_citi} AND
{$_foto} AND
{$_on}
"), 0);
$n = new navigator($look, 10, '?do=result&');
$res = mysql_query("SELECT * FROM `users` WHERE
`age` {$s_age_ot} AND
`age` {$s_age_do} AND
`sex` {$_sex} AND
`sp_st` {$_stat} AND
`orient` {$_orient} AND
{$_target}
`city` {$_citi} AND
{$_foto} AND
{$_on}
ORDER BY {$sql_sort} {$n->limit}");
$resIn = mysql_query("SELECT * FROM `liders` ORDER BY RAND() LIMIT 1");
////////////////////////////////////
if (mysql_num_rows($resIn) != false) {
$InRes = mysql_fetch_assoc($resIn);
$Status = (!empty($InRes['xstatus'])) ? '<br/><div class="q1"></div><div class="q2">' . smiles(bb_code($InRes['xstatus'])) . '</div>' : '';
echo $div_aut . us($InRes['user']) . $Status . '<br/>
<img src="../ico/lider.gif" alt=""/> <a href="../liders.php?'.$ref.'">Все лидеры</a>' . $div_end;
}
////////////////////////////////////
if ($look != FALSE) {
$i = 0;
while($a = mysql_fetch_assoc($res)) {
$Status = (!empty($a['xstatus'])) ? '<br/><div class="q1"></div><div class="q2">' . smiles(bb_code($a['xstatus'])) . '</div>' : '';
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo nikus($a['id']) . $Status . $div_end;
}
echo $n->navi();
} else {
echo 'Поиск не дал результатов!<br/>';
}
echo $div_end;
break;
case city:
echo $div_title . 'Выбрать город' . $div_end . $div_left;
if (isset($_GET['ok'])) {
$ok = my_int($_GET['ok']);
mysql_query("UPDATE `users` SET `s_city` = '$ok' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: index.php?' . $ref);
}
if (isset($_GET['r'])) {
$look = mysql_result(mysql_query("SELECT COUNT(*) FROM `geo_cities` WHERE `rid` = '" . (int)$_GET['r'] . "'"), 0);
$n = new navigator($look, 10, '?do=city&r='.(int)$_GET['r'].'&');
$gorod = mysql_query("SELECT * FROM `geo_cities` WHERE `rid` = '" . (int)$_GET['r'] . "' ORDER BY `city_name` ASC {$n->limit}");
$i = 0;
if ($look != FALSE) {
while($a = mysql_fetch_assoc($gorod)) {
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<a href="index.php?do=city&ok='.$a['city_id'].'">' . $a['city_name'] . '</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Городов нет!<br/>';
}
}
elseif (isset($_GET['c'])) {
$look = mysql_result(mysql_query("SELECT COUNT(*) FROM `geo_regions` WHERE `cid` = '" . (int)$_GET['c'] . "'"), 0);
$n = new navigator($look, 10, '?do=city&c='.(int)$_GET['c'].'&');
$gorod = mysql_query("SELECT * FROM `geo_regions` WHERE `cid` = '" . (int)$_GET['c'] . "' ORDER BY `region_name` ASC {$n->limit}");
$i = 0;
if ($look != FALSE) {
while($a = mysql_fetch_assoc($gorod)) {
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo '<a href="index.php?do=city&r='.$a['region_id'].'">' . $a['region_name'] . '</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Регионов нет!<br/>';
}
} else {
$look = mysql_result(mysql_query("SELECT COUNT(*) FROM `geo_countries`"), 0);
$n = new navigator($look, 10, '?do=city&');
$gorod_1 = mysql_query("SELECT * FROM `geo_countries` WHERE `country_id` = '3159' OR `country_id` = '9908' ORDER BY `country_name` ASC {$n->limit}");
$gorod_2 = mysql_query("SELECT * FROM `geo_countries` WHERE `country_id` != '3159' AND `country_id` != '9908' ORDER BY `country_name` ASC {$n->limit}");
$i = 0;
if ($look != FALSE) {
// Вывод России и Украины
while($a = mysql_fetch_assoc($gorod_1)) {
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $fl . '<a href="index.php?do=city&c='.$a['country_id'].'">' . $a['country_name'] . '</a>' . $div_end;
}
// Вывод остальных...
while($aa = mysql_fetch_assoc($gorod_2)) {
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo $fl . '<a href="index.php?do=city&c='.$aa['country_id'].'">' . $aa['country_name'] . '</a>' . $div_end;
}
echo $n->navi();
} else {
echo 'Стран нет!<br/>';
}
}
echo $div_end;
break;
case users:
echo $div_title . 'Знакомства' . $div_end . $div_left . '
<img src="../ico/search.gif" alt=""/> <a href="index.php?'.$ref.'">Новый поиск</a><br/>
' . $div_menu;
if (isset($_GET['new_all'])) {
$sql_sort = ' `id` DESC ';
echo '<b>Новые</b> |
<a href="index.php?do=result&rating_all">По рейтингу</a> |
<a href="index.php?do=result&last_all">Последние</a>' . $div_end;
} elseif (isset($_GET['rating_all'])) {
$sql_sort = ' `ank_rating` + `rating` DESC ';
echo '<a href="index.php?do=result&new_all">Новые</a> |
<b>По рейтингу</b> |
<a href="index.php?do=result&last_all">Последние</a>' . $div_end;
} elseif (isset($_GET['last_all'])) {
$sql_sort = ' `id` ASC ';
echo '<a href="index.php?do=result&new_all">Новые</a> |
<a href="index.php?do=result&rating_all">По рейтингу</a> |
<b>Последние</b>' . $div_end;
} else {
$sql_sort = ' `id` ASC ';
echo '<a href="index.php?do=result&new_all">Новые</a> |
<a href="index.php?do=result&rating_all">По рейтингу</a> |
<b>Последние</b>' . $div_end;
}
$look = mysql_result(mysql_query("SELECT COUNT(*) FROM `users`"), 0);
$n = new navigator($look, 10, '?do=users&');
$res = mysql_query("SELECT * FROM `liders` ORDER BY RAND() LIMIT 1");
$res_2 = mysql_query("SELECT `id`, `xstatus` FROM `users` ORDER BY {$sql_sort} {$n->limit}");
////////////////////////////////////
if (mysql_num_rows($res) != false) {
$InRes = mysql_fetch_assoc($res);
echo $div_aut . us($InRes['user']) . '<br/>
' . bb_code(smiles($InRes['text'])) . '<br/>
<img src="../ico/lider.gif" alt=""/> <a href="../liders.php?'.$ref.'">Все лидеры</a>' . $div_end;
}
////////////////////////////////////
if ($look != FALSE) {
$i = 0;
while($a = mysql_fetch_assoc($res_2)) {
$Status = (!empty($a['xstatus'])) ? '<br/><div class="q1"></div><div class="q2">' . smiles(bb_code($a['xstatus'])) . '</div>' : '';
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo nikus($a['id']) . $Status . $div_end;
}
echo $n->navi();
} else {
echo 'Поиск не дал результатов!<br/>';
}
echo $div_end;
break;
case view:
echo $div_title . 'Знакомства' . $div_end . $div_left . '
<img src="../ico/search.gif" alt=""/> <a href="index.php?'.$ref.'">Новый поиск</a>' . $block;
if (isset($_SESSION['nikname'])) $nikname = trim(mysql_real_escape_string(check($_SESSION['nikname'])));
if (isset($_POST['nikname'])) $nikname = trim(mysql_real_escape_string(check($_POST['nikname'])));
$nikname = addcslashes($nikname, '_%');
$_SESSION['nikname'] = $nikname;
if (!ctype_digit($nikname)) {
$se = "`user` LIKE '%$nikname%'";
} else {
$nikname = my_int($nikname);
$se = "`id` = '$nikname'";
}
$look = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE $se"), 0);
$n = new navigator($look, 10, '?do=view&');
$view = mysql_query("SELECT * FROM `users` WHERE $se ORDER BY `id` DESC {$n->limit}");
if ($look != FALSE) {
$i = 0;
while($a = mysql_fetch_assoc($view)) {
echo ($i ++ % 2) ? $div_tworazdel : $div_razdel;
echo nik($a['id']) . $div_end;
}
echo $n->navi();
} else {
echo 'Поиск не дал результатов!<br/>';
}
echo $div_end;
break;
}
include '../foot.php';
?>