<?php
require_once ('system/func.php');
$title = 'Подарки';
require_once ('system/header.php');
auth(); // Закроем от гостей

switch($_GET[mod]){
default:

//echo'<div class="block">';
if($_GET['go']=='delete_ok'){
if(isset($_GET['id'])){
$del = num($_GET['id']);
}
if($del){
$db->query("DELETE FROM `podarok_ok` WHERE `id`='".$del."' and `usr`='".$user[id]."' ");
header ("Location: /my_gift"); exit;
}else{
header ("Location: /my_gift"); exit;
}
}
if($_GET['go']=='delete'){
if(isset($_GET['id'])){
$del = num($_GET['id']);
}
if($del){
echo"Вы собираетесь удалить подарок!</div>";
echo "<table style='width:100%;'><tr>";
echo"<td style='width: 33%;' class='center'>
<a class= 'btn-blue' href='?go=delete_ok&id=".$del."'>".ico('icons','ok.png')." Удалить</a></td>";
echo"<td style='width: 33%;' class='center'>
<a class= 'btn-blue' href='?'>".ico('icons','no.png')." Отмена</a></td>";
echo "</tr></table></div>";
require_once ('system/footer.php');
exit;
}else{
header ("Location: /my_gift"); exit;
}
}
$result = mysql_query("SELECT * FROM `podarok_ok` WHERE `usr` = '".$user['id']."'");
if ($result == 0)
{
echo "<img src='images/icons/city.png' alt='*'/> У тебя нет подарков.</div></div>";
require_once ('system/footer.php');
exit;
}
else {
$set['p_str']=5;
$k_post = mysql_query("SELECT * FROM `podarok_ok` WHERE `usr` = '".$user['id']."' ");
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];

$qi = mysql_query("SELECT * FROM `podarok_ok` WHERE `usr` = '".$user['id']."' ORDER by `id` DESC LIMIT $start,$set[p_str]");

//while($msg=$qi->fetch_assoc())
while($msg = mysql_fetch_assoc($qi)) 
{





$from = strip_tags($msg['nick']);
$froms = strip_tags($msg['times']);
$froms2 = strip_tags($msg['podarok']);

$froms3 = $msg['coment'];
$froms3 =text_msg($froms3);
$req = mysql_query("SELECT * FROM `users` WHERE `id` = '".$from."'");
////////////////////////////
$avto=$req->num_rows;
if($avto=="0"){
echo'<img src="images/icons/city.png" alt="*"/> Нет такого персонажа!</div></div>';
require_once ('system/footer.php');
exit;
}
echo '<div class="wrapper">';
//$usdata = $req->fetch_assoc();
$usdata = mysql_fetch_assoc($req);

$req = mysql_query("SELECT * FROM `users` WHERE `id` = '".$from."'");
$pic = mysql_fetch_assoc($req);

echo "От: ";
$nik='<span style="text-shadow: 1px 0 10px  #'.$pic[gradient2].'">'.gradient(''.$pic[login].'',''.$pic[gradient1].'', ''.$pic[gradient2].'').'</span>';
echo icons_user($pic[id])." <a href='/profile/$pic[id]'>".$nik."</a> ";

echo ico('icons','timereg.png').' <font color=00CC00><small>('.$msg[times].')</small></font>';
echo ' <a href="?go=delete&id='.$msg['id'].'">'.ico('icons','no.png').'</a> <br>';
echo'<img src="http://'.$_SERVER[SERVER_NAME].''.$msg[podarok].'" style = "width:40px; height:40px;float:left;margin-left:0px;margin-bottom:2px;margin-right:6px;" alt="ID:lake_8"/></br>';
echo ico('icons','mail.png')." $froms3";
echo'<div style="clear:both"></div></div>';
echo '</div>';

}}


echo '<div class="block_c">';

if($k_post>10){
str('?',$k_page,$page); // Вывод страниц
echo ' </div>';

}
//echo ' </div>';
}
//echo ' </div>';
require_once ('system/footer.php');
?>