<?php

/* DCMS Special
 * Дата последнего редактирования 04.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=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = $db->super_query("SELECT COUNT(*) as count FROM user");
        $k_post = $k_post['count'];
        $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 = $db->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 = $db->get_row($q)) {
            $ank = get_user($ank['id']);

            echo "<table class='list-group-item-null-mini list-group-item-grey dop'><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 class='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 class='right 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>";
        }


#Вывод страниц
        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=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `date_last` > '" . (TIME - $set['user_online']) . "'");
        $k_post = $k_post['count'];
        $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 = $db->query("SELECT `id` FROM `user` WHERE `date_last` > '" . (TIME - $set['user_online']) . "' ORDER BY $sql_sort $por LIMIT $start, $set[p_str]");

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

        while ($ank = $db->get_row($q)) {
            $ank = get_user($ank['id']);
            echo "<table class='list-group-item-null-mini list-group-item-grey dop'><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 class='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 class='right 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>";
        }

        #Вывод страниц
        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=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

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

        if ($k_post == 0) {
            echo "<br />";
            $doc->NoResult();
        }
        while ($guest = $db->get_row($q)) {
            echo "<div class='list-group-item-null-mini list-group-item-grey dop'>";
            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>";
        }
        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 "<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 active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `date_last` > '" . TIME_TODAY . "'");
        $k_post = $k_post['count'];
        $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 = $db->query("SELECT `id` FROM `user` WHERE `date_last` > '" . TIME_TODAY . "' ORDER BY $sql_sort $por LIMIT $start, $set[p_str]");
        while ($ank = $db->get_row($q)) {
            $ank = get_user($ank['id']);

            echo "<table class='list-group-item-null-mini list-group-item-grey dop'><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 "<small class='grey'>" . date::timek($ank['date_last']) . "</small>";
            echo "</td></tr></table>";
        }


#Вывод страниц
        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 active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $u = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `date_reg` > '" . (TIME - $set['user_reg_time']) . "'");
        $users = "<span class='tag tag-info right'>$u[count]</span>";
        $u = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `date_last` > '" . TIME_TODAY . "'");
        $todey = "<span class='tag tag-info right'>$u[count]</span>";
        $u = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `sex` = '1'");
        $man = "<span class='tag tag-info right'>$u[count]</span>";
        $u = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `sex` = '0'");
        $woman = "<span class='tag tag-info right'>$u[count]</span>";
        $u = $db->super_query("SELECT COUNT(*) as count FROM `ban` WHERE `time` > '$time'");
        $ban = "<span class='tag tag-info right'>$u[count]</span>";
        $u = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `group_access` > '1'");
        $admin = "<span class='tag tag-info right'>$u[count]</span>";
        $currD = date("d", time());
        $currm = date("m", time());
        $u = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `ank_d_r` = '$currD' and `ank_m_r` = '$currm'");
        $dr = "<span class='tag tag-info right'>$u[count]</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 list-group-item-grey' href='/?users'><i class='fa fa-user-plus fa-fw'></i> " . lang('Новые пользователи') . " $users</a>\n";
        echo "<a class='list-group-item-null list-group-item-grey' href='/?users&amp;act=todey'><i class='fa fa-calendar-check-o fa-fw'></i> " . lang('Сегодня заходили') . " $todey</a>\n";
        echo "<a class='list-group-item-null list-group-item-grey' href='/?users&amp;act=man'><i class='fa fa-mars fa-fw'></i> " . lang('Парни') . " $man</a>\n";
        echo "<a class='list-group-item-null list-group-item-grey' href='/?users&amp;act=woman'><i class='fa fa-venus fa-fw'></i> " . lang('Девушки') . " $woman</a>\n";
        echo "<a class='list-group-item-null list-group-item-grey' 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 list-group-item-grey' href='/?users&amp;act=ban'><i class='fa fa-gavel fa-fw'></i> " . lang('Нарушители') . " $ban</a>\n";
        echo "<a class='list-group-item-null list-group-item-grey' 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: -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' href='/?users&amp;act=guest'>" . 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 = $db->super_query("SELECT COUNT(*) as count FROM `ban` WHERE `time` > '$time'");
        $k_post = $k_post['count'];
        $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) {
            echo "<br />";
            $doc->NoResult();
        }

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

        while ($ban = $db->get_array($q)) {
            $ank = get_user($ban['id_user']);
            echo "<table class='list-group-item-null-mini list-group-item-grey dop'><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>";
        }

        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 active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `group_access` > '1'");
        $k_post = $k_post['count'];
        $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 = $db->query("SELECT `id` FROM `user` WHERE `group_access` > '1' ORDER BY `group_access` DESC LIMIT $start, $set[p_str]");

        while ($adm = $db->get_array($q)) {
            $ank = get_user($adm['id']);
            echo "<table class='list-group-item-null-mini list-group-item-grey dop'><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>";
        }

        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 active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

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

        $k_post = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `ank_d_r` = '$currD' and `ank_m_r` = '$currm'");
        $k_post = $k_post['count'];
        $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 = $db->query("SELECT * FROM `user` WHERE `ank_d_r` = '$currD' and `ank_m_r` = '$currm' LIMIT $start, $set[p_str]");

        while ($ank = $db->get_array($q)) {
            echo "<table class='list-group-item-null-mini list-group-item-grey dop'><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>";
        }

        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 active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `ank_d_r` = '" . (date('d') + 1) . "' and `ank_m_r` = '" . date('m') . "'");
        $k_post = $k_post['count'];
        $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 = $db->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 = $db->get_array($q)) {
            echo "<table class='list-group-item-null-mini list-group-item-grey dop'><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>";
        }

        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 active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `ank_d_r` = '" . (date('d') + 2) . "' and `ank_m_r` = '" . date('m') . "'");
        $k_post = $k_post['count'];
        $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 = $db->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 = $db->get_array($q)) {
            echo "<table class='list-group-item-null-mini list-group-item-grey dop'><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>";
        }

        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 active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `sex` = '1'");
        $k_post = $k_post['count'];
        $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 = $db->query("SELECT * FROM `user` WHERE `sex` = '1' LIMIT $start, $set[p_str]");

        while ($ank = $db->get_array($q)) {
            echo "<table class='list-group-item-null-mini list-group-item-grey dop'><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>";
        }

        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 active' href='/?users&amp;act=other'>" . lang('Прочее') . "</a>
                </li>
            </ul>";
        echo "</div>";

        $k_post = $db->super_query("SELECT COUNT(*) as count FROM `user` WHERE `sex` = '0'");
        $k_post = $k_post['count'];
        $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 = $db->query("SELECT * FROM `user` WHERE `sex` = '0' LIMIT $start, $set[p_str]");

        while ($ank = $db->get_array($q)) {
            echo "<table class='list-group-item-null-mini list-group-item-grey dop'><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>";
        }

        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';

