<?

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))$ank['id']=$user['id'];
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);
$ank=get_user($ank['id']);
if(!$ank){
header("Location: /index.php?".SID);
exit;
}

# Заголовок
$set['title']=''.user::nick($ank['id'],0).' подарки';
include_once '../../sys/inc/thead.php';
title();
aut();

echo '<table class="block3" cellpadding="0" cellspacing="0">';
echo '<td style="width:110px;">';
# Аватар
echo avatar_profil($ank['id'], true, 640, false);
# Сделать подарок
if (isset($user) && $ank['id']!=$user['id']){
echo '<span style="position: absolute; margin: 60px -20px 0;"><a href="/user/gift/categories.php?id='.$ank[id].'"><img width="20" src="/img/go_gift.png"></a></span>';
}
echo '</td>';
echo '<td>';
if ($ank['verified'] == 1) $verified = ' <img style="margin: -1px 5px;" src="/img/verified.png" title="Подтверждённая страница" alt="Подтверждённая страница"> ';
echo '<b>'.user::nick($ank['id']).'</b> '.$verified.'';
# Редактирование профиля
echo '<a class="profil_edit" href="/user/edit/">Редактировать профиль</a>';
echo '</td>';
echo '</table>';

# Информация о аккаунте
echo '<div class="block3">';
# Имя
if ($ank['ank_name']!=NULL){
echo '<b>'.$ank[ank_name].'</b> ';
}else{
# No
}
# Фамилия
if ($ank['ank_fam']!=NULL){
echo '<b>'.$ank[ank_fam].'</b>';
}else{
# No
}
echo '</br>';
# О себе
if ($ank['ank_o_sebe']!=NULL){
echo ''.output_text($ank['ank_o_sebe']).'';
}else{
# No
}
echo '</div>';

# Панель

# Счетчики
$count_friends = mysql_result(mysql_query("SELECT COUNT(*) FROM `frends` WHERE `user` = '$ank[id]' AND `i` = '1'"), 0);
$count_photo = mysql_result(mysql_query("SELECT COUNT(*) FROM `gallery_foto` WHERE `id_user` = '$ank[id]'"),0);
$count_gifts = mysql_result(mysql_query("SELECT COUNT(id) FROM `gifts_user` WHERE `id_user` = '$ank[id]' AND `status` = '1'"),0);

echo '<table style="text-align:center;" class="block_profil_panel" cellpadding="0" cellspacing="0">';
echo '<td><a href="/modules/photo/'.$ank[id].'/"><span class="profil_panel_count">'.$count_photo.'</span></br>публикаций</a></td>';
echo '<td><a href="/user/friends/?id=' . $ank['id'] . '"><span class="profil_panel_count">'.$count_friends.'</span></br>друзей</a></td>';
echo '<td><a href="/user/gift/index.php?id='.$ank[id].'"><span class="profil_panel_count">'.$count_gifts.'</span></br>подарков</a></td>';
echo '</table>';

echo '<table style="text-align:center;" class="block_profil_panel" cellpadding="0" cellspacing="0">';
echo '<td><a href="/id'.$ank[id].'"><img src="/img/plist.png"></a></td>';
echo '<td><a href="/user/profil/save.php?id='.$ank[id].'"><img src="/img/fav_list.png"></a></td>';
echo '<td><a href="/user/profil/gift.php?id='.$ank[id].'"><img src="/img/glist.png"></a></td>';
echo '</table>';

# Вывод подарков
$k_p = mysql_result(mysql_query("SELECT COUNT(id) FROM `gifts_user` WHERE `id_user` = '$ank[id]' AND `status` = '1'"),0);
if ($k_p > 0){	
$q = mysql_query("SELECT id,id_gift,status FROM `gifts_user` WHERE `id_user` = '$ank[id]' AND `status` = '1' ORDER BY `id` DESC LIMIT 5");
echo '<div class="block"><center>';
while ($post = mysql_fetch_assoc($q)){
$gift = mysql_fetch_assoc(mysql_query("SELECT id FROM `gift_list` WHERE `id` = '$post[id_gift]' LIMIT 1"));
echo '<a href="/user/gift/gift.php?id=' . $post['id'] . '"><img style="width:80px;margin: 10px;" src="/style/gift/' . $gift['id'] . '.png"></a> ';
}
echo '</center></div>';
}else{
echo '<div class="block"><center>Подарков нет</center></div>';
}


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

?>