Файл: public_html/modules/mail/index.php
Строк: 51
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$header = "Почта";
include_once ($root.'/core/head.php');
?>
<style>
.pinter {
background-color: #34344C;
padding: 6px;
color: #fff;
word-wrap: break-word;
border-radius: 5px;
border: 1px solid #fff;
margin-bottom: 2px;
max-width: 92%;
margin-left: 2%;
}
.mr10 {
margin-right: 10px;
}
</style>
<?
if(isset($_GET['readed']))
{
$db->query("UPDATE `mail_messages` SET `read` = '1' WHERE `user2` = '".$u['id']."'");
redirect('/mail', 'Сообщения прочитаны!');
}
if(isset($_GET['delread']))
{
$db->query("DELETE FROM `mail_messages` WHERE (`user1` = '".$u['id']."' OR `user2` = '".$u['id']."') AND `read` = '1'");
redirect('/mail', 'Сообщения удалены!');
}
echo '<center><div class="b">Почта</div></center>';
$count = $db -> query("SELECT * FROM `mail_dialogs` WHERE (`user1` = '".$u['id']."' OR `user2` = '".$u['id']."') ORDER BY `time` DESC") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10*$page-10;
$sql = $db -> query("SELECT * FROM `mail_dialogs` WHERE (`user1` = '".$u['id']."' OR `user2` = '".$u['id']."') ORDER BY `time` DESC LIMIT $start, 10");
$messCount = 0;
while($q = $sql->fetch_object())
{
if($q->user1 == $u['id']) $us = $q->user2;
else $us = $q->user1;
$messages = $db->query("SELECT * FROM `mail_messages` WHERE (`user1` = '".$u['id']."' AND `user2` = '".$us."') OR (`user1` = '".$us."' AND `user2` = '".$u['id']."')")->num_rows;
$notReadMessage = $db->query("SELECT * FROM `mail_messages` WHERE `user2` = '".$u['id']."' AND `user1` = '".$us."' AND `read` = '0'")->num_rows;
if($notReadMessage > 0) $notification = '<font color="lime">Новое</font>';
else $notification = '';
$lastMessage = $db->query("SELECT * FROM `mail_messages` WHERE (`user1` = '".$u['id']."' AND `user2` = '".$us."') OR (`user1` = '".$us."' AND `user2` = '".$u['id']."') ORDER BY `time` DESC LIMIT 1")->fetch_object();
if($messages > 0)
{
echo '<div class = "b-mini"><a href="/mail/dialog/'.$us.'"><div class = "pinter">
<img src="/images/users.png" width="35px"> '.name($us).' <small> '.tm($lastMessage->time).'</small>
<br>
'.setTextColor($us, mb_strimwidth($lastMessage->message, 0, 40, '...')).' '.$notification.'
</div></a></div>';
$messCount++;
}
}
if($messCount == 0) echo '<div class="line"></div><div class="b"><center>Нет диалогов!</center></div><div class="line"></div>';
if($count >= 10) echo str('/mail/?', $k_page, $page);
echo'<div class = "b-mini"><div class="menu"><table>
<tr>
<td class="menu-link">
<a href="/mail/friends"><img src="/images/fr.png" width="30" height="35"><br> Друзья</a>
</td>
<td class="menu-link">
<a href="/mail/blacklist"><img src="/images/chs.png" width="30" height="35"><br> Чёрный список</a>
</td>
</tr>
</table></div>';
echo"<a class = 'clicker ' href = '?readed'>Отметить все как прочитанное</a>
<a class = 'clicker ' href = '?delread'>Удалить все прочитанные</a></div></div>";
include_once ($root.'/core/foot.php');