Файл: modules/mail/index.php
Строк: 67
<?php
if(isset($user)) {
$locate = 'in_cabinet';
$title = $lang->word('u_mail');
require_once(SYS.'/view/header.php');
$tpl->div('title', $lang->word('u_mail'));
$mailn = $db->query("SELECT * FROM `mail_chat` WHERE `user_id` = '$user[id]' OR `who_id` = '$user[id]'")->rowCount();
$pages = new Paginator($mailn, $ames);
if($mailn == 0) {
$tpl->div('post', $lang->word('no_posts'));
} else {
$mailq = $db->query("SELECT * FROM `mail_chat` WHERE `user_id` = '$user[id]' OR `who_id` = '$user[id]' ORDER BY time_last_message DESC LIMIT $start, $ames");
while($mail = $mailq->fetch()) {
$new_mail = $db->query("SELECT * FROM `mail` WHERE `who_id` = '$user[id]' AND `read` = '0' AND `mail_chat_id` = '$mail[id]'")->rowCount();
if ($mail['user_id'] == $user['id']) {
$usr = $db->query("SELECT * FROM `users` WHERE `id` = '".$mail['who_id']."' LIMIT 1")->fetch();
if($usr['time'] > (time()-600))
{
$on = img('on.png');
}
else
{
$on = img('off.png');
}
if($usr['level'] > 4)
{
$gen = img($usr['gender'].'_admin.png');
}
else
{
$gen = img($usr['gender'].'.png');
}
echo '<div class="menu">
'.avatar_mini($usr['nick']).' '.$gen.' <a href="/mail/chat/'. $mail['who_id'] .'">'. tnick($mail['who_id']) .'</a> '.$on.' ['. rtime($mail['time_last_message']) .']'. ($new_mail > 0?' <span class="green"><b>+ '. $new_mail .'</b></span>':NULL) .'
</div>';
} else {
$usr = $db->query("SELECT * FROM `users` WHERE `id` = '".$mail['user_id']."' LIMIT 1")->fetch();
if($usr['time'] > (time()-600))
{
$on = img('on.png');
}
else
{
$on = img('off.png');
}
if($usr['level'] > 4)
{
$gen = img($usr['gender'].'_admin.png');
}
else
{
$gen = img($usr['gender'].'.png');
}
echo '<div class="menu">
'.avatar_mini($usr['nick']).' '.$gen.' <a href="/mail/chat/'. $mail['user_id'] .'">'. tnick($mail['user_id']) .'</a> '.$on.' ['. rtime($mail['time_last_message']) .']'. ($new_mail > 0?' <span class="green"><b>+ '. $new_mail .'</b></span>':NULL) .'
</div>';
}
}
$pages->view('/mail/?');
}
$tpl->div('block', NAV .' <a href="/user/panel/">'. $lang->word('user_panel') .'</a><br/>' . HICO .'<a href="/">'.$lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');
} else { go('/'); }
?>