<?php
/*
////////////////////////////////////////////////////////////////////////////////
// JohnCMS Mobile Content Management System //
// Project site: http://johncms.com //
// Support site: http://gazenwagen.com //
////////////////////////////////////////////////////////////////////////////////
// Lead Developer: Oleg Kasyanov (AlkatraZ) alkatraz@gazenwagen.com //
// Development Team: Eugene Ryabinin (john77) john77@gazenwagen.com //
// Dmitry Liseenko (FlySelf) flyself@johncms.com //
////////////////////////////////////////////////////////////////////////////////
// Search_ex: by Ares^ (ICQ#) //
////////////////////////////////////////////////////////////////////////////////
*/
defined('_IN_JOHNCMS') or die('Error: restricted access');
$textl = 'Расширенный поиск пользователей';
$headmod = 'usersearch';
require('../incfiles/head.php');
echo '<div class="phdr"><a href="index.php"><b>Актив сайта</b></a> | Расширенный поиск пользователей</div>';
/*
-----------------------------------------------------------------
Принимаем данные
-----------------------------------------------------------------
*/
$sex = isset($_REQUEST['sex']) ? abs(intval($_REQUEST['sex'])) : 0;
$from_age = isset($_REQUEST['from']) ? abs(intval($_REQUEST['from'])) : 0;
$to_age = isset($_REQUEST['to']) ? abs(intval($_REQUEST['to'])) : 0;
$live = isset($_POST['live']) ? functions::check(mb_substr($_POST['live'], 0, 50)) : '';
$live = $live ? $live : functions::check(mb_substr(rawurldecode($_GET['live']), 0, 50));
$photo = intval($_REQUEST['photo']) ? 1 : 0;
$online = intval($_REQUEST['online']) ? 1 : 0;
$new = intval($_REQUEST['new']) ? 1 : 0;
/*
-----------------------------------------------------------------
Задаем запрос к БД
-----------------------------------------------------------------
*/
if ($sex) {
$sql = '`sex` = \'' . ($sex == 1 ? 'm' : 'zh') . '\'';
$md = date('m-d', $realtime);
if ($from_age) {
$year_from = date('Y', $realtime) - $from_age;
$date = $year_from . '-' . $md;
$sql .= ' AND UNIX_TIMESTAMP(CONCAT_WS("-",`yearofbirth`,`monthb`,`dayb`)) <= UNIX_TIMESTAMP(\'' . $date . '\') AND `yearofbirth` != \'0\'';
}
if ($to_age) {
$year_to = date('Y', $realtime) - $to_age;
$date = $year_to . '-' . $md;
$sql .= ' AND UNIX_TIMESTAMP(CONCAT_WS("-",`yearofbirth`,`monthb`,`dayb`)) >= UNIX_TIMESTAMP(\'' . $date . '\')';
}
if ($live)
$sql .= ' AND `live` LIKE \'%' . $live . '%\'';
if ($photo) {
$sql .= ' AND `id` IN ( ';
$dir = opendir('../files/users/photo');
while ($file = readdir($dir)) {
$name = explode(".", $file);
$names = preg_replace('#^(.*?)_small.(gif|jpg|png)$#isU', '$1', $file);
if ($name[1] == 'jpg' && $name[0] != $names.'_small' && $name[0] != $user_id) {
$name[0] = $name[0].', ';
$sql .= $name[0];
}
}
closedir($dir);
$sql .= '0 )';
}