<!--#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()
%><BR>
<table cellpadding=5 cellspacing=1 border=0 width=90% Class=TableBorder align=center>
  <tr>
	<th>欢迎<b><%=membername%></b>进入管理页面</th>
</tr></table>
<%
select case request("action")
  case "movebbs"
	call movebbs()
  case "moveuserbbs"
    call moveuserbbs()
  case else
	call boardmovebbs()
end select
%>
<%
end sub
sub boardmovebbs()
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=movebbs>
  <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>移动多少天前的帖子(填写数字)</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="boardidfirst" size="1">
    <%do while not rs.eof%>
    <option value=<%=rs("boardid")%>><%=rs("boardname")%></option>
    <%rs.movenext
  loop
  %>
  </select>
  </td>
  </tr>
  <tr>
  <td width="40%" Class=forumrowhighlight><font color="#000000">目标版面名称</font></td>
  <td width="60%" Class=forumrowhighlight> 
  <select name="boardidlast" size="1">
    <%rs.movefirst
	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=moveuserbbs>
  <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="boardidfirst" size="1">
    <%rs.movefirst
	do while not rs.eof%>
    <option value=<%=rs("boardid")%>><%=rs("boardname")%></option>
    <%rs.movenext
  loop
  %>
  </select>
  </td>
  </tr>
  <tr >
  <td width="40%" Class=forumrowhighlight><font color="#000000">目标版面名称</font></td>
  <td width="60%" Class=forumrowhighlight> 
  <select name="boardidlast" 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 movebbs()		
	
dim boardidfirst,boardidlast,datenum,bbsnum,topicnum,postnum
boardidfirst=clng(request.form("boardidfirst"))
boardidlast=clng(request.form("boardidlast"))
datenum=clng(request.form("datenum"))

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

postnum=rs(0)   '取出要移动原版面的回复数

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

topicnum=rs1(0)    '取出要移动原版面的主题数
bbsnum=postnum+topicnum   '获得要移动原版面的帖子数

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

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

sql="update topic set boardid="&boardidlast&" where boardid="&boardidfirst&" and datediff(day,posttime,getdate())>"&datenum
conn.execute(sql)

sql="update reply set boardid="&boardidlast&" where boardid="&boardidfirst&" and datediff(day,posttime,getdate())>"&datenum
conn.execute(sql)

rs.close
set rs=nothing

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

end sub

sub moveuserbbs()

dim boardidfirst,boardidlast,userid,bbsnum,topicnum,postnum

userid=trim(request.form("userid"))
boardidfirst=clng(request.form("boardidfirst"))
boardidlast=clng(request.form("boardidlast"))
if userid="" then
response.write ("<script language=javascript>alert('请输入用户名！');document.location.href='admin_boardmovebbs.asp';</script>")
response.End
end if
set rs=server.createobject("adodb.recordset")
sql="select count(postid) from topic where boardid="&boardidfirst&" 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 reply where boardid="&boardidlast&" and userid='"&userid&"'"
rs1.open sql,conn,1,1

postnum=rs1(0) '回复数
bbsnum=postnum+topicnum  '帖子数

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="&boardidfirst
conn.execute(sql)

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

sql="update topic set boardid="&boardidlast&" where userid='"&userid&"' and boardid="&boardidfirst
conn.execute(sql)

sql="update reply set boardid="&boardidlast&" where userid='"&userid&"' and boardid="&boardidfirst
conn.execute(sql)

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

end sub%>


