<!--<?php
print <<<EOT
-->
<div class="bdbA">
	<div id="breadcrumbs">
		<a class="crumbs-item gray3" href="$db_bfn" title="$db_bbsname">$db_bbsname</a><a class="crumbs-item gray3" href="u.php"><i> </i>用户中心</a>
<!--
EOT;
if($action=='receivebox'){print <<<EOT
-->
			<span class="crumbs-item current"><i> </i><strong>收件箱</strong></span>
<!--
EOT;
}elseif($action=='sendbox'){print <<<EOT
-->
			<span class="crumbs-item current"><i> </i><strong>发件箱</strong></span>
<!--
EOT;
}elseif($action=='scout'){print <<<EOT
-->
			<span class="crumbs-item current"><i> </i><strong>消息跟踪</strong></span>
<!--
EOT;
}elseif($action=='write'){print <<<EOT
-->
			<span class="crumbs-item current"><i> </i><strong>写新消息</strong></span>
<!--
EOT;
}elseif($action=='chatlog'){print <<<EOT
-->
			<span class="crumbs-item current"><i> </i><strong>通信记录</strong></span>
<!--
EOT;
}elseif(in_array($action,array('read','readsnd','readscout','readpub'))){print <<<EOT
-->
			<span class="crumbs-item current"><i> </i><strong>阅读</strong></span>
<!--
EOT;
}else{print <<<EOT
-->
			<span class="crumbs-item current"><i> </i><strong>收件箱</strong></span>
<!--
EOT;
}print <<<EOT
-->
	</div>
</div>
<style>
.s3,a.s3{color:#f06f18;}
#set-wrap{width:100%;margin:8px auto 1.5em;line-height:150%}
#set-side{width:170px;float:left;}
#set-content{margin-left:173px;_margin-left:170px;background:$bgcolor;}
#set-content-wrap{border:1px solid $tdcolor;padding:1em;}
#set-side-wrap {border:4px solid $tdcolor;background:$bgcolor;}
.set-h2{background:url($imgpath/$stylepath/set-h3.gif) repeat-x;height:30px; line-height:30px;border-bottom:$tdcolor solid 1px;margin:0;padding:0 .6em;font-size:12px;display:block}
.color8{color:#D2C100}
#set-menu{font-size:14px;padding:.6em 0 .6em 1em;margin:0;list-style:none}
#set-menu li{margin:0;padding:.3em 0 0 1.5em;background:url($imgpath/$stylepath/u-fav.gif) no-repeat 0 0.5em;}
#set-menu li a{color:#949494}
#set-menu li.current{background:url($imgpath/$stylepath/u-fav-cur.gif) no-repeat 0 0.5em;}
#set-menu li.current a{color:#707070;font-weight:700}
.set-content-left{margin-right:320px;}
.set-content-right{width:300px;float:right}
.set-table1{line-height:200%}
.set-table1 .tdpr2{padding-right:2em}
#set-content-wrap td{vertical-align:top;}
.set-table2 td{padding:.5em 1em;border-bottom:1px dotted $cbgborder;}
.set-table2 td.td1{text-align:right;padding:.5em 1em;}
.set-tab-table{background:$cbgcolor url($imgpath/$stylepath/set-tab-dot.gif) repeat-x left bottom}
.set-tab-table td{border-bottom:0;padding:.2em 2em;border-right:1px solid $bgcolor;border-left:1px solid $tdcolor}
.set-tab-table td.current{border:1px solid $tdcolor;border-bottom:0;background:$bgcolor}
.set-tab-table td.current a{color:$headfontone;font-weight:700}
.set-tab-box{border:1px solid $tdcolor;border-top:0;padding:.5em 1em}
textarea{font-size:12px;}
</style>
<div id="set-wrap">
	<div id="set-side">
		<div id="set-side-wrap">
			<h2 class="set-h2 color8">短消息</h2>
			<ul id="set-menu">
				<li id="msg_receivebox">
					<a href="$secondurl?action=receivebox">收件箱</a>
				</li>
				<li id="msg_sendbox">
					<a href="$secondurl?action=sendbox">发件箱</a>
				</li>
				<li id="msg_scout">
					<a href="$secondurl?action=scout">消息跟踪</a>
				</li>
				<li id="msg_write">
					<a href="$secondurl?action=write">写新消息</a>
				</li>
				<li>
					<a href="profile.php?action=bbsset&info_type=msg">短消息设置</a>
				</li>				
				<li>
					<a style="cursor:pointer;" onclick="return checkset();">清空</a>
				</li>
			</ul>
		</div>
	</div>
<script language="javascript">
setCurrent('msg_$action','','current');
var ifcheck = true;
function CheckAll(form,match) {
	for (var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];
		if (e.type == 'checkbox' && (typeof match == 'undefined' || e.name.match(match))) {
			e.checked = ifcheck;
		}
	}
	ifcheck = ifcheck == true ? false : true;
}
</script>
	<div id="set-content">
		<div id="set-content-wrap" class="cc" style="padding:.3em">
		<div>
<!--
EOT;
if($action=='receivebox'){print <<<EOT
-->
			<div class="set-tab-table">
				<table border="0" cellspacing="0" cellpadding="0">
					<tr class="tac" id="infolist">
						<td id="base"><a style="cursor:pointer" onclick="showTabs('infolist','base','td','current')">个人消息</a>
<!--
EOT;
if ($contl > 100) {print <<<EOT
-->
							<font color="red">[您的信箱已满，请删除一些，以查看最新消息]</font>
<!--
EOT;
} elseif ($winddb['newpm'] & 1) {print <<<EOT
-->
							<img src="$imgpath/$stylepath/file/new.gif" />
<!--
EOT;
}print <<<EOT
-->
						</td>
						<td id="public">
							<a onclick="showTabs('infolist','public','td','current')" style="cursor:pointer">群发消息</a>
<!--
EOT;
if ($winddb['newpm'] & 2) {print <<<EOT
-->
							<img src="$imgpath/$stylepath/file/new.gif" />
<!--
EOT;
}print <<<EOT
-->
						</td>
					</tr>
				</table>
			</div>
			<div class="set-tab-box">
				<form name="del" action="$secondurl" method="post">
				<input type="hidden" name="verify" value="$verifyhash" />
				<div style="margin:1em 2em;display:none" id="info_public">
					<table width="100%" cellspacing="0" cellpadding="0" class="set-table2">
						<tr class="gray3">
							<td width="6%">ID</a></td>
							<td width="12%">发件人</td>
							<td width="*">标题</td>
							<td width="25%">时间</td>
							<td width="8%">选定</a></td>
						</tr>
<!--
EOT;
if($pmsgdb){
$i = 0;
foreach ($pmsgdb as $key => $message) {
$boldclass = $message['ifnew'] ? 'class="b"' : '';
$i++;
print <<<EOT
-->
						<tr>
							<td>$i</td>
							<td>$message[from]</td>
							<td><a href="$secondurl?action=readpub&mid=$message[mid]" $boldclass>$message[title]</a></td>
							<td>$message[mdate]</td>
							<td><input type="checkbox" name="pdelid[]" value="$message[mid]" /></td>
						</tr>
<!--
EOT;
}}print <<<EOT
-->
					</table>
				</div>
				<div id="info_base" style="display:none">
				<div style="margin:1em 2em;">
					<table width="100%" cellspacing="0" cellpadding="0" class="set-table2">
						<tr class="gray3">
							<td width="6%">ID</a></td>
							<td width="12%">发件人</td>
							<td width="*">标题</td>
							<td width="25%">时间</td>
							<td width="8%">选定</a></td>
						</tr>
<!--
EOT;
$i = ($page-1) * $permsg;
foreach ($msgdb as $key => $message) {
$i++;
$boldclass = $message['ifnew'] ? 'class="b"' : '';
print <<<EOT
-->
						<tr>
							<td>$i</td>
							<td><a href="u.php?action=show&uid=$message[fromuid]">$message[from]</a></td>
							<td><a href="$secondurl?action=read&mid=$message[mid]" $boldclass>$message[title]</a></td>
							<td>$message[mdate]</td>
							<td><input type="checkbox" name="delid[]" value="$message[mid]" /></td>
						</tr>
<!--
EOT;
}print <<<EOT
-->
				</table></div>$pages</div>
				<div class="tac" style=" padding:1em">
					<input class="btn" type="button" name="chkall" value="全选" onclick="CheckAll(this.form,p_match)" />
					<input class="btn" type="submit" value="提交" />
					<input name="towhere" type="hidden" value="receivebox" /><!-- 
					<input name="action" type="radio" value="doread" checked />标记为已读 -->
					<input name="action" type="radio" value="down" />下载
					<input name="action" type="radio" value="del" checked />删除
				</div>
				</form>
<script type="text/javascript">
var p_match = '';
function showTabs(id,select,element,css) {
	var o = getObj(id);
	var t = o.getElementsByTagName(element);
	for (var i = 0; i < t.length; i++) {
		if (t[i].id) {
			var oo = getObj(t[i].id);
			if (t[i].id == select) {
				getObj(t[i].id).className = css;
				getObj('info_'+t[i].id).style.display = '';
			} else {
				getObj(t[i].id).className = '';
				getObj('info_'+t[i].id).style.display = 'none';
			}
		}
	}
	ifcheck = false;
	p_match = select == 'base' ? /^delid/ : /^pdelid/;
	CheckAll(document.del);
	return false;
}
showTabs('infolist','$type','td','current');
</script>
<!--
EOT;
}elseif($action=='sendbox'){print <<<EOT
-->
			<div class="set-tab-table">
				<table border="0" cellspacing="0" cellpadding="0">
					<tr class="tac">
						<td class="current link5 b">发件箱</td>
					</tr>
				</table>
			</div>
			<div class="set-tab-box">
			<form name="del" action="$secondurl" method="post">
			<input type="hidden" name="verify" value="$verifyhash" />
			<div style="margin:1em 2em;" id="info_base">
				<table width="100%" cellspacing="0" cellpadding="0" class="set-table2">
					<tr class="gray3">
						<td width="6%">ID</a></td>
						<td width="12%">收件人</td>
						<td width="*">标题</td>
						<td width="25%">时间</td>
						<td width="8%">选定</a></td>
					</tr>
<!--
EOT;
$i = ($page - 1) * $permsg;
foreach ($msgdb as $key => $message) {
$i++;
print <<<EOT
-->
					<tr>
						<td>$i</td>
						<td><a href="u.php?action=show&uid=$message[touid]">$message[to]</a></td>
						<td><a href="$secondurl?action=readsnd&mid=$message[mid]">$message[title]</a></td>
						<td>$message[mdate]</td>
						<td><input type="checkbox" name="delid[]" value="$message[mid]" /></td>	
					</tr>
<!--
EOT;
}print <<<EOT
-->
				</table>
			</div>$pages
			<div class="tac" style=" padding:1em">
				<input class="btn" type="button" name="chkall" value="全选" onclick="CheckAll(this.form)" />
				<input class="btn" type="submit" value="提交" />
				<input name="towhere" type="hidden" value="sendbox" />
				<input name="action" type="radio" value="down" />下载
				<input name="action" type="radio" value="del" checked />删除
			</div></form><br />
<!--
EOT;
} elseif ($action == 'scout') {print <<<EOT
-->
			<div class="set-tab-table">
				<table border="0" cellspacing="0" cellpadding="0">
					<tr class="tac">
						<td class="current link5 b">消息跟踪</td>
					</tr>
				</table>
			</div>
			<div class="set-tab-box">
			<form name="del" action="$secondurl" method="post">
			<input type="hidden" name="verify" value="$verifyhash" />
			<div style="margin:1em 2em;" id="info_base">
				<table width="100%" cellspacing="0" cellpadding="0" class="set-table2">
					<tr class="gray3">
						<td width="6%">ID</a></td>
						<td width="12%">收件人</td>
						<td width="*">标题</td>
						<td width="25%">时间</td>
						<td width="8%">已读</td>
						<td width="8%">选定</a></td>
						<td width="8%">编辑</td>
					</tr>
<!--
EOT;
$i = ($page-1) * $permsg;
foreach ($msgdb as $key => $message) {
$i++;
print <<<EOT
-->
					<tr>
						<td>$i</td>
						<td><a href="u.php?action=show&uid=$message[touid]">$message[to]</a></td>
						<td><a href="$secondurl?action=readscout&mid=$message[mid]">$message[title]</a></td>
						<td>$message[mdate]</td>
						<td>
<!--
EOT;
if($message['ifnew']){print <<<EOT
-->
							<font color="red">否</font>
<!--
EOT;
}else{print <<<EOT
-->
							是
<!--
EOT;
}print <<<EOT
-->
						</td>
<!--
EOT;
if($message['ifnew']==0 && $message['to'] != $windid){print <<<EOT
-->
						<td>--</td><td><br /></td>
<!--
EOT;
}else{print <<<EOT
-->
						<td><input type="checkbox" name="delid[]" value="$message[mid]" /></td>
						<td><a href="message.php?action=write&edmid=$message[mid]">编辑</a></td>
<!--
EOT;
}print <<<EOT
-->
					</tr>
<!--
EOT;
}print <<<EOT
-->
				</table>
			</div>$pages
			<div class="tac" style=" padding:1em">
				<input class="btn" type="button" name="chkall" value="全选" onclick="CheckAll(this.form)" />
				<input class="btn" type="submit" value="提交" />
				<input name="towhere" type="hidden" value="scout" />
				<input name="action" type="radio" value="down" />下载
				<input name="action" type="radio" value="del" checked />删除
			</div></form><br />
<!--
EOT;
} elseif (in_array($action,array('read','readsnd','readscout','readpub'))) {print <<<EOT
-->
			<div class="set-tab-table">
				<span class="fr" style="margin-right:3px"><a href="javascript:void(0)" onclick="msggoto('previous');">上一条</a> <a href="javascript:void(0)" onclick="msggoto('next');">下一条</a></span>
				<table border="0" cellspacing="0" cellpadding="0">
					<tr class="tac">
<!--
EOT;
if ($action == 'read') {print <<<EOT
-->
						<td><a href="message.php">个人消息</a></td>
<!--
EOT;
} elseif ($action == 'readpub') {print <<<EOT
-->
						<td><a href="message.php?action=receivebox&type=public">群发消息</a></td>
<!--
EOT;
} elseif ($action == 'readsnd') {print <<<EOT
-->
						<td><a href="message.php?action=sendbox">发件箱</a></td>
<!--
EOT;
} else {print <<<EOT
-->
						<td><a href="message.php?action=scout">消息跟踪</a></td>
<!--
EOT;
}print <<<EOT
-->
						<td class="current link5 b">查看信息</td>
					</tr>
				</table>
			</div>
			<div class="set-tab-box">
			<div style="margin:1em 2em;" id="info_base">
				<table width="100%" cellspacing="0" cellpadding="0" class="set-table2">
					<tr>
						<td class="td1" width="13%"><font color="#5A6633">
<!--
EOT;
if($action == 'readscout' || $action == 'readsnd'){print <<<EOT
-->
		收件人:
<!--
EOT;
}else{print <<<EOT
-->
		发件人:
<!--
EOT;
}print <<<EOT
-->
						</font></td>
						<td><a href="u.php?action=show&uid=$msginfo[withuid]">$msginfo[username]</a></td>
					</tr>
					<tr>
						<td class="td1" width="12%"><font color="#5A6633">标题:</font></td>
						<td>$msginfo[title]</td>
					</tr>
					<tr>
						<td class="td1" width="12%"><font color="#5A6633">时间:</font></td>
						<td>$msginfo[mdate]</td>
					</tr>
					<tr>
						<td class="td1" width="12%"><font color="#5A6633">内容:</font></td>
						<td>$msginfo[content]</td>
					</tr>
					<tr>
						<td class="td1"><font color="#5A6633">选项:</font></td>
						<td><font color="#5A6633">
<!--
EOT;
if($action=='read'){print <<<EOT
-->
							[<a href="$secondurl?action=chatlog&withuid=$msginfo[withuid]">通信记录</a>]
							[<a href="$secondurl?action=unread&mid=$msginfo[mid]&verify=$verifyhash">标记未读</a>]
							[<a href="$secondurl?action=write&remid=$msginfo[mid]">回复</a>]
							[<a href="$secondurl?action=write&transmit=$msginfo[mid]">转发</a>]
							[<a href="$secondurl?action=del&towhere=receivebox&delids=$msginfo[mid]&verify=$verifyhash">删除</a>]
							[<a href="message.php?action=receivebox">返回</a>]
<!--
EOT;
}elseif($action=='readpub'){print <<<EOT
-->
							[<a href="$secondurl?action=del&towhere=receivebox&pdelids=$msginfo[mid]&verify=$verifyhash">删除</a>]
							[<a href="message.php?action=receivebox&type=public">返回</a>]
<!--
EOT;
}elseif($action=="readsnd"){print <<<EOT
-->
							[<a href="$secondurl?action=chatlog&withuid=$msginfo[withuid]">通信记录</a>]
							[<a href="$secondurl?action=write&touid=$msginfo[withuid]">另发</a>]
							[<a href="$secondurl?action=write&transmit=$msginfo[mid]">转发</a>]
							[<a href="$secondurl?action=del&towhere=sendbox&delids=$msginfo[mid]&verify=$verifyhash">删除</a>]
							[<a href="message.php?action=sendbox">返回</a>]
<!--
EOT;
}elseif($action=="readscout"){print <<<EOT
-->
							[<a href="$secondurl?action=chatlog&withuid=$msginfo[withuid]">通信记录</a>]
							[<a href="$secondurl?action=write&touid=$msginfo[withuid]">另发</a>]
							[<a href="$secondurl?action=write&transmit=$msginfo[mid]">转发</a>]
							[<a href="$secondurl?action=del&towhere=scout&delids=$msginfo[mid]&verify=$verifyhash">删除</a>]
							[<a href="message.php?action=scout">返回</a>]
<!--
EOT;
}print <<<EOT
-->
						</font>
						</td>
					</tr>
				</table>
			</div></div>
<script language="JavaScript">
function msggoto(type) {
	ajax.send('pw_ajax.php?action=msggoto&from=$action&mid=$mid&type=' + type, '', function() {
		var rText = ajax.request.responseText.split('\t');
		if (rText[0] == 'ok') {
			location.href = 'message.php?action=$action&mid=' + rText[1];
		} else if (rText[0] == 'none') {
			alert(type == 'next' ? '已经是最后一条了!' : '已经是第一条了!');
		} else {
			ajax.guide();
		}
	});
}
</script>
<!--
EOT;
}elseif($action == 'chatlog'){print <<<EOT
-->
			<div class="set-tab-table">
				<table border="0" cellspacing="0" cellpadding="0">
					<tr class="tac">
						<td class="current link5 b">与 {$m[username]} 的通信记录</td>
					</tr>
				</table>
			</div>
			<div class="set-tab-box">
			<form action="$secondurl" method="post">
			<input type="hidden" name="verify" value="$verifyhash" />
			<input type="hidden" name="action" value="dellog" />
			<input type="hidden" name="withuid" value="$withuid" />
			<div style="margin:1em 2em;" id="info_base">
				<table width="100%" cellspacing="0" cellpadding="0" class="set-table2" style="table-layout:fixed">
<!--
EOT;
foreach($msgdb as $key => $value){print <<<EOT
-->
					<tr>
						<td style="line-height:150%; width:100%">
						<div>
							<span class="fr gray">{$u_name[$value[mtype]]} - $value[mdate]  <input type="checkbox" name="selid[]" value="$value[mid]" /></span>
							<span class="s2"><b>{$value[title]}</b></span><br />{$value[content]}</div>
						</td>
					</tr>
<!--
EOT;
}print <<<EOT
-->
			</table></div>{$pages}
			<div class="tac" style=" padding:1em">
				<input class="btn" type="button" name="chkall" value="全选" onclick="CheckAll(this.form)" />
				<input class="btn" type="submit" value="删 除" name="Submit" />
			</div>
		</form><div>
<!--
EOT;
}elseif($action=='write'){print <<<EOT
-->
			<script language="JavaScript" src="js/wind_editor.js"></script>
			<div class="set-tab-table">
				<table border="0" cellspacing="0" cellpadding="0">
					<tr class="tac">
						<td class="current link5 b">写短消息</td>
					</tr>
				</table>
			</div>
			<div class="set-tab-box">
			<form name="FORM" action="$secondurl" method="post" onsubmit="return checkCnt();">
<!--
EOT;
if($edinfo){ print <<<EOT
-->
			<input type="hidden" name="edmid" value="$edmid" />
<!--
EOT;
} print <<<EOT
-->
			<input type="hidden" name="action" value="write" />
			<input type="hidden" name="step" value="2" />
			<input type="hidden" name="verify" value="$verifyhash" />
			<div style="margin:1em;" id="info_base">
				<table width="100%" cellspacing="0" cellpadding="0" class="set-table2">
				<tr>
					<td class="td1" width="20%">用户名</td>
					<td><input class="input" type="text" name="pwuser"  style="width:50%"  size="73" $msgid />
					</td></tr>

<tr><td class="td1" width="20%">其他</td>
<td>
<div id="menu_show" style="display:none;"></div>
<a class="abtn" id="td_face" style="cursor:pointer;" onClick="showDefault();" align="absmiddle" unselectable="on">添加表情</a> <a class="abtn" id="newdraft" onclick="opendraft(this.id);">草稿箱</a>
<!--
EOT;
if($frienddb){print <<<EOT
-->
				<span class="abtn" onClick="getObj('tofriend').style.display='';">好友群发</span>
				</td></tr>
			
				<tr id="tofriend" style="display:none">
					<td class="td1">好友群发</td>
					<td>
<!--
EOT;
foreach($frienddb as $key=>$val){print <<<EOT
-->
						<input type="checkbox" name="touid[]" value="$val[friendid]" />$val[username]
<!--
EOT;
}print <<<EOT
-->
						<span class="abtn" style="cursor:pointer;" onClick="CheckAll(document.FORM,'touid')">全 选</span>
<!--
EOT;
}print <<<EOT
-->
			</td>	
				
				</tr>



				<tr>
					<td class="td1">标题</td>
					<td><input class="input" type="text" name="msg_title" style="width:50%" size="73" value="$subject" /></td>
				</tr>
<!--
EOT;
if($db_gdcheck & 8){print <<<EOT
-->
				<tr>
					<td class="td1">认证码</td>
					<td><input class="input" type="text" name="gdcode" size="8" onfocus="try{opencode('menu_gd',this)}catch(e){}" /><span style="cursor:pointer; margin-left:3px" onclick="this.previousSibling.focus();">点此显示验证码</span>
					<div class="menu" id="menu_gd" style="visibility:hidden;"><img src="ck.php?" align="absmiddle" style="cursor:pointer;" id="ckcode" title="看不清楚，换一张" /></div></td>
				</tr>
<!--
EOT;
}if($msgq && $db_question){
$qkey = array_rand($db_question);
print <<<EOT
-->
				<tr>
					<td class="td1">验证问题<br />{$db_question[$qkey]}</td>
					<td><input class="input" type="text" name="qanswer" /><input type="hidden" name="qkey" value="$qkey" /></td>
				</tr>
<!--
EOT;
}print <<<EOT
-->
				<tr>
					<td class="td1">内容<br /><br />
					<div id="menu_face" class="menu" style="display:none;"></div>
					<script language="javascript">
						var imgpath   = '$imgpath';
						var stylepath = '$stylepath';
					</script>
<!--
EOT;
if(R_P==D_P){print <<<EOT
-->
					<script language="JavaScript" src="data/bbscache/face.js"></script>
<!--
EOT;
}else{
$facedb=readover(D_P."data/bbscache/face.js");
print <<<EOT
-->
					<script language="JavaScript">
					$facedb
					</script>
<!--
EOT;
}print <<<EOT
-->					
				<td>
<!--
EOT;
require_once PrintEot('editor');
print <<<EOT
-->
					<div style="margin:4px 0 2px"><input type="checkbox" name="ifsave" value="Y" />保存到发件箱中
					</div>
				</td>
			</tr>
		</table></div>
		<script language="JavaScript" src="js/post.js"></script></td>
		<div class="tac" style=" padding:1em">
			按 Ctrl+Enter 直接提交   
			<input class="btn" type="submit" value="提 交" name="Submit" />
		</div>
	</form><br />
<!--
EOT;
}print <<<EOT
-->
</div></div></div></div>
<script language="JavaScript">
cnt = 0;
function checkCnt() {
	document.FORM.Submit.disabled = true;
	cnt++;
	if (cnt != 1) {
		alert('Submission Processing. Please Wait');
		return false;
	}
}
function checkset() {
	if (confirm("将删除收件箱和发件箱内所有消息，请确认！")) {
		window.location=('$B_url/message.php?action=clear&verify=$verifyhash');
	} else {
		return false;
	}
}
</script>
</div>
<!--
EOT;
?>-->