Файл: mails.php
Строк: 85
<?php
/* Мод "Почта"
* Версия v0.0.1
* Дата последнего редактирования 21.01.2015
* Двиг DCMS Special
* Модифицировал densnet
* Файл mails.php
* Описание: выводит новые сообщения
*/
require_once 'sys/inc/start.php';
require_once 'sys/inc/compress.php';
require_once 'sys/inc/sess.php';
require_once 'sys/inc/settings.php';
require_once 'sys/inc/db_connect.php';
require_once 'sys/inc/ipua.php';
require_once 'sys/inc/fnc.php';
require_once 'sys/inc/user.php';
user::only_reg();
$set['title'] = 'Новые сообщения';
require_once 'sys/inc/thead.php';
title();
aut();
$k_post = mysql_result(mysql_query("SELECT COUNT(DISTINCT `mail`.`id_user`) FROM `mail` LEFT JOIN `users_konts` ON `mail`.`id_user` = `users_konts`.`id_kont` AND `users_konts`.`id_user` = '$user[id]' WHERE `mail`.`id_kont` = '$user[id]' AND (`users_konts`.`type` IS NULL OR `users_konts`.`type` = 'common' OR `users_konts`.`type` = 'favorite') AND `mail`.`read` = '0'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if ($k_post == 0) {
echo "<div class = 'errs'>";
echo img16('error.png') . " Нет результатов";
echo "</div>";
} else {
$q = mysql_query("SELECT MAX(`mail`.`time`) AS `last_time`, COUNT(`mail`.`id`) AS `count`, `mail`.`id_user`, `users_konts`.`name` FROM `mail` LEFT JOIN `users_konts` ON `mail`.`id_user` = `users_konts`.`id_kont` AND `users_konts`.`id_user` = '$user[id]' WHERE `mail`.`id_kont` = '$user[id]' AND (`users_konts`.`type` IS NULL OR `users_konts`.`type` = 'common' OR `users_konts`.`type` = 'favorite') AND `mail`.`read` = '0' GROUP BY `mail`.`id_user` ORDER BY `count` DESC LIMIT $start, $set[p_str]");
while ($kont = mysql_fetch_assoc($q)) {
$ank = user::get_user($kont['id_user']);
echo "<a href = '/mail.php?id=$ank[id]'><table class = 'razd'><tr><td class = 'icon14'>";
avatar($ank['id'], '48');
echo "</td><td class = 'null'>";
echo "<div style = 'float:right;'>" . date::time($kont['last_time']) . "</div>";
if ($ank) {
echo "<b>" . ($kont['name'] ? $kont['name'] : $ank['nick']) . "</b> (+$kont[count])";
} else {
echo "<b>Пользователь удален</b> (+$kont[count])";
}
$qs = mysql_query("SELECT * FROM `mail` WHERE `id_user` = '$user[id]' AND `id_kont` = '$ank[id]' OR `id_user` = '$ank[id]' AND `id_kont` = '$user[id]' ORDER BY id DESC LIMIT 1");
while ($post = mysql_fetch_array($qs)) {
$ank2 = user::get_user($post['id_user']);
if ($post['read'] == 0) {
echo "<table class = 'mail_hidden'><tr><td class = 'null'>";
} else {
echo "<table class = 'mail'><tr><td class = 'null'>";
}
echo text::toOutput($post['msg']) . "n";
echo "</td></tr></table>";
}
echo "</td></tr></table></a>";
}
}
if ($k_page > 1) {
str('?', $k_page, $page);
}
echo "<div class = 'razd'>";
echo "<a class = 'add' href = '/user/konts.php?$passgen'>" . img16('kont.png') . " Контакты</a>";
if (isset($_SESSION['refer']) && $_SESSION['refer'] != NULL && otkuda($_SESSION['refer'])) {
echo "<br /><br /><a class = 'add' href = '$_SESSION[refer]'>" . img16('left.png') . " " . otkuda($_SESSION['refer']) . "</a>";
}
echo "</div>n";
require_once 'sys/inc/tfoot.php';