<?php

/* DCMS Special
 * Дата последнего редактирования 01.10.2016
 * Модифицировал densnet
 */

foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'user') as $inc) {
    require_once H . "sys/inc/$inc.php";
}

require_once H . 'sys/inc/thead.php';

$sort = 'id';
$por = 'DESC';

if (isset($_GET['ASC'])) {
    $por = 'ASC';
} #прямой порядок

if (isset($_GET['DESC'])) {
    $por = 'DESC';
} #обратный порядок

$act_money = null;
$act_activity = null;
$act_rating = null;
$act_sex = null;
$act_id = null;

switch (@$_GET['sort']) {
    case 'money':
        $sql_sort = '`user`.`money`';
        $sort = 'money'; #рубли
        $act_money = ' active';
        break;
    case 'activity':
        $sql_sort = '`user`.`activity`';
        $sort = 'activity'; #активность
        $act_activity = ' active';
        break;
    case 'rating':
        $sql_sort = '`user`.`rating`';
        $sort = 'rating'; #рейтинг
        $act_rating = ' active';
        break;
    case 'sex':
        $sql_sort = '`user`.`sex`';
        $sort = 'sex'; #пол
        $act_sex = ' active';
        break;
    case 'id':
        $sql_sort = '`user`.`id`';
        $sort = 'id'; #пол
        $act_id = ' active';
        break;
    default:
        $sql_sort = '`user`.`id`';
        $sort = 'id'; #ID
        $act_id = ' active';
        break;
}

$act = (isset($_GET['act'])) ? htmlspecialchars($_GET['act']) : null;

switch ($act) {
    default:

        #Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Пользователи');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>
                <li class='nav-item'>
                    <a class='nav-link active'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=online'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";


        $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user`"), 0);
        $k_page = k_page($k_post, $set['p_str']);
        $page = page($k_page);
        $start = $set['p_str'] * $page - $set['p_str'];

        echo "<div class='list-group-item-null'>";
        echo "<ul class='nav nav-pills'>";
        echo "<li class='nav-item'><a class='nav-link $act_id' href='/?users&amp;sort=id&amp;DESC&amp;page=$page'>ID</a></li>";
        echo "<li class='nav-item'><a class='nav-link $act_money' href='/?users&amp;sort=money&amp;DESC&amp;page=$page'>" . lang('Рубли') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link $act_activity' href='/?users&amp;sort=activity&amp;DESC&amp;page=$page'>" . lang('Активность') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link $act_rating' href='/?users&amp;sort=rating&amp;DESC&amp;page=$page'>" . lang('Рейтинг') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link $act_sex' href='/?users&amp;sort=sex&amp;DESC&amp;page=$page'>" . lang('Пол') . "</a></li>";
        echo "</ul></div>";

        if ($k_post == 0) {
            $doc->NoResult();
        }

        $q = mysql_query("SELECT `user`.`id` FROM `user` LEFT JOIN `user_group` ON `user`.`group_access` = `user_group`.`id` ORDER BY $sql_sort $por LIMIT $start, $set[p_str]");
        while ($ank = mysql_fetch_assoc($q)) {
            $ank = get_user($ank['id']);

            echo "<table class='list-group-item-null'><tr><td class='icon14'>";
            avatar($ank['id'], '48', 'border-radius: 2px;');
            echo "</td><td class='null'>";

            if (isset($user) && $user['id'] != $ank['id']) {
                echo "<span style='float:right;'>";
                echo "<a href='/user/mail/messageList.php?contact=$ank[id]' class='hint--left' data-hint='" . lang('Отправить сообщение') . "'><i class='fa fa-envelope fa-fw'></i></a> ";
                echo "</span>";
            } else {
                if (isset($user)) {
                    echo "<span style='float:right;color: grey;'>" . lang('Это Вы') . "</span>";
                }
            }

            user($ank['id']);

            echo "<br />";

            if ($sort == 'rating') {
                echo lang('Рейтинг') . ": $ank[rating]<br />";
            }
            if ($sort == 'level') {
                if ($ank['group_access'] > 1) {
                    echo "$ank[group_name]<br />";
                }
            } else {
                
            }
            if ($sort == 'money') {
                echo lang('Рубли') . ": $ank[money]<br />";
            }
            if ($sort == 'activity') {
                echo lang('Активность') . ": $ank[activity]<br />";
            }
            if ($sort == 'sex') {
                echo lang('Пол') . ": " . (($ank['sex'] == 1) ? '' . lang('Мужской') . '' : '' . lang('Женский') . '') . "<br />";
            }

            if ($sort == 'id') {
                echo "ID: $ank[id]<br />";
            }
            echo "</td></tr></table>";
            echo "<div class='hr'></div>";
        }


#Вывод страниц
        if ($k_page > 1) {
            str("/?users&amp;sort=$sort&amp;$por&amp;", $k_page, $page);
        }

        break;

    case 'online':

        #Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Онлайн пользователи');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link active'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_last` > '" . (time() - 600) . "'"), 0);
        $k_page = k_page($k_post, $set['p_str']);
        $page = page($k_page);
        $start = $set['p_str'] * $page - $set['p_str'];

        echo "<div class='list-group-item-null'>";
        echo "<ul class='nav nav-pills'>";
        echo "<li class='nav-item'><a class='nav-link $act_id' href='/?users&amp;act=online&amp;sort=id&amp;DESC&amp;page=$page'>ID</a></li>";
        echo "<li class='nav-item'><a class='nav-link $act_money' href='/?users&amp;act=online&amp;sort=money&amp;DESC&amp;page=$page'>" . lang('Рубли') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link $act_activity' href='/?users&amp;act=online&amp;sort=activity&amp;DESC&amp;page=$page'>" . lang('Активность') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link $act_rating' href='/?users&amp;act=online&amp;sort=rating&amp;DESC&amp;page=$page'>" . lang('Рейтинг') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link $act_sex' href='/?users&amp;act=online&amp;sort=sex&amp;DESC&amp;page=$page'>" . lang('Пол') . "</a></li>";
        echo "</ul></div>";

        $q = mysql_query("SELECT `id` FROM `user` WHERE `date_last` > '" . (time() - 600) . "' ORDER BY $sql_sort $por LIMIT $start, $set[p_str]");

        if ($k_post == 0) {
            $doc->NoResult();
        }

        while ($ank = mysql_fetch_assoc($q)) {
            $ank = get_user($ank['id']);
            echo "<table class='list-group-item-null'><tr><td class='icon14'>";
            avatar($ank['id'], '48', 'border-radius: 2px;');
            echo "</td><td class='null'>";

            if (isset($user) && $user['id'] != $ank['id']) {
                echo "<span style='float:right;'>";
                echo "<a href='/user/mail/messageList.php?contact=$ank[id]' class='hint--left' data-hint='" . lang('Отправить сообщение') . "'><i class='fa fa-envelope fa-fw'></i></a> ";
                echo "</span>";
            } else {
                if (isset($user)) {
                    echo "<span style='float:right;'>" . lang('Это Вы') . "</span>";
                }
            }

            user($ank['id']);

            echo "<br />";

            if ($sort == 'rating') {
                echo lang('Рейтинг') . ": $ank[rating]<br />";
            }
            if ($sort == 'level') {
                if ($ank['group_access'] > 1) {
                    echo "$ank[group_name]<br />";
                }
            } else {
                
            }
            if ($sort == 'money') {
                echo lang('Рубли') . ": $ank[money]<br />";
            }
            if ($sort == 'activity') {
                echo lang('Активность') . ": $ank[activity]<br />";
            }
            if ($sort == 'sex') {
                echo lang('Пол') . ": " . (($ank['sex'] == 1) ? '' . lang('Мужской') . '' : '' . lang('Женский') . '') . "<br />";
            }

            if ($sort == 'id') {
                echo "ID: $ank[id]<br />";
            }
            echo "</td></tr></table>";
            echo "<div class='hr'></div>";
        }

        #Вывод страниц
        if ($k_page > 1) {
            str("/?users&amp;act=online&amp;sort=$sort&amp;$por&amp;", $k_page, $page);
        }
        break;

    case 'guest':
        #Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Гости на сайте');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -12px;'>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=online'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link active' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `guests` WHERE `date_last` > '" . (time() - 600) . "' AND `pereh` > '0'"), 0);
        $k_page = k_page($k_post, $set['p_str']);
        $page = page($k_page);
        $start = $set['p_str'] * $page - $set['p_str'];
        $q = mysql_query("SELECT * FROM `guests` WHERE `date_last` > '" . (time() - 600) . "' AND `pereh` > '0' ORDER BY `date_aut` DESC LIMIT $start, $set[p_str]");

        if ($k_post == 0) {
            echo "<br />";
            $doc->NoResult();
        }
        while ($guest = mysql_fetch_assoc($q)) {
            echo "<div class='list-group-item-null'>";
            echo lang('Гость') . "<br/>";
            echo lang('Посл. посещение') . ": " . date::times($guest['date_last']) . "<br />";
            echo lang('Переходов') . ": $guest[pereh]<br />";

            if ($guest['ua'] != NULL) {
                echo "UA: $guest[ua]<br />";
            }

            if (isset($user) && ($user['level'] > 0)) {
                if (access('guest_show_ip') && $guest['ip'] != 0) {
                    echo "IP: " . long2ip($guest['ip']) . "<br />";
                }

                if (access('guest_show_ip') && opsos($guest['ip'])) {
                    echo "Пров: " . opsos($guest['ip']) . "<br />";
                }

                if (otkuda($guest['url'])) {
                    echo "URL: <a href = '$guest[url]'>" . otkuda($guest['url']) . "</a><br />";
                }
            }

            echo "</div>";
            echo "<div class='hr'></div>";
        }
        if ($k_page > 1) {
            str("/?users&amp;act=guest&amp;", $k_page, $page);
        }

        break;
    case 'todey':
        #Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Сегодня заходили');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=online'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link active' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_last` > '" . TIME_TODAY . "'"), 0);
        $k_page = k_page($k_post, $set['p_str']);
        $page = page($k_page);
        $start = $set['p_str'] * $page - $set['p_str'];

        if ($k_post == 0) {
            $doc->NoResult();
        }

        $q = mysql_query("SELECT `id` FROM `user` WHERE `date_last` > '" . TIME_TODAY . "' ORDER BY $sql_sort $por LIMIT $start, $set[p_str]");
        while ($ank = mysql_fetch_assoc($q)) {
            $ank = get_user($ank['id']);

            echo "<table class='list-group-item-null'><tr><td class='icon14'>";
            avatar($ank['id'], '48', 'border-radius: 2px;');
            echo "</td><td class='null'>";

            if (isset($user) && $user['id'] != $ank['id']) {
                echo "<span style='float:right;'>";
                echo "<a href='/user/mail/messageList.php?contact=$ank[id]' class='hint--left' data-hint='" . lang('Отправить сообщение') . "'><i class='fa fa-envelope fa-fw'></i></a> ";
                echo "</span>";
            } else {
                if (isset($user)) {
                    echo "<span style='float:right;'>" . lang('Это Вы') . "</span>";
                }
            }

            user($ank['id']);
            echo "</td></tr></table>";
            echo "<div class='hr'></div>";
        }


#Вывод страниц
        if ($k_page > 1) {
            str("/?users&amp;act=todey&amp;sort=$sort&amp;$por&amp;", $k_page, $page);
        }

        break;

    case 'other':
        #Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/modules/users/'>" . lang('Пользователи') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Прочее');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=online'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $users = "<span class='count'>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_reg` > '" . ($time - 86400) . "'"), 0) . "</span>";
        $man = "<span class='count'>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `sex` = '1'"), 0) . "</span>";
        $woman = "<span class='count'>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `sex` = '0'"), 0) . "</span>";
        $ban = "<span class='count'>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `time` > '$time'"), 0) . "</span>";
        $admin = "<span class='count'>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `group_access` > '1'"), 0) . "</span>";
        $currD = date("d", time());
        $currm = date("m", time());
        $dr = "<span class='count'>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `ank_d_r` = '$currD' and `ank_m_r` = '$currm'", $db), 0) . "</span>";

        echo "<a class='list-group-item-null' href='/modules/users/search.php'><i class='fa fa-search fa-fw'></i> " . lang('Поиск по городу') . "</a>\n";
        echo "<a class='list-group-item-null' href='/?users'><i class='fa fa-user-plus fa-fw'></i> " . lang('Новые пользователи') . " $users</a>\n";
        echo "<a class='list-group-item-null' href='/?users&amp;act=man'><i class='fa fa-mars fa-fw'></i> " . lang('Парни') . " $man</a>\n";
        echo "<a class='list-group-item-null' href='/?users&amp;act=woman'><i class='fa fa-venus fa-fw'></i> " . lang('Девушки') . " $woman</a>\n";
        echo "<a class='list-group-item-null' href='/?users&amp;act=dr'><i class='fa fa-birthday-cake fa-fw'></i> " . lang('Именинники') . " $dr</a>\n";
        echo "<a class='list-group-item-null' href='/?users&amp;act=ban'><i class='fa fa-gavel fa-fw'></i> " . lang('Нарушители') . " $ban</a>\n";
        echo "<a class='list-group-item-null' href='/?users&amp;act=admin'><i class='fa fa-users fa-fw'></i> " . lang('Администрация') . " $admin</a>\n";

        break;
    case 'ban':
        #Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/modules/users/'>" . lang('Пользователи') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Нарушители');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=online'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `ban` WHERE `time` > '$time'"), 0);
        $k_page = k_page($k_post, $set['p_str']);
        $page = page($k_page);
        $start = $set['p_str'] * $page - $set['p_str'];

        if ($k_post == 0) {
            $doc->NoResult();
        }

        $q = mysql_query("SELECT * FROM `ban` WHERE `time` > '$time' ORDER BY `id` DESC LIMIT $start, $set[p_str]");

        while ($ban = mysql_fetch_array($q)) {
            $ank = get_user($ban['id_user']);
            echo "<table class='list-group-item-null'><tr><td class='icon14'>";
            avatar($ank['id'], '48', 'border-radius: 2px;');
            echo "</td><td class = 'null'>";
            user($ank['id']);
            echo "<br />";

            $user_ban = get_user($ban['id_ban']);


            echo "<small>" . lang('Осталось') . " " . date::time($ban['time']) . ":</small><br />\n";
            echo "<small>" . toOutput($ban['prich']) . "</small> ($user_ban[nick])<br />\n";
            echo "</td></tr></table>";
            echo "<div class='hr'></div>";
        }

        if ($k_page > 1) {
            str("/?users&amp;act=ban&amp;sort=$sort&amp;$por&amp;", $k_page, $page);
        }

        break;
    case 'admin':
        #Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/modules/users/'>" . lang('Пользователи') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Администрация');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=online'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `group_access` > '1'"), 0);
        $k_page = k_page($k_post, $set['p_str']);
        $page = page($k_page);
        $start = $set['p_str'] * $page - $set['p_str'];

        echo "<div class='list-group-item-null'>";
        echo "<ul class='nav nav-pills'>";
        echo "<li class='nav-item'><a class='nav-link active' href='/?users&amp;act=admin'>" . lang('Администрация') . "</a></li>";
        echo "</ul></div>";

        if ($k_post == 0) {
            $doc->NoResult();
        }

        $q = mysql_query("SELECT `id` FROM `user` WHERE `group_access` > '1' ORDER BY `group_access` DESC LIMIT $start, $set[p_str]");

        while ($adm = mysql_fetch_array($q)) {
            $ank = get_user($adm['id']);
            echo "<table class='list-group-item-null'><tr><td class='icon14'>";
            avatar($ank['id'], '48', 'border-radius: 2px;');
            echo "</td><td class = 'null'>";
            if (isset($user) && $user['id'] != $ank['id']) {
                echo "<span style='float:right;'>";
                echo "<a href='/user/mail/messageList.php?contact=$ank[id]' class='hint--left' data-hint='" . lang('Отправить сообщение') . "'><i class='fa fa-envelope fa-fw'></i></a> ";
                echo "</span>";
            } else {
                if (isset($user)) {
                    echo "<span style='float:right;'>" . lang('Это Вы') . "</span>";
                }
            }
            user($ank['id']);
            echo "<br />";

            echo "<b>$ank[group_name]</b><br />\n";
            echo lang('Посл. посещение') . ": " . date::time($ank['date_last']);
            echo "</td></tr></table>";
            echo "<div class='hr'></div>";
        }

        if ($k_page > 1) {
            str("/?users&amp;act=admin&amp;sort=$sort&amp;$por&amp;", $k_page, $page);
        }

        break;
    case 'dr':
#Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/modules/users/'>" . lang('Пользователи') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Именинники');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=online'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $currD = date("d", time());
        $currm = date("m", time());

        $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `ank_d_r` = '$currD' and `ank_m_r` = '$currm'", $db), 0);
        $k_page = k_page($k_post, $set['p_str']);
        $page = page($k_page);
        $start = $set['p_str'] * $page - $set['p_str'];

        echo "<div class='list-group-item-null'>";
        echo "<ul class='nav nav-pills'>";
        echo "<li class='nav-item'><a class='nav-link active' href='/?users&amp;act=dr'>" . lang('Сегодня') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link' href='/?users&amp;act=dr1'>" . lang('Завтра') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link' href='/?users&amp;act=dr2'>" . lang('Послезавтра') . "</a></li>";
        echo "</ul></div>";
        echo "<div class='list-group-item-null'>";
        echo "<img src='/style/icons/dr.png' style='margin-top: -10px;margin-left: -10px;margin-bottom: -16px;'/>";
        echo "</div>";

        if ($k_post == 0) {
            $doc->NoResult();
        }

        $q = mysql_query("SELECT * FROM `user` WHERE `ank_d_r` = '$currD' and `ank_m_r` = '$currm' LIMIT $start, $set[p_str]");

        while ($ank = mysql_fetch_array($q)) {
            echo "<table class='list-group-item-null'><tr><td class='icon14'>";
            avatar($ank['id'], '48', 'border-radius: 2px;');
            echo "</td><td class = 'null'>";
            if (isset($user) && $user['id'] != $ank['id']) {
                echo "<span style='float:right;'>";
                echo " <a href='/modules/gifts/?id=$ank[id]&amp;do' class='hint--left' data-hint='" . lang('Подарить подарок') . "'><i class='fa fa-gift fa-fw'></i></a> ";
                echo " <a href='/user/mail/messageList.php?contact=$ank[id]' class='hint--left' data-hint='" . lang('Отправить сообщение') . "'><i class='fa fa-envelope'></i></a> ";
                echo "</span>";
            } else {
                if (isset($user)) {
                    echo "<span style='float:right;'>" . lang('Это Вы') . "</span>";
                }
            }
            user($ank['id']);
            echo "<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 lang('исполнилось') . " " . sklon_text($ank['ank_age'], array('год', 'года', 'лет')) . ",\n";
            }
            if ($ank['ank_city'] != NULL) {
                echo " $ank[ank_city]\n";
            } else {
                echo " " . lang('город не указан') . "\n";
            }
            if ($ank['country'] != NULL) {
                echo country($ank['id']);
            }
            echo "</td></tr></table>";
            echo "<div class='hr'></div>";
        }

        if ($k_page > 1) {
            str("/?users&amp;act=dr&amp;sort=$sort&amp;$por&amp;", $k_page, $page);
        }

        break;
    case 'dr1':
        #Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/modules/users/'>" . lang('Пользователи') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Именинники');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=online'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `ank_d_r` = '" . (date('d') + 1) . "' and `ank_m_r` = '" . date('m') . "'", $db), 0);
        $k_page = k_page($k_post, $set['p_str']);
        $page = page($k_page);
        $start = $set['p_str'] * $page - $set['p_str'];

        echo "<div class='list-group-item-null'>";
        echo "<ul class='nav nav-pills'>";
        echo "<li class='nav-item'><a class='nav-link' href='/?users&amp;act=dr'>" . lang('Сегодня') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link active' href='/?users&amp;act=dr1'>" . lang('Завтра') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link' href='/?users&amp;act=dr2'>" . lang('Послезавтра') . "</a></li>";
        echo "</ul></div>";
        echo "<div class='list-group-item-null'>";
        echo "<img src='/style/icons/dr.png' style='margin-top: -10px;margin-left: -10px;margin-bottom: -16px;'/>";
        echo "</div>";

        if ($k_post == 0) {
            $doc->NoResult();
        }

        $q = mysql_query("SELECT * FROM `user` WHERE `ank_d_r` = '" . (date('d') + 1) . "' and `ank_m_r` = '" . date('m') . "' AND `date_last` > '" . (time() - 86400) . "' LIMIT $start, $set[p_str]");

        while ($ank = mysql_fetch_array($q)) {
            echo "<table class='list-group-item-null'><tr><td class='icon14'>";
            avatar($ank['id'], '48', 'border-radius: 2px;');
            echo "</td><td class='null'>";
            if (isset($user) && $user['id'] != $ank['id']) {
                echo "<span style='float:right;'>";
                echo " <a href='/modules/gifts/?id=$ank[id]&amp;do' class='hint--left' data-hint='" . lang('Подарить подарок') . "'><i class='fa fa-gift fa-fw'></i></a> ";
                echo " <a href='/user/mail/messageList.php?contact=$ank[id]' class='hint--left' data-hint='" . lang('Отправить сообщение') . "'><i class='fa fa-envelope'></i></a> ";
                echo "</span>";
            } else {
                if (isset($user)) {
                    echo "<span style='float:right;'>" . lang('Это Вы') . "</span>";
                }
            }
            user($ank['id']);
            echo "<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 lang('исполнится') . " " . sklon_text($ank['ank_age'], array('год', 'года', 'лет')) . ",\n";
            }
            if ($ank['ank_city'] != NULL) {
                echo " $ank[ank_city]\n";
            } else {
                echo " " . lang('город не указан') . "\n";
            }
            if ($ank['country'] != NULL) {
                echo country($ank['id']);
            }
            echo "</td></tr></table>";
            echo "<div class='hr'></div>";
        }

        if ($k_page > 1) {
            str("/?users&amp;act=dr&amp;sort=$sort&amp;$por&amp;", $k_page, $page);
        }

        break;
    case 'dr2':
#Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/modules/users/'>" . lang('Пользователи') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Именинники');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=online'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `ank_d_r` = '" . (date('d') + 2) . "' and `ank_m_r` = '" . date('m') . "'", $db), 0);
        $k_page = k_page($k_post, $set['p_str']);
        $page = page($k_page);
        $start = $set['p_str'] * $page - $set['p_str'];

        echo "<div class='list-group-item-null'>";
        echo "<ul class='nav nav-pills'>";
        echo "<li class='nav-item'><a class='nav-link' href='/?users&amp;act=dr'>" . lang('Сегодня') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link' href='/?users&amp;act=dr1'>" . lang('Завтра') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link active' href='/?users&amp;act=dr2'>" . lang('Послезавтра') . "</a></li>";
        echo "</ul></div>";
        echo "<div class='list-group-item-null'>";
        echo "<img src='/style/icons/dr.png' style='margin-top: -10px;margin-left: -10px;margin-bottom: -16px;'/>";
        echo "</div>";

        if ($k_post == 0) {
            $doc->NoResult();
        }

        $q = mysql_query("SELECT * FROM `user` WHERE `ank_d_r` = '" . (date('d') + 2) . "' and `ank_m_r` = '" . date('m') . "' AND `date_last` > '" . (time() - 86400) . "' LIMIT $start, $set[p_str]");

        while ($ank = mysql_fetch_array($q)) {
            echo "<table class='list-group-item-null'><tr><td class='icon14'>";
            avatar($ank['id'], '48', 'border-radius: 2px;');
            echo "</td><td class = 'null'>";
            if (isset($user) && $user['id'] != $ank['id']) {
                echo "<span style='float:right;'>";
                echo " <a href='/modules/gifts/?id=$ank[id]&amp;do' class='hint--left' data-hint='" . lang('Подарить подарок') . "'><i class='fa fa-gift fa-fw'></i></a> ";
                echo " <a href='/user/mail/messageList.php?contact=$ank[id]' class='hint--left' data-hint='" . lang('Отправить сообщение') . "'><i class='fa fa-envelope'></i></a> ";
                echo "</span>";
            } else {
                if (isset($user)) {
                    echo "<span style='float:right;'>" . lang('Это Вы') . "</span>";
                }
            }
            user($ank['id']);
            echo "<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 lang('исполнится') . " " . sklon_text($ank['ank_age'], array('год', 'года', 'лет')) . ",\n";
            }
            if ($ank['ank_city'] != NULL) {
                echo " $ank[ank_city]\n";
            } else {
                echo " " . lang('город не указан') . "\n";
            }
            if ($ank['country'] != NULL) {
                echo country($ank['id']);
            }
            echo "</td></tr></table>";
            echo "<div class='hr'></div>";
        }

        if ($k_page > 1) {
            str("/?users&amp;act=dr&amp;sort=$sort&amp;$por&amp;", $k_page, $page);
        }

        break;
    case 'man':
        #Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/modules/users/'>" . lang('Пользователи') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Парни');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=online'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `sex` = '1'"), 0);
        $k_page = k_page($k_post, $set['p_str']);
        $page = page($k_page);
        $start = $set['p_str'] * $page - $set['p_str'];

        echo "<div class='list-group-item-null'>";
        echo "<ul class='nav nav-pills'>";
        echo "<li class='nav-item'><a class='nav-link active' href='/?users&amp;act=man'>" . lang('Парни') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link' href='/?users&amp;act=woman'>" . lang('Девушки') . "</a></li>";
        echo "</ul></div>";

        if ($k_post == 0) {
            $doc->NoResult();
        }

        $q = mysql_query("SELECT * FROM `user` WHERE `sex` = '1' LIMIT $start, $set[p_str]");

        while ($ank = mysql_fetch_array($q)) {
            echo "<table class='list-group-item-null'><tr><td class='icon14'>";
            avatar($ank['id'], '48', 'border-radius: 2px;');
            echo "</td><td class = 'null'>";
            if (isset($user) && $user['id'] != $ank['id']) {
                echo "<span style='float:right;'>";
                echo "<a href='/user/mail/messageList.php?contact=$ank[id]' class='hint--left' data-hint='" . lang('Отправить сообщение') . "'><i class='fa fa-envelope fa-fw'></i></a> ";
                echo "</span>";
            } else {
                if (isset($user)) {
                    echo "<span style='float:right;'>" . lang('Это Вы') . "</span>";
                }
            }
            user($ank['id']);
            echo "<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 " " . sklon_text($ank['ank_age'], array('год', 'года', 'лет')) . ",\n";
            }
            if ($ank['ank_city'] != NULL) {
                echo " $ank[ank_city]\n";
            } else {
                echo " " . lang('город не указан') . "\n";
            }
            if ($ank['country'] != NULL) {
                echo country($ank['id']);
            }
            echo "</td></tr></table>";
            echo "<div class='hr'></div>";
        }

        if ($k_page > 1) {
            str("/?users&amp;act=man&amp;sort=$sort&amp;$por&amp;", $k_page, $page);
        }

        break;
    case 'woman':
        #Навигация
        echo "<div class='list-group-item-null list-group-item-grey'><small>";
        echo "<a href='/' class='hint--right' data-hint='" . lang('На главную') . "'><i class='fa fa-home fa-lg'></i></a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo "<a href='/modules/users/'>" . lang('Пользователи') . "</a> <i class='fa fa-angle-right fa-fw'></i> ";
        echo lang('Девушки');
        echo "</small></div><br />";

        echo "<div class='list-group-item-null list-group-item-grey'>";
        echo "<ul class='nav nav-tabs' style='margin-bottom: -11px;'>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users'>" . lang('Все') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=online'>" . lang('Онлайн') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=guest'>" . lang('Гости') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link' href='/?users&amp;act=todey'>" . lang('Сегодня') . "</a>
                </li>
                <li class='nav-item'>
                    <a class='nav-link active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `sex` = '0'"), 0);
        $k_page = k_page($k_post, $set['p_str']);
        $page = page($k_page);
        $start = $set['p_str'] * $page - $set['p_str'];

        echo "<div class='list-group-item-null'>";
        echo "<ul class='nav nav-pills'>";
        echo "<li class='nav-item'><a class='nav-link' href='/?users&amp;act=man'>" . lang('Парни') . "</a></li>";
        echo "<li class='nav-item'><a class='nav-link active' href='/?users&amp;act=woman'>" . lang('Девушки') . "</a></li>";
        echo "</ul></div>";

        if ($k_post == 0) {
            $doc->NoResult();
        }

        $q = mysql_query("SELECT * FROM `user` WHERE `sex` = '0' LIMIT $start, $set[p_str]");

        while ($ank = mysql_fetch_array($q)) {
            echo "<table class='list-group-item-null'><tr><td class='icon14'>";
            avatar($ank['id'], '48', 'border-radius: 2px;');
            echo "</td><td class='null'>";
            if (isset($user) && $user['id'] != $ank['id']) {
                echo "<span style='float:right;'>";
                echo "<a href='/user/mail/messageList.php?contact=$ank[id]' class='hint--left' data-hint='" . lang('Отправить сообщение') . "'><i class='fa fa-envelope fa-fw'></i></a> ";
                echo "</span>";
            } else {
                if (isset($user)) {
                    echo "<span style='float:right;'>" . lang('Это Вы') . "</span>";
                }
            }
            user($ank['id']);
            echo "<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 " " . sklon_text($ank['ank_age'], array('год', 'года', 'лет')) . ",\n";
            }
            if ($ank['ank_city'] != NULL) {
                echo " $ank[ank_city]\n";
            } else {
                echo " " . lang('город не указан') . "\n";
            }
            if ($ank['country'] != NULL) {
                echo country($ank['id']);
            }
            echo "</td></tr></table>";
            echo "<div class='hr'></div>";
        }

        if ($k_page > 1) {
            str("/?users&amp;act=man&amp;sort=$sort&amp;$por&amp;", $k_page, $page);
        }

        break;
}

require_once H . 'sys/inc/tfoot.php';

