View file element_admin_mail.php

File size: 10.96Kb
<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
if ($user['lost_privilege'] != 3) { header('Location: /'); exit; } 

if (!$id) {
	$title = 'Персонаж не найден';
	$error1 = '<span class="small">Выбранный Вами персонаж не существует, либо был удален';
	require_once 'element_error_page.php';
	exit;
	}

	$profile_user = cache_user($id);	
	
if (!$profile_user) {
	$title = 'Персонаж не найден';
	$error1 = '<span class="small">Выбранный Вами персонаж не существует, либо был удален';
	require_once 'element_error_page.php';
	exit;
}

if (!$go OR $go == 'all') {
	$title = 'Почта "'.$profile_user['lost_login'].'"';
	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 '<span>Все</span> | <a href="/element/admin/mail?id='.$id.'&go=in">Входящие</a> | <a href="/element/admin/mail?id='.$id.'&go=out">Отправленные</a> | <a href="/element/admin/mail?id='.$id.'&go=new">Новые</a>';
	echo '</div>';
		$count = Cache_Count_Message($id);
		if (empty($count['all'])) {
		$count['all'] = mysql_result(mysql_query("SELECT COUNT(lost_id) FROM `element_mail` WHERE `lost_user_in` = '$id' OR `lost_user_out` = '$id'"), 0);
		writecache('element_count_message'.$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_user_out` = '$id' OR `lost_user_in` = '$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'] == $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'] == $id AND $myrrow['lost_new'] == 1) ? '' : ' odd').'" href="/element/admin/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'] == $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'],'/element/admin/mail?id='.$id.'&go=all&page=');
	} 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 = 'Почта "'.$profile_user['lost_login'].'"';
	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="/element/admin/mail?id='.$id.'&go=all">Все</a> | <a href="/element/admin/mail?id='.$id.'&go=in">Входящие</a> | <span>Отправленные</span> | <a href="/element/admin/mail?id='.$id.'&go=new">Новые</a>';
	echo '</div>';
		$count = Cache_Count_Message($id);
		if (empty($count['out'])) {
		$count['out'] = mysql_result(mysql_query("SELECT COUNT(lost_id) FROM `element_mail` WHERE `lost_user_out` = '$id'"), 0);
		writecache('element_count_message'.$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_user_out` = '$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 odd" href="/element/admin/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'],'/element/admin/mail?id='.$id.'&go=out&page=');
	} 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 = 'Почта "'.$profile_user['lost_login'].'"';
	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="/element/admin/mail?id='.$id.'&go=all">Все</a> | <span>Входящие</span> | <a href="/element/admin/mail?id='.$id.'&go=out">Отправленные</a> | <a href="/element/admin/mail?id='.$id.'&go=new">Новые</a>';
	echo '</div>';
		$count = Cache_Count_Message($id);
		if (empty($count['in'])) {
		$count['in'] = mysql_result(mysql_query("SELECT COUNT(lost_id) FROM `element_mail` WHERE `lost_user_in` = '$id'"), 0);
		writecache('element_count_message'.$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_user_in` = '$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="/element/admin/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'],'/element/admin/mail?id='.$id.'&go=in&page=');
	} 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 = 'Почта "'.$profile_user['lost_login'].'"';
	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="/element/admin/mail?id='.$id.'&go=all">Все</a> | <a href="/element/admin/mail?id='.$id.'&go=in">Входящие</a> | <a href="/element/admin/mail?id='.$id.'&go=out">Отправленные</a> | <span>Новые</span>';
	echo '</div>';
		$count = Cache_Count_Message($id);
		if (empty($count['new'])) {
		$count['new'] = mysql_result(mysql_query("SELECT COUNT(lost_id) FROM `element_mail` WHERE `lost_user_in` = '$id' AND `lost_new` = '1'"), 0);
		writecache('element_count_message'.$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_user_in` = '$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="/element/admin/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).'
				'.'<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'],'/element/admin/mail?id='.$id.'&go=new&page=');
	
	} 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;
	}
	
?>