<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
if (!$go OR $go == 'all') {
require_once './element_function/element_function_mail.php';
$count = Cache_Count_Message($user['lost_id']);
if (isset($_GET['delete_read'])) {
mysql_query("UPDATE `element_mail` SET `lost_in` = '0' WHERE `lost_in` = '$user[lost_id]' AND `lost_new` = '0'");
mysql_query("UPDATE `element_mail` SET `lost_out` = '0' WHERE `lost_out` = '$user[lost_id]'");
writecache('element_count_message'.$user['lost_id'], array());
header('Location: /mail');
exit;
}
if (isset($_GET['read_all'])) {
mysql_query("UPDATE `element_mail` SET `lost_new` = '0' WHERE `lost_in` = '$user[lost_id]' AND `lost_money_gold` = '0'");
$count['new'] = mysql_result(mysql_query("SELECT COUNT(lost_id) FROM `element_mail` WHERE `lost_in` = '$user[lost_id]' AND `lost_new` = '1'"), 0);
$lost_other[2] = $count_new;
$user['lost_other'] = implode(' ', $lost_other);
writecache('element_users_id_'.$user['lost_id'], $user);
user_list_update($user['lost_id']);
writecache('element_count_message'.$user['lost_id'], $count);
header('Location: /mail');
exit;
}
$title = 'Почта : Все';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
echo '<div class="nfl p5 mb5 mt5 w96 mlra">';
echo '<div class="small cntr white">';
echo '<span>Все</span> | <a href="/mail?go=in">Входящие</a> | <a href="/mail?go=out">Отправленные</a> | <a href="/mail?go=new">Новые</a>';
echo '</div>';
if (empty($count['all'])) {
$count['all'] = mysql_result(mysql_query("SELECT COUNT(lost_id) FROM `element_mail` WHERE `lost_in` = '$user[lost_id]' OR `lost_out` = '$user[lost_id]'"), 0);
writecache('element_count_message'.$user['lost_id'], $count);
}
if ($count['all'] > 0) {
require_once './element_function/element_function_pagination.php';
$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
$pagination = pagination(10, $page, $count['all']);
$query = mysql_query("SELECT `lost_id`,`lost_sub_text`,`lost_time`,`lost_user_out`,`lost_user_in`,`lost_system`,`lost_new`
FROM `element_mail`
WHERE `lost_out` = '$user[lost_id]' OR `lost_in` = '$user[lost_id]'
ORDER BY `lost_time` DESC
LIMIT $pagination[start], $pagination[num]");
echo '<div class="nf2 mt5 mb5 p5">';
while ($myrrow = mysql_fetch_array($query)) {
$user_mail = ($myrrow['lost_user_out'] == $user['lost_id']) ? cache_user($myrrow['lost_user_in']) : cache_user($myrrow['lost_user_out']);
$on_off = (!empty($online[$user_mail['lost_id']])) ? 'online' : 'offline';
echo '
<div>
<a class="bl p5 block'.(($myrrow['lost_user_in'] == $user['lost_id'] AND $myrrow['lost_new'] == 1) ? '' : ' odd').'" href="/mail/read?id='.$myrrow['lost_id'].'">
<span class="small fr pt2 lngreen">'.rdate("d M H:i", $myrrow['lost_time']).'</span>
<img alt="" src="/images/icons/'.(($myrrow['lost_user_out'] == $user['lost_id']) ? 'mail_out' : 'mail_in').'.png"/>
'.((empty($myrrow['lost_system'])) ? ikonka_user($user_mail['lost_race'], $on_off) : '').'
'.((empty($myrrow['lost_system'])) ? '<span class="yellow1 small">'.$user_mail['lost_login'].'</span>' : '<span class="small white">'.$myrrow['lost_system'].'</span>').'<br/>
<span class="small gray1">'.$myrrow['lost_sub_text'].'</span>
</a>
</div>';
}
echo '</div>';
echo pagination_echo($pagination['page'],$pagination['total'],'/mail?go=all&page=');
echo '<div class="p5 cntr">';
echo '<a class="small yellow1" href="/mail?go=all&read_all">Отметить всё как прочитанное</a><br/><br/>';
echo '<span class="lngreen small">Почта хранится 30 дней!<br/>Подсказка: регулярное удаление писем ускоряет загрузку страниц</span>';
echo '<br/><br/><a class="small red" href="/mail?go=all&delete_read">Удалить все прочитанные!</a>';
echo '</div>';
} else echo '<div class="hr p5"></div><div class="p5 small cntr white">В почте писем не найдено</div>';
echo '</div>';
require_once './element_include/element_foot_user_true.php';
exit;
}
if ($go == 'out') {
$title = 'Почта : Отправленные';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
require_once './element_function/element_function_mail.php';
echo '<div class="nfl p5 mb5 mt5 w96 mlra">';
echo '<div class="small cntr white">';
echo '<a href="/mail?go=all">Все</a> | <a href="/mail?go=in">Входящие</a> | <span>Отправленные</span> | <a href="/mail?go=new">Новые</a>';
echo '</div>';
$count = Cache_Count_Message($user['lost_id']);
if (empty($count['out'])) {
$count['out'] = mysql_result(mysql_query("SELECT COUNT(lost_id) FROM `element_mail` WHERE `lost_out` = '$user[lost_id]'"), 0);
writecache('element_count_message'.$user['lost_id'], $count);
}
if ($count['out'] > 0) {
require_once './element_function/element_function_pagination.php';
$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
$pagination = pagination(10, $page, $count['out']);
$query = mysql_query("SELECT `lost_id`,`lost_sub_text`,`lost_time`,`lost_user_out`,`lost_user_in`,`lost_system`,`lost_new`
FROM `element_mail`
WHERE `lost_out` = '$user[lost_id]'
ORDER BY `lost_time` DESC
LIMIT $pagination[start], $pagination[num]");
echo '<div class="nf2 mt5 mb5 p5">';
while ($myrrow = mysql_fetch_array($query)) {
$user_mail = cache_user($myrrow['lost_user_in']);
$on_off = (!empty($online[$user_mail['lost_id']])) ? 'online' : 'offline';
echo '
<div>
<a class="bl p5 block" href="/mail/read?id='.$myrrow['lost_id'].'">
<span class="small fr pt2 lngreen">'.rdate("d M H:i", $myrrow['lost_time']).'</span>
<img alt="" src="/images/icons/mail_out.png"/>
'.ikonka_user($user_mail['lost_race'], $on_off).'
'.'<span class="yellow1 small">'.$user_mail['lost_login'].'</span>'.'<br/>
<span class="small gray1">'.$myrrow['lost_sub_text'].'</span>
</a>
</div>';
}
echo '</div>';
echo pagination_echo($pagination['page'],$pagination['total'],'/mail?go=out&page=');
echo '<div class="p5 cntr">';
echo '<span class="lngreen small">Почта хранится 30 дней!<br/>Подсказка: регулярное удаление писем ускоряет загрузку страниц</span>';
echo '</div>';
} else echo '<div class="hr p5"></div><div class="p5 small cntr white">Отправленных писем не найдено</div>';
echo '</div>';
require_once './element_include/element_foot_user_true.php';
exit;
}
if ($go == 'in') {
$title = 'Почта : Входящие';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
require_once './element_function/element_function_mail.php';
echo '<div class="nfl p5 mb5 mt5 w96 mlra">';
echo '<div class="small cntr white">';
echo '<a href="/mail?go=all">Все</a> | <span>Входящие</span> | <a href="/mail?go=out">Отправленные</a> | <a href="/mail?go=new">Новые</a>';
echo '</div>';
$count = Cache_Count_Message($user['lost_id']);
if (empty($count['in'])) {
$count['in'] = mysql_result(mysql_query("SELECT COUNT(lost_id) FROM `element_mail` WHERE `lost_in` = '$user[lost_id]'"), 0);
writecache('element_count_message'.$user['lost_id'], $count);
}
if ($count['in'] > 0) {
require_once './element_function/element_function_pagination.php';
$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
$pagination = pagination(10, $page, $count['in']);
$query = mysql_query("SELECT `lost_id`,`lost_sub_text`,`lost_time`,`lost_user_out`,`lost_user_in`,`lost_system`,`lost_new`
FROM `element_mail`
WHERE `lost_in` = '$user[lost_id]'
ORDER BY `lost_time` DESC
LIMIT $pagination[start], $pagination[num]");
echo '<div class="nf2 mt5 mb5 p5">';
while ($myrrow = mysql_fetch_array($query)) {
$user_mail = cache_user($myrrow['lost_user_out']);
$on_off = (!empty($online[$user_mail['lost_id']])) ? 'online' : 'offline';
echo '
<div>
<a class="bl p5 block '.(($myrrow['lost_new'] > 0) ? '' : 'odd').'" href="/mail/read?id='.$myrrow['lost_id'].'">
<span class="small fr pt2 lngreen">'.rdate("d M H:i", $myrrow['lost_time']).'</span>
<img alt="" src="/images/icons/mail_in.png"/>
'.((!empty($myrrow['lost_system'])) ? '<span class="yellow1 small">'.$myrrow['lost_system'].'</span><br/>' : ikonka_user($user_mail['lost_race'], $on_off).' <span class="yellow1 small">'.$user_mail['lost_login'].'</span><br/>').'
<span class="small gray1">'.$myrrow['lost_sub_text'].'</span>
</a>
</div>';
}
echo '</div>';
echo pagination_echo($pagination['page'],$pagination['total'],'/mail?go=in&page=');
echo '<div class="p5 cntr">';
echo '<span class="lngreen small">Почта хранится 30 дней!<br/>Подсказка: регулярное удаление писем ускоряет загрузку страниц</span>';
echo '</div>';
} else echo '<div class="hr p5"></div><div class="p5 small cntr white">Входящих писем не найдено</div>';
echo '</div>';
require_once './element_include/element_foot_user_true.php';
exit;
}
if ($go == 'new') {
$title = 'Почта : Новые';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
require_once './element_function/element_function_mail.php';
echo '<div class="nfl p5 mb5 mt5 w96 mlra">';
echo '<div class="small cntr white">';
echo '<a href="/mail?go=all">Все</a> | <a href="/mail?go=in">Входящие</a> | <a href="/mail?go=out">Отправленные</a> | <span>Новые</span>';
echo '</div>';
$count = Cache_Count_Message($user['lost_id']);
if (empty($count['new'])) {
$count['new'] = mysql_result(mysql_query("SELECT COUNT(lost_id) FROM `element_mail` WHERE `lost_in` = '$user[lost_id]' AND `lost_new` = '1'"), 0);
writecache('element_count_message'.$user['lost_id'], $count);
}
if ($count['new'] > 0) {
require_once './element_function/element_function_pagination.php';
$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
$pagination = pagination(10, $page, $count['new']);
$query = mysql_query("SELECT `lost_id`,`lost_sub_text`,`lost_time`,`lost_user_out`,`lost_user_in`,`lost_system`,`lost_new`
FROM `element_mail`
WHERE `lost_in` = '$user[lost_id]' AND `lost_new` = '1'
ORDER BY `lost_time` DESC
LIMIT $pagination[start], $pagination[num]");
echo '<div class="nf2 mt5 mb5 p5">';
while ($myrrow = mysql_fetch_array($query)) {
$user_mail = cache_user($myrrow['lost_user_out']);
$on_off = (!empty($online[$user_mail['lost_id']])) ? 'online' : 'offline';
echo '
<div>
<a class="bl p5 block" href="/mail/read?id='.$myrrow['lost_id'].'">
<span class="small fr pt2 lngreen">'.rdate("d M H:i", $myrrow['lost_time']).'</span>
<img alt="" src="/images/icons/mail_in.png"/>
'.ikonka_user($user_mail['lost_race'], $on_off).'
'.((empty($myrrow['lost_system'])) ? '<span class="yellow1 small">'.$user_mail['lost_login'].'</span>' : '<span class="small white">'.$myrrow['lost_system'].'</span>').'<br/>
<span class="small gray1">'.$myrrow['lost_sub_text'].'</span>
</a>
</div>';
}
echo '</div>';
echo pagination_echo($pagination['page'],$pagination['total'],'/mail?go=new&page=');
echo '<div class="p5 cntr">';
echo '<span class="lngreen small">Почта хранится 30 дней!<br/>Подсказка: регулярное удаление писем ускоряет загрузку страниц</span>';
echo '</div>';
} else echo '<div class="hr p5"></div><div class="p5 small cntr white">Новых писем не найдено</div>';
echo '</div>';
require_once './element_include/element_foot_user_true.php';
exit;
}
?>