<?php 
	require "../../Run.php";
	
	echo head('发送信件');
	if($_GET['burl']!=NULL){
		$left = '';
	}
	$center = '写短信';
	$right = '<a href="http://'.HTTP_HOST.'/index.php?">首页</a>';
	$pageurl ='http://'.HTTP_HOST.'/user/message/list.php?'; 
	$NUMS = mysql_num_rows(mysql_query("SELECT * FROM message WHERE wapid='".WAPID."\'"));
	$limit = 15;
echo topNavBar($left,$center,$right);
	$title = $_POST['mess_title'];
	if($_POST['mes_title'] == NULL){
		$title = '您收到了一个懒得不写题目的信哦！'; 
	}
		if(LOGIN == 1){
			if($_POST['mes_send'] == 'yes'){
				$sql = 'INSERT INTO `message` (`messageid`, `sendid`, `toid`, `title`, `content`, `read`, `time`, `wapid`) VALUES (NULL, \''.MYID.'\', \''.user2('id',$_POST['mes_toid'],WAPID).'\', \''.$_POST['mes_title'].'\', \''.$_POST['mes_content'].'\', \'0\', \''.time().'\', \''.WAPID.'\');'; 
				$mess = mysql_query($sql);
				if($mess && mysql_affected_rows()>0){
					echo '<div class="tip">短信已经成功发送了...</div>';
				}
				echo '<div class="mylink"><a href="list.php?">短信列表</a></div>';
			}else{
				echo '<div class="title"><a href="list.php?">收件箱</a></div>';
				echo '<form method="post" action="?">';
				echo '短信标题<br>';
				echo '<input name="mes_title" type="text" value=""><br>';
				echo '收件人ID<br>';
				echo '<input name="mes_toid" type="text" value="'.$_GET['toid'].'"><br>';
				echo '短信内容<br>';
				echo '<textarea name="mes_content"></textarea><br>';
				echo '<input name="mes_send" type="hidden" value="yes">';
				echo '<input  type="submit" value="发送短信">';
				echo '</form>';
			}
		}else{
			echo '<div class="tip">您好，您尚未登录，没有足够的权限进行操作，请登录后再进入本页面！</div>';
		}
	echo footer(1);
	?>