<?

include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';

if(!isset($user))
{
$set['title']='Подарки';
include_once '../sys/inc/thead.php';
title();
err();

echo'Доступ закрыт не авторизированым пользователям<br/>';
include_once '../sys/inc/tfoot.php';
exit();
}
if (isset($_GET['user']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '".intval($_GET['user'])."'"),0))
{
$set['title']='Подарки';
include_once '../sys/inc/thead.php';
title();
err();
echo "<div class='mytitle'>";
echo"".online($_GET['user'])." <a href='/info.php?id=".intval($_GET['user'])."'>";
echo ''.mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id` = '".intval($_GET['user'])."'"),0).'</a><br/>Полученные подарки';
echo"</div>\n";
	if (isset($user) && isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `present_give` WHERE `id_give` = '$user[id]' AND `id` = '".intval($_GET['del'])."'"),0))
	{
	mysql_query("DELETE FROM `present_give` WHERE `id` = '".intval($_GET['del'])."' LIMIT 1");
	msg('Подарок удален');
	}

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `present_give` WHERE `id_give` = '".intval($_GET['user'])."'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
echo "<table class='post'>\n";
if ($k_post==0)
{
echo "<div class='komm'>\n";
echo "Нет подарков\n";
echo"</div>\n";
}
$q=mysql_query("SELECT * FROM `present_give` WHERE `id_give` = '".intval($_GET['user'])."' ORDER BY `id` DESC LIMIT $start, $set[p_str]");
while ($post = mysql_fetch_array($q))
{


echo "   <tr>\n";

if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$post[id_user]'"),0) && mysql_result(mysql_query("SELECT COUNT(*) FROM `present_list` WHERE `id` = '$post[id_p]'"),0))
{
$qp=mysql_query("SELECT * FROM `present_list` WHERE `id` = '$post[id_p]' LIMIT 1");
$p = mysql_fetch_array($qp);
echo '<tr><td class="icon14">';
echo"<img src='$p[url]' width='70' height='70' /><br />";
echo '</td><td class="anput1">';
echo"<font color='#fb85ec'>$p[name]</font>\n";
if (isset($user) && $user['id'] == $post['id_give']) echo"<a href='?user=".intval($_GET['user'])."&amp;del=$post[id]'><img src='/style/img/del.gif'></img></a>\n";
echo"<br/>\n";
echo"Подарил(a) \n";//<font color='#706e6b'>
echo"<a href='/info.php?id=$post[id_user]'><font color='#706e6b'>".mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id` = '$post[id_user]' LIMIT 1"),0)."</font></a><br/>\n";
echo '<font color="#9a9795">'.vremja($post['time']).'</font><br/>';
if($post['coment'] != NULL)echo"<font color='#f8c281'> $post[coment]</font><br />\n";
else
echo"<font color='#d1becd'>Без пожелания</font><br />\n";
echo '</td></tr>';
echo "</div>\n";
}
}

echo '</table>';
if ($k_page>1)str("?user=".intval($_GET['user'])."&amp;",$k_page,$page); // Вывод страниц





}
else
{
$set['title']='Подарки';
include_once '../sys/inc/thead.php';
title();
err();

echo'Не указан пользователя чьи подарки вы хотите просмотреть.<br/>';
}
include_once '../sys/inc/tfoot.php';
?>