<!--#include file="user_top.asp"-->
<!--#include file="inc/class_blog.asp"-->
<div id="main">
  <div class="submenu">
  	<div class="side_c1 side11"></div>
    <div class="side_c2 side21"></div>
	<div class="submenu_content" style="display:block;">
		&#8226; <a href="user_pmmanage.asp">收件箱</a>
		&#8226; <a href="user_pmmanage.asp?usersearch=1">发件箱</a>
		&#8226; <a href="javascript:openScript('user_pm.asp?action=send',450,400)">发送短信</a>
	</div>
  </div>
  <div class="content">
  	<div class="content_top">
		  	<div class="side_d1 side11"></div>
		    <div class="side_d2 side21"></div>
			短消息管理
	</div>
	
    <div class="content_body">
<%const MaxPerPage=20
dim strFileName,totalPut,TotalPages
dim rs,sql,blog
dim id,usersearch,action
usersearch=trim(request("usersearch"))
action=trim(request("action"))
id=oblog.filt_badstr(trim(Request("id")))
if usersearch="" then
	usersearch=0
else
	usersearch=clng(usersearch)
end if
strFileName="user_pmmanage.asp?usersearch=" & usersearch
if request("page")<>"" then
    currentPage=cint(request("page"))
else
	currentPage=1
end if
select case action
	case "add"
	call add()
	case "saveadd" 
	call saveadd()
	case "del" 
	call del()
	case else	
	call main()
end select
set rs=nothing
set blog=nothing
%>
	</div>
	
    <div class="content_bot">
		  	<div class="side_e1 side12"></div>
   			<div class="side_e2 side22"></div>
 	</div>
	
  </div>
</div>  
  
  
  <div id="bottom"><%=oblog.user_copyright%></div>

</body>
</html>
<%
sub main()
%>
<style type="text/css">
<!--
	#list ul{ width: 100%} 
	#list ul li.t1 { width: 50px} 
	#list ul li.t2 { width: 50px} 
	#list ul li.t3 { width: 160px} 
	#list ul li.t4 { width: 80px} 
	#list ul li.t5 { width: 80px} 
	#list ul li.t6 { width: 100px} 
	#list ul li.t7 { width: 50px} 
-->
</style>

<%
	dim strGuide,ssql
	ssql="id,sender,incept,topic,addtime,isguest,isreaded"
	strGuide="<h1>当前选择&nbsp;&gt;&gt;&nbsp;"
	select case usersearch
		case 0
			sql="select "&ssql&" from oblog_pm where incept='"&oblog.logined_uname&"' and delr=0 order by id desc"
			strGuide=strGuide & "收件箱"
		case 1
			sql="select "&ssql&" from oblog_pm where sender='"&oblog.logined_uname&"' and dels=0 order by id desc"
			strGuide=strGuide & "发件箱"
		case else
	end select
	Set rs=Server.CreateObject("Adodb.RecordSet")
	'response.Write(sql)
	rs.Open sql,Conn,1,1
  	if rs.eof and rs.bof then
		strGuide=strGuide & " (共有0条短消息)</h1><div id=""list""></div>"
		response.write strGuide
	else
    	totalPut=rs.recordcount
		strGuide=strGuide & " (共有" & totalPut & "条短消息)</h1><div id=""list"">"
		response.write strGuide
		if currentpage<1 then
       		currentpage=1
    	end if
    	if (currentpage-1)*MaxPerPage>totalput then
	   		if (totalPut mod MaxPerPage)=0 then
	     		currentpage= totalPut \ MaxPerPage
		  	else
		      	currentpage= totalPut \ MaxPerPage + 1
	   		end if
    	end if
	    if currentPage=1 then
        	showContent
        	response.write oblog.showpage(strFileName,totalput,MaxPerPage,true,true,"条短消息")
   	 	else
   	     	if (currentPage-1)*MaxPerPage<totalPut then
         	   	rs.move  (currentPage-1)*MaxPerPage
         		dim bookmark
           		bookmark=rs.bookmark
            	showContent
            	response.write oblog.showpage(strFileName,totalput,MaxPerPage,true,true,"条短消息")
        	else
	        	currentPage=1
           		showContent
           		response.write oblog.showpage(strFileName,totalput,MaxPerPage,true,true,"条短消息")
	    	end if
		end if
	end if
	rs.Close
	if totalPut>oblog.setup(53,0) then
			'oblog.execute("update oblog_pm set delr=1 where id not in (select top "&oblog.setup(53,0)&" id from  oblog_pm where incept='"&oblog.logined_uname&"' order by id desc ) and incept='"&oblog.logined_uname&"'")
		oblog.execute("delete from oblog_pm where delr=1 and dels=1")
		Response.Write"<script language=JavaScript>alert(""您的信箱已满，请及时清理！"");</script>"
	end if
	set rs=Nothing
end sub

sub showContent()
   	dim i,freen
    i=0
	freen=oblog.setup(53,0)-totalPut
%>
	<div class="list_left">
	&nbsp;<img align=absmiddle src='images/touming.gif' border=1 width='10' height='10' style='background:#cccccc;'>&nbsp;已有短信:<%=totalPut%><br />
	&nbsp;<img align=absmiddle src='images/touming.gif' border=1 width='10' height='10' style='background:#ffffff;'>&nbsp;空余条数:<%=freen%><br />
	<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="150" height="150">
	<param name=movie value="images/chart.swf?in6=<%=int((freen/oblog.setup(53,0))*100)%>&in6=<%=int((totalPut/oblog.setup(53,0))*100)%>">
	<param name=quality value=high>
	<param name="wmode" value="transparent">
	</object>
	</div>
	<div class="list_right">
	<form name="myform" method="Post" action="user_pmmanage.asp?usersearch=<%=usersearch%>" onSubmit="return confirm('确定要执行选定的操作吗？');">
	<ul class="list_top">
	<li class="t1">选中</li>
	<%if usersearch=0 then%>
		<li class="t2">状态</li>
	<%end if%>
	<li class="t3">标题</li>
	<li class="t4">收件人</li>
	<li class="t5">发件人</li>
	<li class="t6">发送时间</li>
	<li class="t7">操作</li>
	</ul>
	<%do while not rs.eof %>
	<ul class="list_content" onMouseOver="fSetBg(this)" onMouseOut="fReBg(this)">
	<li class="t1"><input name='id' type='checkbox' onClick="unselectall()" id="id" value='<%=cstr(rs("id"))%>' /></li>
<%if usersearch=0 then%>
	<li class="t2"><%if rs("isreaded")=1 then response.Write("已读") else response.Write("<font color=red>未读</font>")%></li>
<%end if%>
	<li class="t3"><a href="javascript:openScript('user_pm.asp?action=read<%=usersearch%>&id=<%=rs("id")%>',450,380)"><%=oblog.filt_html(rs("topic"))%></a> </li>
	<li class="t4"><%=oblog.filt_html(rs("incept"))%></li>
	<li class="t5"><%=oblog.filt_html(rs("sender"))%></li>
	<li class="t6" title="<%=rs("addtime")%>"><%if rs("addtime")<>"" then response.write formatdatetime(rs("addtime"),2) else response.write "&nbsp;" %> </li>
	<li class="t7">
<%response.write "<a href='user_pmmanage.asp?action=del&id=" & rs("id") &"&usersearch="&usersearch&"' onClick='return confirm(""确定要删除吗？"");'>删除</a>"%> </li>
	</ul>
<%
	i=i+1
	if i>=MaxPerPage then exit do
	rs.movenext
loop
%>
	<ul class="list_bot"><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox" />全选
	<input name="action"  type="hidden" value="del" />
	<input type="submit" name="Submit" value="删除" />
	</ul>
	</form>
	</div>
</div>
<%
end sub


sub del()
	if id="" then
		oblog.adderrstr( "错误：请指定要删除的对象！")
		oblog.showusererr
		exit sub
	end if
	if instr(id,",")>0 then
		dim n,i
		id=FilterIDs(id)
		n=split(id,",")
		for i=0 to ubound(n)
			delone(n(i))
		next
	else
		delone(id)
	end if
	set rs=nothing
	oblog.showok "删除短消息成功！",""
end sub

sub delone(id)
	id=clng(id)
	select case usersearch
		case 0
		sql="update oblog_pm set delr=1 where id=" & clng(id)&" and incept='"&oblog.logined_uname&"'"
		case 1
		sql="update oblog_pm set dels=1 where id=" & clng(id)&" and sender='"&oblog.logined_uname&"'"
	end select	
	oblog.execute(sql)
end sub
%>