<?

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';

only_reg();

if (isset($_GET['id']))$ank['id'] = intval($_GET['id']);
//Определяем юзера
else $ank['id'] = $user['id']; 

$ank = get_user($ank['id']);

if(!$ank || $ank['id'] == 0){ header("Location: /index.php?".SID); exit; }
$set['title'] = 'Подарки ' .user::nick($ank['id'],0).'';
include_once '../../sys/inc/thead.php';
title();
aut();

# Панель
echo '<table class="block_panel" cellspacing="0" cellpadding="0">';
echo '<td><a class="panel" href="/id'.$ank['id'].'">' .user::nick($ank['id'],0).'</a><td>';
echo '<td><a class="panel_ok" href="/user/gift/index.php?id='.$ank['id'].'">Подарки</a></td>';
echo '</table>';

//Список подарков
$k_post = mysql_result(mysql_query("SELECT COUNT(id) FROM `gifts_user` WHERE `id_user` = '$ank[id]'" . ($ank['id'] != $user['id'] ? " AND `status` = '1' " : "") . ""),0);
if ($k_post == 0){
echo '<div class="block2">Подарков нет</div>';
}

$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 id,status,coment,id_gift,id_ank,time FROM `gifts_user` WHERE `id_user` = '$ank[id]'" . ($ank['id'] != $user['id'] ? " AND `status` = '1' " : "") . " ORDER BY `time` DESC LIMIT $start, $set[p_str]");

//Вывод подарков
while ($post = mysql_fetch_assoc($q)){
$gift = mysql_fetch_assoc(mysql_query("SELECT id,name FROM `gift_list` WHERE `id` = '$post[id_gift]' LIMIT 1"));
$anketa = get_user($post['id_ank']);

echo '<a class="link" href="gift.php?id=' . $post['id'] . '"><img src="/style/gift/' . $gift['id'] . '.png"></a>';

}

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

include_once '../../sys/inc/tfoot.php';

?>