<!--#INCLUDE FILE="conn.asp" -->
<!--#include file="admin_Checkuser.asp"-->
<HTML><HEAD><title><%=StrVar(1)%>--管理页面</title>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<!--#include file="inc/admin_main.css"-->
</HEAD>
<BODY leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
<%
if  not sysadmin or session("adminlogin")<>"0K" Then
	Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用，请<a href=admin_index.asp target=_top>登陆</a>后进入。"
	Call Error("Information",ErrMsg)
	else
		call main()
		call endconnection()
end if
	sub main()
%>
<table cellpadding=5 cellspacing=1 border=0 width=90% Class=TableBorder align=center>
  <tr>
	<th>欢迎<b><%=membername%></b>进入管理页面</th>
</tr></table>
<BR>
<%
select case request("action")
  case "delbbs"
	call delbbs()
  case "deluserbbs"
    call deluserbbs()
  case else
	call boarddelbbs()
end select
%>
<%
end sub


sub boarddelbbs()

dim rs,sql

	set rs=server.createobject("adodb.recordset")
	sql="select * from bbs order by boardid desc"
	rs.open sql,conn,1,1
	
	 if rs.bof and rs.eof then
	   errmsg="<br><li>暂时还没有任何版面."
	   response.write errmsg
	   exit sub
	end if
%>
<form method="POST" action="" name=boarddelbbs>
  <input type=hidden name=action value=delbbs>
  <table width=90% cellspacing=1  cellpadding=5 align=center Class=TableBorder>
  <tr>
  <th colspan=2><b>删除指定日期内帖子(本功能不扣除用户帖子数和积分)</b></th>
  </tr>
  <tr>
  <td width="40%" Class=forumrowhighlight><font color="#000000">删除多少天前的帖子(填写数字)</font></td>
  <td width="60%" Class=forumrowhighlight> 
  <input type="text" name="datenum" size="30" value="0">
  </td>
  </tr>
  <tr>
  <td width="40%" class=forumrow><font color="#000000">版面名称</font></td>
  <td width="60%" class=forumrow> 
  <select name="boardid" size="1">
  <%do while not rs.eof%>
  <option value=<%=rs("boardid")%>><%=rs("boardname")%></option>
  <%rs.movenext
  loop
  %>
  </select>
  　　　　　　　　　
  <input type="submit" name="Submit" value="提 交">
  </td>
  </tr>
  </table>
</form>
<br>
<form name="form1" method="post" action="">
  <input type=hidden name=action value=deluserbbs>
  <table width=90% cellspacing=1  cellpadding=5 align=center Class=TableBorder>
  <tr>
  <th colspan=2><b>删除某用户的所有帖子</b> </th>
  </tr>
  <tr>
  <td width="40%" height="33" Class=forumrowhighlight>请输入用户名</td>
  <td width="60%" height="33" Class=forumrowhighlight> 
  <input type="text" name="userid" size="30">
  </td>
  </tr>
  <tr>
  <td width="40%" class=forumrow><font color="#000000">版面名称</font></td>
  <td width="60%" class=forumrow> 
  <select name="boardid" size="1">
    <%rs.movefirst
	do while not rs.eof%>
    <option value=<%=rs("boardid")%>><%=rs("boardname")%></option>
    <%rs.movenext
  loop
  %>
  </select>
  　　　　　　　　　
  <input type="submit" name="Submit2" value="提 交">
  </td>
  </tr>
  </table>
</form>
<%
rs.close
set rs=nothing
end sub

sub delbbs()		
	
dim boardid,datenum,bbsnum,topicnum,postnum
boardid=clng(request.form("boardid"))
datenum=clng(request.form("datenum"))

set rs=server.createobject("adodb.recordset")
sql="select count(postid) from topic where datediff(day,posttime,getdate())>"&datenum&" and boardid="&boardid
rs.open sql,conn,1,1

topicnum=rs(0)

dim rs1
set rs1=server.createobject("adodb.recordset")
sql="select count(postid) from [reply] where datediff(day,posttime,getdate())>"&datenum&" and boardid="&boardid
rs1.open sql,conn,1,1

postnum=rs1(0)
bbsnum=postnum+topicnum

sql="update bbs set boardbbsnum=boardbbsnum-"&bbsnum&",topicnum=topicnum-"&topicnum&",postnum=postnum-"&postnum&" where boardid="&boardid
conn.execute(sql)

sql="update [config] set bbsnum=bbsnum-"&bbsnum&",topicnum=topicnum-"&topicnum
'response.write sql
'response.end
conn.execute(sql)

sql="delete * from topic where datediff(day,posttime,getdate())>"&datenum&" and boardid="&boardid
conn.execute(sql)
sql="delete * from reply where datediff(day,posttime,getdate())>"&datenum&" and boardid="&boardid
conn.execute(sql)

rs.close
set rs=nothing

response.write ("<script language=javascript>alert('批量删除贴子成功！');document.location.href='admin_boarddelbbs.asp';</script>")

end sub

sub deluserbbs()

dim boardid,userid,bbsnum,topicnum,postnum

userid=trim(request.form("userid"))
boardid=clng(request.form("boardid"))
if userid="" then
response.write ("<script language=javascript>alert('请输入用户名！');document.location.href='admin_boarddelbbs.asp';</script>")
response.End
end if
set rs=server.createobject("adodb.recordset")
sql="select count(postid) from topic where boardid="&boardid&" and userid='"&userid&"'"

rs.open sql,conn,1,1

topicnum=rs(0)

dim rs1
set rs1=server.createobject("adodb.recordset")
sql="select count(postid) from topic where boardid="&boardid&" and userid='"&userid&"'"
rs1.open sql,conn,1,1

postnum=rs1(0)
bbsnum=topicnum+postnum

rs.close
set rs=nothing
rs1.close
set rs1=nothing

sql="update bbs set boardbbsnum=boardbbsnum-"&bbsnum&",topicnum=topicnum-"&topicnum&",postnum=postnum-"&postnum&" where boardid="&boardid
conn.execute(sql)

sql="update [config] set bbsnum=bbsnum-"&bbsnum&",topicnum=topicnum-"&topicnum
conn.execute(sql)

sql="delete * from topic where userid='"&userid&"' and boardid="&boardid
conn.execute(sql)

sql="delete * from reply where userid='"&userid&"' and boardid="&boardid
conn.execute(sql)

response.write ("<script language=javascript>alert('批量删除某用户贴子成功！');document.location.href='admin_boarddelbbs.asp';</script>")

end sub%>