Файл: mails.php
Строк: 90
<?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';
only_reg();
$set['title'] = 'Новые сообщения';
require_once 'sys/inc/thead.php';
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 "<table class = 'blok'><tr><td class = 'null'>";
echo "<img src = '/style/icons/bullet_error.png' /> Нет новых сообщений";
echo "</td></tr></table>";
} 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 = get_user($kont['id_user']);
echo "<a href = '/mail.php?id=$ank[id]'><table class = 'blok'><tr><td class = 'icon14'>";
avatar($ank['id'], '35');
echo "</td><td class = 'null'>";
echo "<div class = 'right'><font color = 'grey'>" . vremja($kont['last_time']) . "</font></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 = 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 output_text($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 "<img src = '/style/icons/13.png' /> <a href='/user/konts.php?$passgen'>Все контакты</a><br />";
if (isset($_SESSION['refer']) && $_SESSION['refer'] != NULL && otkuda($_SESSION['refer'])) {
echo "<img src = '/style/icons/left.png' /> <a href='$_SESSION[refer]'>" . otkuda($_SESSION['refer']) . "</a><br />n";
}
echo "</div>n";
include_once 'sys/inc/tfoot.php';