Просмотр файла element_mail_create.php

Размер файла: 4.1Kb
<?php
require_once './element_options/element_options.php';
	if (!$user) { header('Location: /'); exit; }
	
	if (!$id) {
		$title = 'Персонаж не найден';
		$error1 = '<span class="small">Выбранный Вами персонаж не существует, либо был удален, если вы считаете это ошибкой, обратитесь пожалуйста в <a class="small yellow" href="/support">техническую поддержку</a></span>';
		require_once 'element_error_page.php';
		exit;
	}
	
	if ($id == $user['lost_id']) {
		$title = 'Доспут закрыт';
		$error1 = '<span class="small">Вы не можете отправлять сообщения самому себе</span>';
		require_once 'element_error_page.php';
		exit;	
	}
	
	$profile_user = cache_user($id);
	
	if (!$profile_user) {
		$title = 'Персонаж не найден';
		$error1 = '<span class="small">Выбранный Вами персонаж не существует, либо был удален, если вы считаете это ошибкой, обратитесь пожалуйста в <a class="small yellow" href="/support">техническую поддержку</a></span>';
		require_once 'element_error_page.php';
		exit;
	}
	
	$title = 'Письмо для "'.$profile_user['lost_login'].'"';
	require_once './element_include/element_head.php';
	require_once './element_include/element_header_user_true.php';
	
		if ($go == 'add') {
			$text = (isset($_POST['text']) AND !empty($_POST['text'])) ? mysql_real_escape_string(htmlspecialchars(addslashes(trim($_POST['text'])))) : false;
			
			if (!$text) $error = 'Поле \'сообщение\' обязательно для ввода';
			if ($user['lost_resourse_cristalls'] < 1) $error = 'Недостаточно кристаллов';
			
			if (!isset($error)) {
				require_once './element_function/element_function_mail.php';
				$sub_text = mb_substr($text,0,20,"UTF-8");
				$sub_text = (mb_strlen($sub_text,"UTF-8") >= 20) ? $sub_text.'...' : $sub_text;
				$profile_other = explode(' ', $profile_user['lost_other']);
				if ($profile_other[2] < 0) $profile_other[2] = 0;
				$profile_other[2] = $profile_other[2] + 1;
				$profile_user['lost_other'] = implode(' ', $profile_other);
				writecache('element_users_id_'.$id, $profile_user);
				user_list_update($id);
				update_money_exp($user, 0, -1, 0, 0);
				
				mysql_query("INSERT INTO `element_mail` SET `lost_out` = '$user[lost_id]',
															`lost_in` = '$id',
															`lost_sub_text` = '$sub_text',
															`lost_text` = '$text',
															`lost_user_out` = '$user[lost_id]',
															`lost_user_in` = '$id',
															`lost_time` = '".time()."',
															`lost_new` = '1'");
				$count_out = Cache_Count_Message($user['lost_id']);
				$count_in = Cache_Count_Message($id);	
					
					if (!empty($count_out['all'])) $count_out['all']++;
					if (!empty($count_out['out'])) $count_out['out']++;
					writecache('element_count_message'.$user['lost_id'], $count_out);
					
					if (!empty($count_in['all'])) $count_in['all']++;
					if (!empty($count_in['in'])) $count_in['in']++;
					if (!empty($count_in['new'])) $count_in['new']++;
					writecache('element_count_message'.$id, $count_in);

				header('Location: /mail');
				exit;
			} else echo '<div class="error cntr p5 mb5"><span class="red">'.$error.'</span></div>'; 
		}
	
	echo '<div class="nfl cntr p5 mb5 mt5 mlra">';
	echo '
	<form method="post" action="/mail/create?id='.$id.'&go=add">
		<span class="small white">Сообщение</span><br/>
		<textarea class="w90 mb5 fdark" rows="5" name="text"></textarea><br/>
		
		<span class="btn w40"><span class="el">
			<span class="er"><input class="ttl" type="submit" name="submit" value="Отправить"/>
			</span></span>
		</span>
	</form>';
	echo '<br/><span class="yellow1">Стоимость отправки почты <img src="/images/icons/cristall.png">1</span>';
	echo '</div>';
	require_once './element_include/element_foot_user_true.php';
?>