<?php
require_once('../classes/body.class.php');
require_once('../classes/db.class.php');
require_once('../classes/system.class.php');
$title= new Body;
$title->SetTitle('Панель управления - Просмотр почты');
$title->GetHeader();
if ($b['level'] < 5) {
header('location: /');
die();
}
echo '<div class="tile"><div class="t-header th-alt bg-teal"><div class="th-title"><i class="zmdi zmdi-widgets"></i><a href="/"style="text-decoration:none; color:white;"> Главная</a> :: <a href="/administration/"style="text-decoration:none; color:white;"> Дата-центр</a> :: Просмотр почты</div></div></div>';
$all = DB::$dbs->querySingle("SELECT COUNT(id) FROM `letters`");
$num = 10;
$k_page = k_page($all, $num);
$page = page($k_page);
$start = $num*$page-$num;
$read = DB::$dbs->query("SELECT * FROM letters ORDER BY id DESC LIMIT $start,$num");
while($ot = $read->fetch()) {
$vfile = $_SERVER['DOCUMENT_ROOT'].$ot['file'];
$files = strtolower(strrchr($ot['file'], '.'));
$your = DB::$dbs->queryFetch("SELECT `id`, `read` FROM `letters` WHERE `idwho` = ? AND `who` = ? AND `mod` = ? AND `id` = ?", [$ot['who'],$b['id'],'i',($ot['id']-1)]);
$nicks = user_inf($ot['who'], 'name').' '.user_inf($ot['who'], 'family').' ('.NickN($ot['who']).')';
$nick = user_inf($ot['idwho'], 'name').' '.user_inf($ot['idwho'], 'family').' ('.NickN($ot['idwho']).')';
if ($ot['read'] == 0) $NoRead = '[<font color="red"><b>Непрочитанное</b></font>]';
else $NoRead = '';
echo '<div class="list-group-item media">';
echo'<a href="/users/'.user_inf($ot['who'], 'id').'">'. $nicks . '</a> -> <a href="/users/'.user_inf($ot['idwho'], 'id').'">'.$nick.'</a> (' . vr($ot['data']) . ') ' . $NoRead . '<br/>' . text($ot['text']) . '
<br/>' .($ot['file'] != '' ? '<b>Прикрепленный файл</b><br/><a href="'.$ot['file'].'">'.mb_substr($ot['file'],12,27, 'UTF-8').' ('.get_size(filesize($vfile)).')</a><br/>' : '') . '</div>';
}
if ($k_page>1) {
str('?', $k_page,$page);
}
$title->GetMenu();
$title->GetFooter();
?>