<!--#INCLUDE FILE="setup.asp" -->
<!--#include file=checkuser.asp-->
<html><head>
<title><%=StrVar(1)%>--管理页面</title>
<link href="css.asp" rel="stylesheet" type="text/css">
<!--#include file=theme.css-->
<body class=adminbody>
<%
if  not sysadmin or session("adminlogin")<>"0K" Then
	Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用，请<a href=superindex.asp target=_top>登陆</a>后进入。"
	Call Error("Information",ErrMsg)
Else%>

	<table cellpadding=5 cellspacing=1 border=0 width=100% Class=TableBorder align=center>
			<tr>
			<th>欢迎<b><%=membername%></b>进入管理页面</th>
			</tr>
	</table>
	<%
	if request("action")="DelNoReply" then
		call DelNoReply()
	elseif request("action")="DelExpire" then
		call delexpire()
	elseif request("action")="DelUser" then
		call DelUser()
	else
		call ShowOperation()
	end if

end if

call endconnection()

sub DelUser()

	dim sql,rs
	dim i
	dim SpecifiedUser

	SpecifiedUser=replace(trim(request("userid")),"'","")
	ExpiringDate=cint(request("ExpiringDate"))
	item=cint(request("item"))

	if ExpiringDate=0 then wherecond="" else wherecond=" and datediff('d',PostTime,date())<="&ExpiringDate
	wherecond=" where userid='"&SpecifiedUser&"'"&wherecond
	if item=0 or item=2 then
	sql="select postid from topic"&wherecond
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
	do until rs.eof
		sql="delete from reply where topicid="&rs(0)
		conn.execute(sql)
		rs.movenext
		i=i+1
	loop
	rs.close
	sql="delete from topic"&wherecond
	conn.execute(sql)
	end if

	if item=1 or item=2 then

	set rs=conn.execute("select count(*) from reply"&wherecond)
	i=i+rs(0)
	set rs=nothing
	sql="delete from reply"&wherecond
	conn.execute(sql)
	end if
	
	if i<>0 then
		response.write "<br><br><center>成功删除"&i&"个贴子，请返回！</center>"
	else
		response.write "<br><br><center>没有找到符合相关条件的帖子，请返回！</center>"
	end if	

end sub



sub DelExpire()

	dim sql,rs
	dim i
	i=0
	ExpiringDate=cint(request("ExpiringDate"))
	ExpiringDate=ExpiringDate*30
	sql="select postid from topic where locked=false and datediff('d',LastTime,date())>="&ExpiringDate
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
	do until rs.eof
		sql="delete from reply where topicid="&rs(0)
		conn.execute(sql)
		rs.movenext
		i=i+1
	loop
	rs.close:set rs=nothing
	sql="delete from topic where locked=false and datediff('d',LastTime,date())>="&ExpiringDate
	conn.execute(sql)
	
	if i<>0 then
		response.write "<br><br><center>成功删除"&i&"个主题，请返回！</center>"
	else
		response.write "<br><br><center>没有找到符合相关条件的主题，请返回！</center>"
	end if	


end sub

sub DelNoReply()

	dim sql,rs
	dim i
	i=0
	ExpiringDate=cint(request("ExpiringDate"))
	if ExpiringDate<10 then ExpiringDate=ExpiringDate*30
	sql="select postid from topic where locked=false and replys=0 and datediff('d',PostTime,date())>="&ExpiringDate
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
	do until rs.eof
		sql="delete from reply where topicid="&rs(0)
		conn.execute(sql)
		rs.movenext
		i=i+1
	loop
	rs.close:set rs=nothing
	sql="delete from topic where locked=false and replys=0 and datediff('d',PostTime,date())>="&ExpiringDate
	conn.execute(sql)
	
	if i<>0 then
		response.write "<br><br><center>成功删除"&i&"个主题，请返回！</center>"
	else
		response.write "<br><br><center>没有找到符合相关条件的主题，请返回！</center>"
	end if	


end sub


sub ShowOperation()%>

<center>
<table border=0 width=90%><tr><td class=mp><BR><B><a name=top>说明</a></B>：<br>
(1)删除的帖子不可恢复,请谨慎操作！<br>
(2)在零回复主题管理操作时，建议先用数据维护功能重新统计主题的回帖数，否则有可能引起数据丢失！<br>
(3)在特定用户帖子管理后建议用数据维护功能重新统计主题的回帖数.
<BR><BR></td></tr></table>

<BR><table border=0 cellspacing=1 cellpadding=5 Class=TableBorder width=90%>
<tr Class=DarkTableBody><th>零回复主题管理(不对用户进行积分操作)</th></tr>
<tr Class=LightTableBody align=left height=40><form method="POST" action="sysadm_forum.asp">
<td>&nbsp;&nbsp;删除超过指定日期没有回复的主题帖子(不包括已被锁定的主题)&nbsp;<Select name="ExpiringDate" size=1>
	<option value=6>半年以上</option>
	<option value=5>5个月</option>
	<option value=4>4个月</option>
	<option value=3>3个月</option>
	<option value=2>2个月</option>
	<option value=1>30天</option>
	<option value=20>20天</option>
	<option value=10>10天</option>
	</Select>
<input type=hidden name=action value=DelNoReply><input type=submit value="执行操作" onclick="return confirm('您确认要执行此项操作吗？')" class=button></td></form></tr></table>
<BR>
<table border=0 cellspacing=1 cellpadding=5 Class=TableBorder width=90%>
<tr Class=DarkTableBody><th>过期帖子管理(不对用户进行积分操作)</th></tr>
<tr Class=LightTableBody align=left height=40>
<form method="POST" action="sysadm_forum.asp">
<td>&nbsp;&nbsp;删除最后回复在指定日期前的主题及其回复帖子(不包括已被锁定的主题)&nbsp;<Select name="ExpiringDate" size=1>
	<option value=36>三年</option>
	<option value=24>两年</option>
	<option value=12>一年</option>
	<option value=6>半年</option>
	<option value=5>5个月</option>
	<option value=4>4个月</option>
	<option value=3>3个月</option>
	<option value=2>2个月</option>
	<option value=1>一个月</option>
	</Select>
<input type=hidden name=action value=DelExpire><input type=submit value="执行操作" onclick="return confirm('您确认要执行此项操作吗？')" class=button></td></form></tr></table>
<BR>
<table border=0 cellspacing=1 cellpadding=5 Class=TableBorder width=90%>
<tr Class=DarkTableBody><th>特定用户帖子管理(不对用户进行积分操作)</th></tr>
<tr Class=LightTableBody align=left height=40>
<form method="POST" action="sysadm_forum.asp">
<td>&nbsp;&nbsp;删除用户&nbsp;<input type=text name=userid>&nbsp;在&nbsp;<Select name="ExpiringDate" size=1>
	<option value=1>1天</option>
	<option value=2>2天</option>
	<option value=3>3天</option>
	<option value=4>4天</option>
	<option value=5>5天</option>
	<option value=6>6天</option>
	<option value=7>一星期</option>
	<option value=15>半个月</option>
	<option value=30>一个月</option>
	<option value=24>两个月</option>
	<option value=182>半年</option>
	<option value=0>注册以来</option>
	</Select>&nbsp;内发表的&nbsp;<Select name="item" size=1>
	<option value=0>主题帖子</option>
	<option value=1>回复帖子</option>
	<option value=2>主题和回复帖子</option>
	</Select>
<input type=hidden name=action value=DelUser><input type=submit value="执行操作" onclick="return confirm('您确认要执行此项操作吗？')" class=button></td></form></tr>

</table><BR><BR>

<%end sub%>