<?php defined('ACCESS') OR die('No direct script access...');
thead('Вложения в беседе', true);
$k_post = DB :: $pdo -> querySingle("SELECT COUNT(*) FROM mail_files_vk WHERE `action` = 'sent' AND `id_mail` <> '0' AND `folder` <> 'reply' AND (`id_kont` = '$user[id]' AND `id_user` = '" .$peer['id'] . "' OR `id_kont` = '" . $peer['id'] . "' AND `id_user` = '$user[id]')");
if($k_post)
{
$q = DB :: $pdo -> query("SELECT * FROM mail_files_vk WHERE `action` = 'sent' AND `id_mail` <> '0' AND `folder` <> 'reply' AND (`id_kont` = '$user[id]' AND `id_user` = '" .$peer['id'] . "' OR `id_kont` = '" . $peer['id'] . "' AND `id_user` = '$user[id]') ORDER BY `time` ");
echo '<div class="app-block"><div class="attached_block" style="text-align: center;"><div class="pi_medias">';
$i = 0;
while ($post = $q -> fetch())
{
if($post['folder'] == 'image')
{
?>
<a class="medias_thumb thumb_item mr_x_wrap" href="/mail/file/<?= $post['folder'] ?>/<?= $post['tmp_name'] ?>/">
<img class="ph_img" src="/mail/file/<?= $post['folder'] ?>/<?= $post['tmp_name'] ?>/"></a>
<?
}
}
echo '</div><a class="button wide_button" href="/mail/?act=show&peer='. $peer['id'] .'">Назад в переписку</a></div>';
}
else
redirect('/mail/?act=show&peer=' . $peer['id'], 'Список вложений пуст.', 'warning');