<?
define('_IN_JOHNCMS', 1);
/*
 by Str@nnik
 http://johncms.com/users/profile.php?user=21326
 ICQ: 609745227
*/
$headmod ="mchat";
$textl = 'Мини-чат';
$rootpath = '../';
require_once ("../incfiles/core.php");
require_once ("../incfiles/head.php");

// Выгоняем гостей
if (!$user_id) {
	echo '<div class="rmenu">Вход гостям в мини-чат запрещен! Авторизуйтесь или зарегистрируйте учетную запись!</div>';
	require_once ("../incfiles/end.php");
	exit;
}

echo '<div class="phdr"><a href="index.php">Мини-чат</a>&nbsp;|&nbsp;Кто в мини-чате</div>';
$total = mysql_result(mysql_query('select count(*) from `users` where `place` = "mchat" and `lastdate`+300 > '.time().''), 0);
if ($total) {
	$req = mysql_query('select * from `users` where `place` = "mchat" and `lastdate`+300 > '.time().'');
	$i = 0;
	while ($res = mysql_fetch_assoc($req)) {
	    echo $i % 2 ? '<div class="list1">' : '<div class="list2">';
		if (file_exists((ROOTPATH . 'files/users/avatar/' . $res['id'] . '.png')))
            echo '<img src="' . $home . '/files/users/avatar/' . $res['id'] . '.png" width="32" height="32" alt="" />&#160;';
        else
            echo '<img src="' . $home . '/images/empty.png" width="32" height="32" alt="" />&#160;';
		if ($res['sex'])
            echo functions::image(($res['sex'] == 'm' ? 'm' : 'w') . ($res['datereg'] > time() - 86400 ? '_new' : '') . '.png', array('class' => 'icon-inline'));
        else
             echo functions::image('del.png');
		echo !$user_id || $user_id == $res['id'] ? '<b>' . $res['name'] . '</b>&#160;' : '<a href="' . $home . '/users/profile.php?user=' . $res['id'] . '"><b>' . $res['name'] . '</b></a>&#160;';
                $rank = array(
                0 => '',
                1 => '(GMod)',
                2 => '(CMod)',
                3 => '(FMod)',
                4 => '(DMod)',
                5 => '(LMod)',
                6 => '(Smd)',
                7 => '(Adm)',
                9 => '(SV!)'
                );
                $Rights = isset($res['rights']) ? $res['rights'] : 0;
				echo $rank[$Rights];
				echo (time() > $res['lastdate'] + 300 ? '<span class="red"> [Off]</span>' : '<span class="green"> [ON]</span>');
			echo '</div>';
			$i++;
		}
} else {
	echo '<div class="menu">Никого</div>';
}
echo '<div class="phdr">Всего: '.$total.'</div>' .
        '<div class="menu"><a href="index.php">Назад</a></div>';

require_once ("../incfiles/end.php");