<?
define('_IN_JOHNCMS', 1);
$headmod ="mchat";
$textl = 'Suhbatxona';
$rootpath = '../';
require_once ("../incfiles/core.php");
require_once ("../incfiles/head.php");

echo '<div class="menu"><img src="/ico/home.png"> &raquo; Chat onlinelari</div>';
echo '<div class="phdr"> Chat Online</div>';

if (!$user_id) {
echo '<div class="phdr">Xatolik</div>';
	echo '<div class="rmenu">Faqat sayt foydalanuvchilari uchun ruhsat etilgan !!!</div>';
	require_once ("../incfiles/end.php");
	exit;
}

$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="menu">' : '<div class="menu">';

    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 ? '<font color="red"> [off]</font>' : '<font color="green"> [on]</font>');

			echo '</div>';
			$i++;
		}
} else {
echo '<div class="rmenu"><p><b>Chatda Hech Kim Yo\'q !!!</b></p></div>';
}

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