<?php

require '../system/start.php';
require '../system/functions.php';
reg();
$str['mesto'] = 'Кто-Где?';
$chat = mysql_result(mysql_query("select count(*) from `users` where `where` = 'Чат' and time > ".(time()-300).""),0);
$str['block'] = $set['site'].' / Чат / Кто-Где?';
include '../style/'.$style.'/head.php';
$query = mysql_query("SELECT * FROM `chat_users` ORDER by `time` DESC LIMIT ".$page.", ".$set['str']."");
$total = mysql_result(mysql_query("select count(*) from `users` where `where` = 'Чат' and time > ".(time()-300).""),0);
if($total == 0)
{
	echo '<div class="forum1">Людей в чате нет!</div>';
}
else

{
	while($row = mysql_fetch_assoc($query))
	{     
		$room = mysql_fetch_assoc(mysql_query("SELECT `title` FROM `chat_rooms` WHERE `id` = ".$row['rid'].""));
		$login = mysql_fetch_assoc(mysql_query("SELECT `login` FROM `users` WHERE `id` = ".$row['id_user'].""));

		$i++;
		if($i%2)
		{
			echo '<div class="forum1">';
		}
		else
		{
			echo '<div class="forum2">';
		}
                            if ($login['gender'] == 1)
			$pol = '<img class="ico" src="../style/'.$style.'/ico/m.png" alt="" />';
	              if ($login['gender'] == 2)
			$pol = '<img class="ico" src="../style/'.$style.'/ico/w.png" alt="" />';
		echo $pol.'<a href="../p/'.$login['login'].'">'.$login['login'].'</a> в <a href="room.php?id='.$row['rid'].'">'.$room['title'].'</a></div>';
	}
	if($total > $set['str'])
	{
		pages($page, $total, 'who.php?', $set['str']);
	}
echo'<div class="where">Всего в чате сидят ('.$chat.' человек) </div>';
}

include '../style/'.$style.'/foot.php';
?>