<?
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($_GET['user']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '".intval($_GET['user'])."'"),0))
{
$set['title']='Подарки у '.mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id` = '".intval($_GET['user'])."'"),0).'';
include_once '../sys/inc/thead.php';
title();
err();
aut();
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'];
if ($k_post==0)
{
echo "<div class='err'>Эх, пока никто ничего не подарил... </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))
{

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 '<table class="post">';
echo '<tr>';
echo '<td class="icon128">';
echo"<img src='$p[url]' /><br />";
echo '</td>';
echo '<td class="p_t">';

echo"<div class='foot'>Подарок ($p[name]) от: <a href='/info.php?id=$post[id_user]'>".mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id` = '$post[id_user]' LIMIT 1"),0)."</a></div>\n";
if($post['coment'] != NULL)echo"Записка: $post[coment]<br />\n";
if (isset($user) && $user['id'] == $post['id_give']) echo"[<a href='?user=".intval($_GET['user'])."&amp;del=$post[id]'>Выбросить!</a>]\n";
echo '</td>';
echo '</tr>';
echo '</table>';
}
}
if ($k_page>1)str("?user=".intval($_GET['user'])."&amp;",$k_page,$page); // Вывод страниц

echo"<div class='foot'>\n";
echo"<img src='/style/icons/krugovaya_strelka.png'> <a href='/info.php?id=".intval($_GET['user'])."'>Вернуться назад</a><br />\n";

echo"</div>\n";




}
else
{
$set['title']='Подарки';
include_once '../sys/inc/thead.php';
title();
err();
aut();
echo'<div class="err">Скажи сначала, чьи подарки посмотреть хочешь!</div>';
}
include_once '../sys/inc/tfoot.php';
?>