%@ LANGUAGE="VBSCRIPT" %>
<%
stats="帖子管理"
dim boardid
dim rootid
dim id
dim Lasttopic,Lastpost
dim lastrootid,lastpostuser
if founduser=false then
founderr=true
Errmsg=Errmsg+"
"+"
请登陆后进行操作。"
end if
if request("boardid")="" then
founderr=true
Errmsg=Errmsg+"
"+"请指定论坛版面。"
elseif not isInteger(request("boardid")) then
founderr=true
Errmsg=Errmsg+"
"+"非法的版面参数。"
else
boardid=request("boardid")
if chkboardmaster(boardid)=false then
founderr=true
Errmsg=Errmsg+"
"+"您不是该版面斑竹或者系统管理员。"
end if
end if
if request("id")="" then
founderr=true
Errmsg=Errmsg+"
"+"请指定相关贴子。"
elseif not isInteger(request("id")) then
founderr=true
Errmsg=Errmsg+"
"+"非法的贴子参数。"
else
id=request("id")
end if
if request("rootid")="" then
founderr=true
Errmsg=Errmsg+"
"+"请指定相关贴子。"
elseif not isInteger(request("rootid")) then
founderr=true
Errmsg=Errmsg+"
"+"非法的贴子参数。"
else
rootid=request("rootid")
end if
call nav()
call headline(1)
if founderr=true then
call Error()
else
set rs=server.createobject("adodb.recordset")
if request("action")="lock" then
call lock()
elseif request("action")="unlock" then
call unlock()
elseif request("action")="delete" then
call delete()
elseif request("action")="move" then
call move()
elseif request("action")="copy" then
call copy()
elseif request("action")="istop" then
call istop()
elseif request("action")="notop" then
call notop()
elseif request("action")="dele" then
call dele()
elseif request("action")="isbest" then
call isbest()
elseif request("action")="nobest" then
call nobest()
else
founderr=true
Errmsg=Errmsg+"
"+"请选择相应操作。"
end if
if founderr=true then
call error()
end if
set rs=nothing
call endline()
sub lock()
sql="update bbs1 set locktopic=1 where boardid="&boardid&" and rootid="&cstr(rootid)
conn.Execute(sql)
call success()
end sub
sub unlock()
sql="update bbs1 set locktopic=0 where boardid="&boardid&" and rootid="&cstr(rootid)
conn.Execute(sql)
call success()
end sub
sub istop()
sql="update bbs1 set istop=1 where boardid="&boardid&" and rootid="&cstr(rootid)
conn.Execute(sql)
call success()
end sub
sub notop()
sql="update bbs1 set istop=0 where boardid="&boardid&" and rootid="&cstr(rootid)
conn.Execute(sql)
call success()
end sub
sub isbest()
sql="update bbs1 set isbest=1 where boardid="&boardid&" and announceid="&cstr(id)
conn.Execute(sql)
call success()
end sub
sub nobest()
sql="update bbs1 set isbest=0 where boardid="&boardid&" and announceid="&cstr(id)
conn.Execute(sql)
call success()
end sub
sub dele()
dim NewAnnounceNum,lastpostime
sql="delete from bbs1 where boardid="&boardid&" and ParentID<>0 and announceid="&cstr(id)
conn.Execute(sql)
sql="select count(announceid) from bbs1 where boardid="&boardid
set rs=conn.Execute(sql)
NewAnnounceNum=rs(0)
sql="select Max(announceid) from bbs1 where rootid="&rootid&" and boardid="&boardid
set rs=conn.Execute(sql)
LastPostime=rs(0)
call LastCount(boardid)
sql="update board set lastbbsnum="&NewAnnounceNum&",TodayNum=TodayNum-1,lasttopic='"&LastTopic&"',lastrootid='"&LastRootid&"',lastposttime='"&LastPost&"',lastpostuser='"&LastPostUser&"' where boardid="&boardid
conn.execute(sql)
sql="update bbs1 set times="&LastPostime&" where rootid="&rootid&" and boardid="&boardid
conn.execute(sql)
sql="update bbs1 set child=child-1 where announceid="&rootid&" and boardid="&boardid
conn.execute(sql)
sql="update [user] set article=article-1,userWealth=userWealth-"&wealthDel&",userEP=userEP-"&epDel&",userCP=userCP-"&cpDel&" where username='"&request("username")&"'"
'response.write sql
conn.execute (sql)
sql="update config set TodayNum=TodayNum-1,BbsNum=BbsNum-1"
conn.execute(sql)
call success()
end sub
sub delete()
dim NewAnnounceNum,NewTopicNum
set rs=conn.execute("select username from bbs1 where boardid="&boardid&" and rootid="&rootid)
do while not rs.eof
sql="update [user] set article=article-1,userWealth=userWealth-"&wealthDel&",userEP=userEP-"&epDel&" where username='"&rs(0)&"'"
conn.execute (sql)
rs.movenext
loop
set rs=nothing
sql="delete from bbs1 where boardid="&boardid&" and rootid="&cstr(rootid)
conn.Execute(sql)
sql="select count(announceid) from bbs1 where boardid="&boardid
set rs=conn.Execute(sql)
NewAnnounceNum=rs(0)
sql="select count(announceid) from bbs1 where ParentID=0 and boardid="&boardid
set rs=conn.Execute(sql)
NewTopicNum=rs(0)
call LastCount(boardid)
sql="update board set lastbbsnum="&NewAnnounceNum&",lasttopicnum="&NewTopicNum&",lasttopic='"&LastTopic&"',lastrootid='"&LastRootid&"',lastposttime='"&LastPost&"',lastpostuser='"&LastPostUser&"' where boardid="&boardid
conn.execute(sql)
call success()
end sub
sub move()
dim newboardid
if request("checked")="yes" then
if request("boardid")=request("newboardid") then
founderr=true
Errmsg=Errmsg+"
"+"不能在相同版面内进行转移操作。"
elseif not isInteger(request("newboardid")) then
founderr=true
Errmsg=Errmsg+"
"+"非法的版面参数。"
exit sub
else
newboardid=request("newboardid")
sql="select boardid,announceid,Parentid from bbs1 where announceid="&id&" and boardid="&cstr(boardid)
rs.open sql,conn,1,1
if rs.eof and rs.bof then
founderr=true
Errmsg=Errmsg+"
"+"您选择的贴子并不存在。"
else
if rs("Parentid")<>0 then
founderr=true
Errmsg=Errmsg+"
"+"您必须选择一个主题,而不是贴子。"
end if
end if
rs.close
end if
if founderr=false then
if request("leavemessage")="yes" then
'ON ERROR RESUME NEXT
elseif request("leavemessage")="no" then
dim newtopic
sql="select topic from bbs1 where announceid="&rootid
set rs=conn.execute(sql)
newtopic=rs("topic") & "-->" & membername & "转移"
sql="update bbs1 set topic='"&newtopic&"' where announceid="&rootid
conn.execute(sql)
sql="update bbs1 set boardid="&newboardid&" where rootid="&rootid
conn.Execute(sql)
'更新论坛贴子数据
dim NewAnnounceNum,NewTopicNum
sql="select count(announceid) from bbs1 where boardid="&boardid
set rs=conn.Execute(sql)
NewAnnounceNum=rs(0)
sql="select count(announceid) from bbs1 where ParentID=0 and boardid="&boardid
set rs=conn.Execute(sql)
NewTopicNum=rs(0)
sql="update board set lastbbsnum="&NewAnnounceNum&",lasttopicnum="&NewTopicNum&" where boardid="&boardid
conn.execute(sql)
dim MoveAnnounceNum,MoveTopicNum
sql="select count(announceid) from bbs1 where boardid="&newboardid
set rs=conn.Execute(sql)
MoveAnnounceNum=rs(0)
sql="select count(announceid) from bbs1 where ParentID=0 and boardid="&newboardid
set rs=conn.Execute(sql)
MoveTopicNum=rs(0)
sql="update board set lastbbsnum="&MoveAnnounceNum&",lasttopicnum="&MoveTopicNum&" where boardid="&newboardid
conn.execute(sql)
'更新论坛数据结束
call success()
else
founderr=true
Errmsg=Errmsg+"
"+"请选择相应操作。"
end if
end if
else
%>
<%
end if
end sub
sub copy()
dim newboardid
if request("checked")="yes" then
if request("boardid")=request("newboardid") then
founderr=true
Errmsg=Errmsg+"
"+"不能在相同版面内进行转移操作。"
elseif not isInteger(request("newboardid")) then
founderr=true
Errmsg=Errmsg+"
"+"非法的版面参数。"
exit sub
else
newboardid=request("newboardid")
sql="select boardid,announceid,Parentid from bbs1 where announceid="&id&" and boardid="&cstr(boardid)
rs.open sql,conn,1,1
if rs.eof and rs.bof then
founderr=true
Errmsg=Errmsg+"
"+"您选择的贴子并不存在。"
end if
rs.close
end if
if founderr=false then
'ON ERROR RESUME NEXT
dim newtopic,username,body,dateandtime,length,ip,Expression
dim announceid
sql="select * from bbs1 where announceid="&id
set rs=conn.execute(sql)
newtopic=rs("topic") & "-->" & membername & "添加"
username=rs("username")
body=rs("body")
DateAndTime=rs("DateAndTime")
length=rs("length")
ip=rs("ip")
Expression=rs("Expression")
rs.close
sql="select * from bbs1"
rs.open sql,conn,1,3
rs.AddNew
rs("BoardID")=newboardID
rs("ParentID")=0
rs("Child")=0
rs("UserName")=UserName
rs("Topic")=newTopic
rs("Body")=Body
rs("DateAndTime")=DateAndTime
rs("hits")=0
rs("length")=length
rs("rootID")=0
rs("layer")=1
rs("orders")=0
rs("ip")=ip
rs("Expression")=Expression
rs("locktopic")=0
rs("signflag")=0
rs("emailflag")=0
rs("times")=0
rs("isvote")=0
rs("istop")=0
rs("isbest")=0
rs.Update
rs.MoveLast
announceid=rs("AnnounceID")
rs("RootID")= announceid
rs("Times")= announceid
rs.Update
rs.close
'更新论坛贴子数据
sql="update board set lastbbsnum=lastbbsnum+1,lasttopicnum=lasttopicnum+1,lastpostuser='"&username&"',lastposttime='"&DateAndTime&"' where boardid="&newboardid
conn.execute(sql)
'更新论坛数据结束
call success()
end if
else
%>
<%
end if
end sub
sub success()
%>
<%
end sub
'指定论坛今日帖子
function boardtoday(boardid)
tmprs=conn.execute("Select count(announceid) from bbs1 Where datediff(d,dateandtime,Now())=0 and boardid="&boardid)
boardtoday=tmprs(0)
set tmprs=nothing
if isnull(boardtoday) then boardtoday=0
end function
'所有论坛今日帖子
function alltodays()
tmprs=conn.execute("Select count(announceid) from bbs1 Where datediff(d,dateandtime,Now())")
alltodays=tmprs(0)
set tmprs=nothing
if isnull(alltodays) then alltodays=0
end function
'论坛最后回复信息
sub LastCount(boardid)
set rs=conn.execute("select top 1 topic,body,rootid,dateandtime,username from bbs1 where boardid="&boardid&" order by announceid desc")
if not(rs.eof and rs.bof) then
Lasttopic=rs(0)
body=rs(1)
LastRootid=rs(2)
LastPost=rs(3)
LastPostUser=rs(4)
else
LastTopic="无"
LastRootid=0
LastPost=now()
LastPostUser="无"
end if
if Lasttopic="" or isnull(Lasttopic) then LastTopic=left(body,20)
set rs=nothing
end sub
end if
%>