Просмотр поста

.
Taltos
<?php

#--  by 2ziz  --#
#--  E-mail: 2ziz@spaces.ru  --#
#--  http://friendka.tk  --#

define('_IN_JOHNCMS', 1);
$textl = 'Поиск пользователей';
$headmod = 'usersearch';
require_once('../incfiles/core.php');
require('../incfiles/head.php');
echo '<div class="phdr">Поиск пользователей</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']) ? mb_strtolower(functions::check(mb_substr($_POST['live'], 0, 50)), 'utf-8') : '';
$live = $live ? $live : mb_strtolower(functions::check(mb_substr(rawurldecode($_GET['live']), 0, 50)), 'utf-8');
$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', time());
    if ($from_age) {
        $year_from = date('Y', time()) - $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', time()) - $to_age;
        $date = $year_to . '-' . $md;
        $sql .= ' AND UNIX_TIMESTAMP(CONCAT_WS("-",`yearofbirth`,`monthb`,`dayb`)) >= UNIX_TIMESTAMP(\'' . $date . '\')';
    }
    if ($live)
	    $sql .=	' AND LOWER(`live`) LIKE \'%' . functions::trans($live) . '%\' OR LOWER(`live`) LIKE \'%' . functions::rus_lat($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 )';
    }