Файл: 3/adm_mail.php
Строк: 76
<?php
require_once ('system/func.php');
auth(); // Закроем от не авторизованных
access(3);
# Настройки #
$uid = num($_GET['uid']);
$id = num($_GET['id']);
$uprof = $db->query("SELECT * FROM `users` WHERE `id` = '".$uid."'")->fetch_assoc();
if($id){
$prof = $db->query("SELECT * FROM `users` WHERE `id` = '".$id."'")->fetch_assoc();
# Ошибки #
if(!$prof){
$_SESSION['msg'] = 'Такой игрок не существует';
header('Location: /mail/');
exit();
}
$title = 'Диалог с '.$prof['login'];
require_once ('system/header.php');
echo "<div class='block'>";
$set['p_str'] = 10;
$k_post = $db->query("SELECT * FROM `mail` WHERE (`in` = '$prof[id]' && `out` = '$uprof[id]') or (`in` = '$uprof[id]' && `out` = '$prof[id]')")->num_rows;
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
$q = $db->query("SELECT * FROM `mail` WHERE (`in` = '$prof[id]' && `out` = '$uprof[id]') or (`in` = '$uprof[id]' && `out` = '$prof[id]') ORDER BY `id` DESC LIMIT $start, $set[p_str]");
if($k_post == 0) echo "Сообщений не найдено...";
while($post = $q->fetch_assoc()) {
if($post['online'] == 1)$color = 'green';
else $color = '#A8A8A8';
if(isset($_GET[del])&&isset($_GET[mid]))
{
$db->query("DELETE FROM `mail` WHERE `id` = '".num($_GET['mid'])."'");
$_SESSION['msg'] = 'Сообщение удалено';
header('Location: ?');
exit();
}
$ank = $db->query("SELECT * FROM `users` WHERE `id` = '".$post['in']."' LIMIT 1")->fetch_assoc();
echo icons_user($ank[id])." <a href='/profile/".$ank['id']."'>".$ank['login']."</a>, <font color='$color'>".vremja($post['time'])."</font> <a href='?del&mid=".$post['id']."'><font color='#900'>( x )</font><br>".text_msg($post['text'])."<br>";
}
if($k_post>10){
str('?',$k_page,$page); // Вывод страниц
}
echo "</div>";
echo "<a href='/settGame/mail/".$uid."' class='link'>".ico('icons','arrow.png')." Все контакты ";
if($new_msg >= 1)echo "<font color='green'>(+)</font>";
echo "</a>";
}else{
$title = 'Почта';
require_once ('system/header.php');
$set['p_str'] = 10;
$k_post = $db->query("SELECT * FROM `kont` WHERE `id_user` = '".$uid."'")->num_rows;
$k_page = k_page($k_post,$set['p_str']);
$page = page($k_page);
$start = $set['p_str']*$page-$set['p_str'];
$q = $db->query("SELECT * FROM `kont` WHERE `id_user` = '".$uid."' ORDER BY `time` DESC LIMIT $start, $set[p_str]");
echo "<div class='block2'>";
if($k_post == 0)echo "<h1>Нет контактов...</h1>";
while ($post = $q->fetch_assoc()){
$ank = $db->query("SELECT * FROM `users` WHERE `id` = '".$post['id_kont']."' LIMIT 1")->fetch_assoc();
$mess = $db->query("SELECT * FROM `mail` WHERE `in` = '$uid' && `out` = '$ank[id]' OR `in` = '$ank[id]' AND `out` = '$uid' ORDER BY `id` DESC LIMIT 1");
$msg = $mess->fetch_assoc();
$new_msg = $db->query("SELECT * FROM `mail` WHERE `out` = '".$uid."' && `in` = '".$ank['id']."' AND `online` = '1'")->num_rows;
$online = $db->query("SELECT * FROM `mail` WHERE `out` = '".$ank['id']."' && `in` = '".$uid."' AND `online` = '1'")->num_rows;
echo "<li><a href='/settGame/mail/$uid/$ank[id]'>";
echo icons_user($ank[id])."$ank[login], ".vremja($msg['time'])." ";
if($new_msg > 0)echo "<font color='red'>($new_msg)</font>";
if($online > 0)echo "<font color='gren'>($online)</font>";
echo "<br>".rez_text($msg['text'], 10, 15)."</a></li>";
}
echo "</div>";
if($k_post>10){
echo "<div class='block'>";
str('?',$k_page,$page); // Вывод страниц
echo "</div>";
}
}
require_once ('system/footer.php');
?>