<?

////Модификация DCMS 6.6.4 by Kyber\\\\
////Специально для  сети klybok.net\\\\
////Распространение бесплатное FREE\\\\
////Запрещено присваивать мод права\\\\
////Безопасные моды на-> klybok.net\\\\
////Автор CMS Desure | MOD by Kyber\\\\

include_once 'sys/inc/start.php';
include_once 'sys/inc/compress.php';
include_once 'sys/inc/sess.php';
include_once 'sys/inc/home.php';
include_once 'sys/inc/settings.php';
include_once 'sys/inc/db_connect.php';
include_once 'sys/inc/ipua.php';
include_once 'sys/inc/fnc.php';
include_once 'sys/inc/user.php';
$set['title']='Новые сообщения';
include_once 'sys/inc/thead.php';

only_reg(); 
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'];
echo "<table class='post'>\n";
if ($k_post==0){
echo "<tr><td class='p_t'>Нет новых сообщений</td></tr>\n";
}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 "<tr>\n";
if ($set['set_show_icon']==2){
echo "<td class='icon48' rowspan='2'>\n";
avatar($ank['id']);
echo "</td>\n";
}
elseif ($set['set_show_icon']==1)
{
echo "<td class='icon14'><img src='/style/themes/$set[set_them]/user/$ank[pol].png' alt='' /></td>";
}
echo "<td class='p_t'>\n";
if ($ank)
echo "<a href='/mail.php?id=$ank[id]'>".($kont['name']?$kont['name']:$ank['nick'])."</a>".online($ank['id'])." (+$kont[count])\n";
else
echo "<a href='/mail.php?id=$ank[id]'>[DELETED] (+$kont[count])</td></tr><tr>\n";
if ($set['set_show_icon']==1)echo "<td class='p_m' colspan='2'>\n"; else echo "<td class='p_m'>\n";
echo "Отправлено: ".vremja($kont['last_time'])."<br /></td></tr>\n";
}
}
echo "</table>\n";
if ($k_page>1)str('?',$k_page,$page); // Вывод страниц
echo "<div class='foot'><a href='/konts.php?$passgen'>Список контактов</a><br /><a href='umenu.php'>Мое меню</a><br /></div>\n";

include_once 'sys/inc/tfoot.php';
?>