Файл: modules/mail/index.php
Строк: 68
<?php
/**********************************
* @package: PerfCMS *
* @year: 2012 *
* @author: Artas *
* @link: http://perfcms.ru *
**********************************/
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()-300))
{
$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">+ '. $new_mail .'</span>':NULL) .'
</div>';
} else {
$usr = $db->query("SELECT * FROM `users` WHERE `id` = '".$mail['user_id']."' LIMIT 1")->fetch();
if($usr['time'] > (time()-300))
{
$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">+ '. $new_mail .'</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('/'); }
?>