<?
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';
$ank['id'] = $user['id'];
if (isset($_GET['id'])) $ank['id'] = intval($_GET['id']);


$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '".$ank['id']."' LIMIT 1"));

if ( empty($ank) ) exit('o_O');
$set['title'] = 'Подарки '.$ank['nick'].'';
include_once 'sys/inc/thead.php';
title();
aut();


if ($ank['ank_enter'] == '2' && !isset($user))
{
echo' <div class="gend"> - Пользователь запретил просмотр своих подарков<br/> - Просмотр только для друзей</div>';

include_once 'sys/inc/tfoot.php';
exit();
}

if ($ank['ank_enter'] == '2' && $ank['id'] != $user['id'] && mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' && `frend` = '$user[id]'"),0) == '0')
{
echo' <div class="gend"> - Пользователь запретил просмотр своих подарков<br/> - Просмотр только для друзей</div>';

include_once 'sys/inc/tfoot.php';
exit();
}


$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `gifts` WHERE `id_user` = '$ank[id]' LIMIT 1"), 0);
if ($k_post==0)
{
echo 'У обитателя '.$ank['nick'].' нет подарков';
}




$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];

$q = mysql_query("SELECT * FROM `gifts` WHERE `id_user` = '".$ank['id']."' ORDER BY `time` DESC LIMIT ".$start.", ".$set['p_str'].";");
while ($f = mysql_fetch_array($q))
{
$a = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$f[ot_id]' LIMIT 1"));
if($num==1){
echo "<div class='gend'>";
$num=0;
}else{
echo "<div class='guser_aut'>";
$num=1;}
echo"<img src='/gifts/".$f['id_gifts'].".png' alt='' class='icon'/><br>";
echo "".smiles(htmlspecialchars($f['text']))." \n";
echo "<br>От: <a href='info.php?id=$a[id]'><span style=\"color:$a[ncolor]\">$a[nick]</span></a>\n";
echo "(".vremja($f['time']).") \n";
echo "</div>";
if($f['id_user'] == $user['id'])
{
if (isset($_GET['p']) && $_GET['p']==$f['id_user'] && $_GET['ot']==$f['ot_id'] && $_GET['time']==$f['time'] && $_GET['id_gifts']==$f['id_gifts'])
{
mysql_query("DELETE FROM `gifts` WHERE `id_user` = '".intval($_GET['p'])."' && `ot_id` = '".intval($_GET['ot'])."' && `time` = '".intval($_GET['time'])."' && `id_gifts` = '".intval($_GET['id_gifts'])."' LIMIT 1");
echo'Подарок удален';
}
else echo"<a href='?id=".intval($_GET['id'])."&amp;p=$f[id_user]&amp;ot=$f[ot_id]&amp;time=$f[time]&amp;id_gifts=$f[id_gifts]'>Удалить</a>\n";
echo"<br />";
}

 
}

$asd = $user['id'] == $ank['id'] ? '?' : '?id='.$ank['id'].'&';
if ($k_page>1)str($asd,$k_page,$page); // Вывод страниц
include_once 'sys/inc/tfoot.php';
?>
