<?php

require '../system/start.php';
require '../system/functions.php';
reg();
$str['mesto'] = 'Гости';
$str['block'] = $set['site'].' / Гости';
include '../style/'.$style.'/head.php';
$query = mysql_fetch_assoc(mysql_query("select `id`,`login` from `users` where `id` = '".int($_GET['id'])."'"));
if (!$query)
{
 	echo '<div class="on">Пользователь не найден!</div>';
 	include '../style/'.$style.'/foot.php';
 	exit;
}
$zapros = mysql_query("select * from `guests` where `id_user` = '".$query['id']."' order by `time` DESC limit ".$page.",".$set['str']."");
$total = mysql_result(mysql_query("select count(*) from `guests` where `id_user` = '".$query['id']."'"),0);
if($total == 0)
{
 	echo '<div class="forum1">Гостей ещё нет!</div>';
}
echo '<div class="block2">Всего гостей ('.mysql_result(mysql_query("select count(*) from `guests` where `id_user` = '".$query['id']."'"),0).') </div>';
while($row = mysql_fetch_assoc($zapros))
{
 	$i++;
 	if($i%2)
 	{
	   echo '<div class="forum1">';
 	}
 	else
 	{
  		echo '<div class="forum2">';
 	}
	echo '<img class="ico" src="/style/'.$style.'/ico/personal.gif" alt="" /> <a href="../p/'.$row['login_guest'].'">'.$row['login_guest'].'</a>';
	echo statusl($row['login_guest']).'('.clock($row['time']).')';
	echo ($row['status'] == 0) ? '<span style="color:#45CE2D">NEW!</span>' : '';
	echo '</div>';
	if($row['id_user'] == $user['id'] and $row['status'] == 0)
	{
		mysql_query("UPDATE `guests` SET `status` = 1 WHERE `time` = ".$row['time']."");
	}
}
if($total > $set['str'])
{
 pages($page, $total, 'guests.php?id='.$query['id'].'&amp;', $set['str']);
}
include '../style/'.$style.'/foot.php'; ?>