<?
include 'config.php';
include 'func.php';
head();
aut();
ban();
////////////////////////////////////////
####################Запись онлайна##################
mysql_query("UPDATE `profile` SET `online` = 'presents' WHERE `id` = '".$id_session."'");
####################################################

echo "<div class=\"head\"><b>Подарки</b></div>"; 


switch($_GET['act']){
default:

break;

case 'present_user':
$id = num($_GET['user']);
$user_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `profile` WHERE `id` = '".$id."'"));

if ( empty($user['id']) ) {
    
    echo link2 . 'Данный пользователь не найден' . div;
    navig();
    foot();
    exit();
    
}

echo "<div class='link1'>Подарки пользователя: <b>".$user_info['login']."</b></div>";

$all = mysql_result(mysql_query("SELECT count(*) FROM `presents_list` WHERE `user_2` = '".$id."'"), 0);
if($all>0)
{
if($all){
$onpage = 5;
$allpage = ceil($all/$onpage);
$this_page = (isset($_GET['p'])) ? intval($_GET['p']) : 1 ;
if($this_page < 1 || $this_page > $allpage)$this_page = 1;
$start = $this_page*$onpage - $onpage;

$result = mysql_query("SELECT * FROM presents_list WHERE `user_2` = '".$id."' ORDER BY `id` DESC limit ".$start.",".$onpage."");
while($present = mysql_fetch_assoc($result)){

$present_info = mysql_fetch_assoc(mysql_query("SELECT * FROM `presents` WHERE `id` = '".$present['present']."'"));

if($present['user_1']==0){
    $ot = 'Анонима';
}else{
    $user = mysql_fetch_assoc(mysql_query("SELECT * FROM `profile` WHERE `id` = '".$present['user_1']."'"));
    $ot = ''.$user['login'].'';
}  
echo "<div class='link2'><img src=\"".$present_info['url']."\" alt=\".\"/><br/>";
echo "От: <b>".$ot."</b><br/>";
if($present['coment']){
    echo "Коментарий: ".$present['coment']."<br/>";
}
echo "".strftime("%d.%m.%y",$present['date'])."</div>";
}

echo '<div class="link1"><b>Страницы:</b> ';
navigation($allpage,"presents.php?act=present_user&user=".$id."&p={p}",1,1);
}

}else{ 
echo 'Подарков нет...';}

break;
}

//////////////////////////////////////

navig();
foot();
?>