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

$on24 = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_last` > '" . TIME_TODAY . "'"), 0);
$on1 = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_last` >" . (TIME - 600) . ""), 0);
$on2 = mysql_result(mysql_query("SELECT COUNT(*) FROM `guests` WHERE `date_last` > " . (TIME - 500) . " AND `pereh` > '0'"), 0);
$on3 = $on1 + $on2;

if (isset($user)) {
    #Показываем все
    if ($user['set_online'] == 1) {
        echo "<div class='list-group-item-null list-group-item-grey'>";

        #Виды строки пользователей онлайн
        if ($user['set_online_view'] == 1) {
            echo "<center>";
            echo "<a href='?users&amp;act=online'>" . lang('Онлайн') . " <b>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_last` > " . (TIME - 600) . ""), 0) . "</b></a>";
            echo " | ";
            echo "<a href='?users&amp;act=guest'>" . lang('Гостей') . " <b>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `guests` WHERE `date_last` > " . (TIME - 500) . " AND `pereh` > '0'"), 0) . "</b></a>";
            echo "</center>";
        }
        if ($user['set_online_view'] == 2) {
            echo "<center>";
            echo "<a href='?users&amp;act=online'>" . lang('Онлайн') . " <b>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_last` > " . (TIME - 600) . ""), 0) . "</b></a> ";
            echo "(<a href='?users&amp;act=guest'>" . lang('Гостей') . " <b>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `guests` WHERE `date_last` > " . (TIME - 500) . " AND `pereh` > '0'"), 0) . "</b></a>)";
            echo "</center>";
        }
        if ($user['set_online_view'] == 3) {
            echo "<center>";
            echo "<a href='?users&amp;act=online'>" . lang('Онлайн') . " <b>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_last` > " . (TIME - 600) . ""), 0) . "</b></a> ";
            echo "(+<a href='?users&amp;act=guest'> <b>" . mysql_result(mysql_query("SELECT COUNT(*) FROM `guests` WHERE `date_last` > " . (TIME - 500) . " AND `pereh` > '0'"), 0) . "</b></a>)";
            echo "</center>";
        }
        if ($user['set_online_view'] == 4) {
            $kol = mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_last` > " . (TIME - 600) . ""), 0);
            $kol1 = mysql_result(mysql_query("SELECT COUNT(*) FROM `guests` WHERE `date_last` > " . (TIME - 500) . " AND `pereh` > '0'"), 0);
            $obkol = $kol + $kol1;

            echo "<center>";
            echo "<a href='?users&amp;act=online'>" . lang('Онлайн') . " <b>$obkol</b></a>";
            echo "</center>";
        }

        $q = mysql_query("SELECT `id` FROM `user` WHERE `date_last` > '" . (TIME - 600) . "' ORDER BY `date_last` DESC LIMIT 8");

        //echo "<br />";

        while ($ank = mysql_fetch_assoc($q)) {
            $ank = get_user($ank['id']);
            echo "<a class='hint--top' data-hint='$ank[nick]' href='/id$ank[id]'>\n";
            avatar($ank['id'], "$user[set_online_size]", 'border-radius: 50%;');
            echo "</a> ";
        }

        echo "</div>";
    }

    #Показываем только аватары
    if ($user['set_online'] == 2) {
        $q = mysql_query("SELECT `id` FROM `user` WHERE `date_last` > '" . (TIME - 600) . "' ORDER BY `date_last` DESC LIMIT 8");

        echo "<div class='list-group-item-null list-group-item-grey'>";
        while ($ank = mysql_fetch_assoc($q)) {
            $ank = get_user($ank['id']);
            echo "<a class='hint--top' data-hint='$ank[nick]' href='/id$ank[id]'>\n";
            avatar($ank['id'], "$user[set_online_size]", 'border-radius: 50%;');
            echo "</a> ";
        }
        ?>
        </div>
        <?php
    }

    #Показываем только данные
    if ($user['set_online'] == 3) {
        ?>
        <div class='list-group-item-null list-group-item-grey'><center>
                <?php
                echo "<a href='?users&amp;act=online'>" . lang('Онлайн') . " " . mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `date_last` > " . (TIME - 600) . ""), 0) . "</a>";
                echo " | ";
                echo "<a href='?users&amp;act=guest'>" . lang('Гостей') . " " . mysql_result(mysql_query("SELECT COUNT(*) FROM `guests` WHERE `date_last` > " . (TIME - 500) . " AND `pereh` > '0'"), 0) . "</a>";
                echo "</center>";
                ?>
        </div>
        <?php
    }
}