<?php

require '../system/start.php';
require '../system/functions.php';
reg();
$query = mysql_fetch_assoc(mysql_query("select `id`,`login` from `users` where `id` = '".int($_GET['id'])."'"));
$str['mesto'] = 'Гостевая';
$str['block'] = $set['site'].' / Гостевая';
include '../style/'.$style.'/head.php';
if (!$query)
{
	echo '<div class="on">Пользователь не найден!</div>';
	include '../style/'.$style.'/foot.php';
	exit;
}
if(isset($_POST['msg']) and !empty($_POST['msg']))
{
	$flood = mysql_fetch_assoc(mysql_query("select `time` from `wall` where `id_sender` = ".$user['id']." order by `time` desc limit 1"));
	if($flood['time']<(time()-30))
	{
		mysql_query("insert into `wall`(id_getter,id_sender,text,time) values(".$query['id'].",".$user['id'].",'".protect($_POST['msg'])."',".time().")");
		echo '<div class="where">Сообщение успешно добавлено!</div>';
	}
	else
	{
		echo '<div class="where">Вы не можете добавлять сообщения столь быстро!</div>';
	}
}
echo '<form action="gb.php?id='.$query['id'].'" method="post">
<div class="fss">
Сообщение:<br/>
<table class="whp"><tr><td>
<textarea name="msg" maxlength="100"  id="msg" class="finp whp fss" size="12"></textarea><br />
</td><td class="srcbc pls"><input type="submit" value="Написать"/>
</td></tr></table></form>
</div>';
$zapros = mysql_query("select * from `wall` where `id_getter` = ".$query['id']." order by `id` desc limit ".$page.",".$set['str']."");
$total = mysql_result(mysql_query("select count(*) from `wall` where `id_getter` = ".$query['id'].""),0);
if($total == 0)
{
	echo '<div class="on">Сообщений ещё нет! Будь первым!</div>';
}
else
{
	while($row = mysql_fetch_assoc($zapros))
	{
		$i++;
		if($i%2)
		{
			echo '<div class="forum1">';
		}
		else
		{
			echo '<div class="forum2">';
		}
		$u = mysql_fetch_assoc(mysql_query("select `login` from `users` where `id` = ".$row['id_sender'].""));
    	echo '<img class="ico" src="../style/'.$style.'/ico/personal.gif" alt="" /> <a href="../p/'.$u['login'].'">'.$u['login'].'</a>';
    	statusl($u['login']);
    	echo '<div class="ftext"> '.text($row['text']).'</div></div><hr>';
    	}
}
if($total > $set['str'])
{
	pages($page, $total, 'gb.php?id='.$query['id'].'&amp;', $set['str']);
}
echo '<div class="block2">
 <a href="../pages/info.php?act=bbcode">BBcode</a> <a href="../pages/info.php?act=smiles">Смайлы</a><br/>
</div>';
echo '<div class="acln act"><hr>»<a href="../p/'.$user['login'].'">Моя страница</a> »гостевая';
include '../style/'.$style.'/foot.php'; ?>