<?php

require_once 'core/system.php';


date_default_timezone_set('Europe/Moscow'); 






head('Подарки');



reg(); 

$gift = $dbc->query("SELECT * FROM `present_us` WHERE `user_id` =".$user['id']." ORDER BY `time` DESC LIMIT ".$page.",".$set['str'].""); 





$tota = $dbc->query("SELECT `id` FROM `present_us` WHERE  `user_id`=".$user['id'].""); $total = $tota->num_rows; 






if($total==0){
echo '<center>Нет подарков</center>';

foot();
exit;
}
if(isset($_GET['del']) and !empty($_GET['id'])){
    $ers = int($_GET['id']); 


$rowi = $dbc->query("SELECT * FROM `present_us` WHERE `id`='".$ers."' LIMIT 1")->fetch_assoc(); 


if(!$rowi){ header('location:?');exit;} 



if($rowi['user_id']!=$user['id']){ header('location:?');exit;} 



$dbc->query("delete from `present_us` where `id`='".$rowi['id']."'");  $_SESSION['message']="Подарок Удален";

header('location: ? ');exit;











}
while($gifte = $gift->fetch_assoc()){ 


$timen = $gifte['time'];




$de = $dbc->query("SELECT * FROM `users` WHERE `id` = '".$gifte['user_id']."'")->fetch_assoc(); 








?><center><div class="b-panel-new dblue-panel bordered mt2">



<div class="panel-inner-2"><div class="font-small text-italic c-verygray">


<img src="img/class/<?=$de['storona']?>/<?=$de['pers']?>/pers.png" width="14" height="14" alt="*"><b><a href="pers.php?ank=<?=$de['id']?>"><?=$de['login']?></b></a> </br><?=clock($timen)?></br><img src="img/gift/<?=$gifte['img']?>.jpg"></br><span class="info"><?=$gifte['text']?></span>














<?


if($user['id']==$gifte['user_id']){ 







 ?></br><a href="user_gift.php?id=<?=$gifte['id']?>&amp;del" onclick="return confirm ('Уверены? Подарок будет удален')">Удалить</a></p></br><?







} 


?></div></div></div></center><?

















}
if($total > $set['str'])    {
echo'<div class="mini-line"></div><div class="block_zero">';
pages($page, $total, 'all_us?' ,$set['str']);






    }
foot();
