<?php 
require "../../Run.php";
require "../../include/page.inc.php";
function listStart($limit){
	$start = ($_GET['page']-1)*$limit;
	if($start < 0){
		$start = 0;
	}
	return $start;
}
function getMessList(){
	$WAPID = WAPID;
	$sql = "SELECT * FROM message WHERE wapid='".$WAPID."' AND sendid='".MYID."' ORDER BY messageid DESC LIMIT ".listStart(15).",15;";
	$mess = mysql_query($sql);
	if($mess && mysql_num_rows($mess) > 0){
			$nums = 0;
			
			while(list($messageid,$sendid,$toid,$title,$content,$read,$time,$wapid) = mysql_fetch_row($mess)){
			if($read == 0){
				$tip = '[未读]';
			}else{
				$tip = '';
			}
			$div = $num++%2 == 0?'line1':'line2';
				$html .= '<div class="'.$div.'">'.$tip.'<a href="http://'.HTTP_HOST.'/user/message/content.php?id='.$messageid.'">'.$title.'</a>'.date('Y-m-d H:i:s',$time).'</div>';
			}
		}else{
				return '<div class="tip">暂时发件箱里没有短信哦!</div>'; //记录为空返回空
		}
	return $html;
}

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?'; 
	$sum = mysql_num_rows(mysql_query("SELECT * FROM message WHERE wapid='".WAPID."' AND toid='".MYID."';"));
	$limit = 15;
echo topNavBar($left,$center,$right);
echo '<div class="title">发件箱|<a href="send.php?">发送短信</a>|<a href="delall.php?">清空短信</a></div>';
echo getMessList();
echo '<div class="showpage">'.page($sum,$limit,$pageurl,NULL,'view').'</div>';
echo footer(1);
?>