<?php
$thisLink = "/{$thisPage}";
if (isset($user['id']) && isset($_GET['admin'])) {
require('inc/admin.php');
}
$id = (int)abs($_GET['id']);
$ank = profile :: getUser($id);
if (isset($user['id']) && $user['id'] != $ank['id'] && isset($_GET['cat'])) {
require('inc/cat.php');
} else if (isset($user['id']) && $user['id'] != $ank['id'] && isset($_GET['gift'])) {
require('inc/gift.php');
} else if (isset($user['id']) && $user['id'] == $ank['id'] && isset($_GET['dell_my_gift'])) {
require('inc/dell_my_gift.php');
}
$title = $l = "".language::text('gifts', $language,'gifts')."";
$lBack = profile :: getLink($ank);
require (CORE."head.php");
echo "<div class=\"app-block\">";
if (isset($user['id']) && $user['id'] == $ank['id'] && $user['count_new_gifts'] > 0)
{
DB :: $pdo -> query("UPDATE `user_gifts` SET `read` = '1' WHERE `id_ank` = '".$ank['id']."' AND `read` = '0'");
DB :: $pdo -> query("UPDATE `users` SET `count_new_gifts` = '0' WHERE `id` = ?;", [$user['id']]);
}
if (isset($user['id']) && $user['id'] != $ank['id'])
{
echo "<a href=\"/gifts?id=".$ank['id']."&cat=1\" class=\"app-action\">".system :: icon('gift')." ".language::text('gift', $language,'gifts')."</a>";
}
$total = $ank['count_gifts'];
if ($total == 0)
{
?>
<div class="list _gray _font-s _center">Подарки не найдены!</div>
<?php
} else {
if ($total > 10)
{
$p = (($_GET['p']) ? intval($_GET['p']) : 1);
$pagination = new pagination(10, $total, $p);
$total_lin = $pagination -> limit;
} else {
$total_lin = '';
}
$query_gifts = DB :: $pdo -> query("SELECT * FROM `user_gifts` WHERE `id_ank` = '".$id."' ORDER BY `id` DESC ".$total_lin."");
while($r = $query_gifts -> fetch())
{
?>
<div class="list _l-padd-n">
<div class="_l-padd">
<div class="_oh">
<div class="list-flex">
<div class="post-l">
<?php
$ank_gift = profile :: getUser($r['id_user']);
echo profile :: userAvatar(($r['privat'] == 0 || ($r['privat'] == 1 && isset($user['id']) && $user['id'] == $ank['id']) ? $ank_gift : ['id'=>0] ),3);
?>
</div>
<div class="post-c">
<div class="_name">
<?=($r['privat'] == 0 || ($r['privat'] == 1 && isset($user['id']) && $user['id'] == $ank['id']) ? profile :: goPage($ank_gift): "Анонимный подарок")?>
</div>
<div class="_time">
<?echo system :: times($r['time']);?>
</div>
<?=($r['privat'] == 1 && isset($user['id']) && $user['id'] == $ank['id'] ? " <span class=\"_gray _font-m\">".language::text('meon', $language,'gifts')."</span>" : '' ) ?>
</div>
</div>
</div>
<div class="_center _gray">
<div>
<img src="<?=(FILES_SERVER."/gifts/{$r['id_gift']}.jpg")?>">
</div>
<div class="_font-s">
<?echo Emoji :: Text($r['komment']);?>
</div>
</div>
</div>
<?
if (isset($user['id']) && $user['id'] == $ank['id'])
{
?>
<div class="tb-line"></div>
<div class="tb-bloc"><div class="tb-cont tb-2">
<div class="tb-item"><a href="<?=$thisLink?>?id=<?=$ank_gift['id']?>&cat=1" class="tb-c"><?=language::text('replay', $language,'gifts');?></a></div>
<div class="tb-item"><a href="<?=$thisLink?>?id=<?=$ank['id']?>&dell_my_gift=<?=$r['id']?>" class="tb-c"><?=language::text('delete', $language,'gifts')?></a></div>
</div></div>
<?
}
?>
</div>
<?php
}
if ($total > 10)
{
echo $pagination -> printPages("/gifts?id=".$ank['id']."&");
}
}
echo "</div>";
require (CORE."foot.php");