📄 admin_board.asp
字号:
'假如更改了所属论坛
'需要更新其原来所属版面信息,包括深度、父级ID、版面数、排序、继承版主等数据
'需要更新当前所属版面信息
'继承版主数据需要另写函数进行更新--取消,在前台可用boardid in parentstr来获得
dim k,nParentStr,mParentStr
dim ParentSql,boardcount
if clng(parentid)<>clng(request("class")) and not (iparentid=0 and cint(request("class"))=0) then
'如果原来不是一级分类改成一级分类
if iparentid>0 and cint(request("class"))=0 then
'更新当前版面数据
Dvbbs.Execute("update dv_board set depth=0,orders=0,rootid="&maxrootid&",parentid=0,parentstr='0' where boardid="&newboardid)
ParentStr=ParentStr & ","
set rs=Dvbbs.Execute("select count(*) from dv_board where ParentStr like '%"&ParentStr&"%'")
boardcount=rs(0)
if isnull(boardcount) then
boardcount=1
else
boardcount=boardcount+1
end if
'更新其原来所属论坛版面数
Dvbbs.Execute("update dv_board set child=child-"&boardcount&" where boardid="&iparentid)
'更新其原来所属论坛数据,排序相当于剪枝而不需考虑
for i=1 to depth
'得到其父类的父类的版面ID
set rs=Dvbbs.Execute("select parentid from dv_board where boardid="&iparentid)
if not (rs.eof and rs.bof) then
iparentid=rs(0)
Dvbbs.Execute("update dv_board set child=child-"&boardcount&" where boardid="&iparentid)
end if
next
if child>0 then
'更新其下属论坛数据
'有下属论坛,排序不需考虑,更新下属论坛深度和一级排序ID(rootid)数据
'更新当前版面数据
'ParentStr=ParentStr & ","
i=0
set rs=Dvbbs.Execute("select * from dv_board where ParentStr like '%"&ParentStr&"%'")
do while not rs.eof
i=i+1
mParentStr=replace(rs("ParentStr"),ParentStr,"")
Dvbbs.Execute("update dv_board set depth=depth-"&depth&",rootid="&maxrootid&",ParentStr='"&mParentStr&"' where boardid="&rs("boardid"))
rs.movenext
loop
end if
elseif iparentid>0 and cint(request("class"))>0 then
'将一个分论坛移动到其他分论坛下
'获得所指定的论坛的相关信息
set trs=Dvbbs.Execute("select * from dv_board where boardid="&request("class"))
'得到其下属版面数
ParentStr=ParentStr & ","
set rs=Dvbbs.Execute("select count(*) from dv_board where ParentStr like '%"&ParentStr & newboardid&"%'")
boardcount=rs(0)
if isnull(boardcount) then boardcount=1
'在获得移动过来的版面数后更新排序在指定论坛之后的论坛排序数据
Dvbbs.Execute("update dv_board set orders=orders + "&boardCount&" + 1 where rootid="&trs("rootid")&" and orders>"&trs("orders")&"")
'更新当前版面数据
If trs("parentstr")="0" Then
Dvbbs.Execute("update dv_board set depth="&trs("depth")&"+1,orders="&trs("orders")&"+1,rootid="&trs("rootid")&",ParentID="&request("class")&",ParentStr='" & trs("boardid") & "' where boardid="&newboardid)
Else
Dvbbs.Execute("update dv_board set depth="&trs("depth")&"+1,orders="&trs("orders")&"+1,rootid="&trs("rootid")&",ParentID="&request("class")&",ParentStr='" & trs("parentstr") & "," & trs("boardid") & "' where boardid="&newboardid)
End If
i=1
'如果有则更新下属版面数据
'深度为原有深度加上当前所属论坛的深度
set rs=Dvbbs.Execute("select * from dv_board where ParentStr like '%"&ParentStr & newboardid&"%' order by orders")
do while not rs.eof
i=i+1
If trs("parentstr")="0" Then
iParentStr=trs("boardid") & "," & replace(rs("parentstr"),ParentStr,"")
Else
iParentStr=trs("parentstr") & "," & trs("boardid") & "," & replace(rs("parentstr"),ParentStr,"")
End If
Dvbbs.Execute("update dv_board set depth=depth+"&trs("depth")&"-"&depth&"+1,orders="&trs("orders")&"+"&i&",rootid="&trs("rootid")&",ParentStr='"&iParentStr&"' where boardid="&rs("boardid"))
rs.movenext
loop
ParentID=request("class")
if rootid=trs("rootid") then
'在同一分类下移动
'更新所指向的上级论坛版面数,i为本次移动过来的版面数
'更新其父类版面数
Dvbbs.Execute("update dv_board set child=child+"&i&" where (not ParentID=0) and boardid="&parentid)
for k=1 to trs("depth")
'得到其父类的父类的版面ID
set rs=Dvbbs.Execute("select parentid from dv_board where (not ParentID=0) and boardid="&parentid)
if not (rs.eof and rs.bof) then
parentid=rs(0)
'更新其父类的父类版面数
Dvbbs.Execute("update dv_board set child=child+"&i&" where (not ParentID=0) and boardid="&parentid)
end if
next
'更新其原父类版面数
Dvbbs.Execute("update dv_board set child=child-"&i&" where (not ParentID=0) and boardid="&iparentid)
'更新其原来所属论坛数据
'response.write iparentid & "<br>"
for k=1 to depth
'得到其原父类的父类的版面ID
set rs=Dvbbs.Execute("select parentid from dv_board where (not ParentID=0) and boardid="&iparentid)
if not (rs.eof and rs.bof) then
iparentid=rs(0)
'response.write iparentid & "<br>"
'更新其原父类的父类版面数
Dvbbs.Execute("update dv_board set child=child-"&i&" where (not ParentID=0) and boardid="&iparentid)
end if
next
else
'更新所指向的上级论坛版面数,i为本次移动过来的版面数
'更新其父类版面数
Dvbbs.Execute("update dv_board set child=child+"&i&" where boardid="&parentid)
for k=1 to trs("depth")
'得到其父类的父类的版面ID
set rs=Dvbbs.Execute("select parentid from dv_board where boardid="&parentid)
if not (rs.eof and rs.bof) then
parentid=rs(0)
'更新其父类的父类版面数
Dvbbs.Execute("update dv_board set child=child+"&i&" where boardid="&parentid)
end if
next
'更新其原父类版面数
Dvbbs.Execute("update dv_board set child=child-"&i&" where boardid="&iparentid)
'更新其原来所属论坛数据
for k=1 to depth
'得到其原父类的父类的版面ID
set rs=Dvbbs.Execute("select parentid from dv_board where boardid="&iparentid)
if not (rs.eof and rs.bof) then
iparentid=rs(0)
'更新其原父类的父类版面数
Dvbbs.Execute("update dv_board set child=child-"&i&" where boardid="&iparentid)
end if
next
end if 'end if rootid=trs("rootid") then
else
'如果原来是一级论坛改成其他论坛的下属论坛
'得到所指定的论坛的相关信息
set trs=Dvbbs.Execute("select * from dv_board where boardid="&request("class"))
set rs=Dvbbs.Execute("select count(*) from dv_board where rootid="&rootid)
boardcount=rs(0)
Rs.Close
'更新所指向的上级论坛版面数,i为本次移动过来的版面数
ParentID=request("class")
'更新其父类版面数
Dvbbs.Execute("update dv_board set child=child+"&boardcount&" where boardid="&parentid)
'response.write parentid & "-"&boardcount&"<br>"
for k=1 to trs("depth")
'得到其父类的父类的版面ID
set rs=Dvbbs.Execute("select parentid from dv_board where boardid="&parentid)
if not (rs.eof and rs.bof) then
parentid=rs(0)
'更新其父类的父类版面数
Dvbbs.Execute("update dv_board set child=child+"&boardcount&" where boardid="&parentid)
end if
Rs.Close
'response.write parentid & "-"&boardcount&"<br>"
next
'在获得移动过来的版面数后更新排序在指定论坛之后的论坛排序数据
Dvbbs.Execute("update dv_board set orders=orders + "&boardCount&" + 1 where rootid="&trs("rootid")&" and orders>"&trs("orders")&"")
i=0
SQL = "select boardid,parentid,ParentStr from dv_board where rootid="&rootid&" order by orders"
SET Rs = Dvbbs.Execute(SQL)
If Not Rs.eof Then
SQL=Rs.GetRows(-1)
Rs.close:Set Rs = Nothing
For iii=0 To Ubound(SQL,2)
i=i+1
if SQL(1,iii)=0 then
if trs("ParentStr")="0" then
parentstr=trs("boardid")
else
parentstr=trs("parentstr") & "," & trs("boardid")
end if
Dvbbs.Execute("update dv_board set depth=depth+"&trs("depth")&"+1,orders="&trs("orders")&"+"&i&",rootid="&trs("rootid")&",ParentStr='"&ParentStr&"',parentid="&request("class")&" where boardid="&SQL(0,iii))
else
if trs("ParentStr")="0" then
parentstr=trs("boardid") & "," & SQL(2,iii)
else
parentstr=trs("parentstr") & "," & trs("boardid") & "," & SQL(2,iii)
end if
Dvbbs.Execute("update dv_board set depth=depth+"&trs("depth")&"+1,orders="&trs("orders")&"+"&i&",rootid="&trs("rootid")&",ParentStr='"&ParentStr&"' where boardid="&SQL(0,iii))
end if
Next
Else
Rs.close:Set Rs = Nothing
End If
End If
End If
dv_suc("论坛修改成功!<br>" & str)
set trs=nothing
'cache版面数据
Dvbbs.ReloadAllBoardInfo()
Dvbbs.Name="setup"
Dvbbs.ReloadSetup
Dvbbs.CacheData=Dvbbs.value
Dim iUpdateRootID
'原来的RootID
iUpdateRootID=RootID
'现在的RootID
Set tRs=Dvbbs.Execute("Select RootID From Dv_Board Where BoardID="&request("editid"))
Dim UpdateRootID
UpdateRootID = tRs(0)
Set tRs=Dvbbs.Execute("Select BoardID From Dv_Board Where RootID="&UpdateRootID&" Order By Orders")
Do While Not tRs.Eof
Dvbbs.ReloadBoardInfo(tRs(0))
tRs.Movenext
Loop
'如果编辑版面更改了一级分类,即RootID不一样,则更新原RootID所属的论坛缓存
If iUpdateRootID<>UpdateRootID Then
Set tRs=Dvbbs.Execute("Select BoardID From Dv_Board Where RootID="&iUpdateRootID&" Order By Orders")
Do While Not tRs.Eof
Dvbbs.ReloadBoardInfo(tRs(0))
tRs.Movenext
Loop
End If
Set tRs=Nothing
Dvbbs.DelCahe "BoardJumpList"
Dvbbs.DelCahe "MyAllBoardList"
'end cache
end sub
'删除版面,删除版面帖子,入口:版面ID
sub del()
Dim trs
'更新其上级版面论坛数,如果该论坛含有下级论坛则不允许删除
Set tRs=Dvbbs.Execute("Select RootID From Dv_Board Where BoardID="&request("editid"))
Dim UpdateRootID
UpdateRootID = tRs(0)
set rs=Dvbbs.Execute("select ParentStr,child,depth from dv_board where boardid="&Request("editid"))
if not (rs.eof and rs.bof) then
if rs(1)>0 then
response.write "该论坛含有下属论坛,请删除其下属论坛后再进行删除本论坛的操作"
exit sub
end if
'如果有上级版面,则更新数据
if rs(2)>0 then
Dvbbs.Execute("update dv_board set child=child-1 where boardid in ("&rs(0)&")")
Dim UpdateBoardID
UpdateBoardID=Split(Rs(0),",")
For i=0 To Ubound(UpdateBoardID)
Dvbbs.ReloadBoardInfo(UpdateBoardID(i))
Next
end if
sql = "delete from dv_board where boardid="&Request("editid")
Dvbbs.Execute(sql)
for i=0 to ubound(AllPostTable)
sql = "delete from "&AllPostTable(i)&" where boardid="&Request("editid")
Dvbbs.Execute(sql)
next
Dvbbs.Execute("delete from dv_topic where boardid="&Request("editid"))
Dvbbs.Execute("delete from dv_besttopic where boardid="&Request("editid"))
Dvbbs.Execute("delete from dv_upfile where f_boardid="&Request("editid"))
end if
set rs=nothing
Dvbbs.ReloadAllBoardInfo()
Dvbbs.Name="setup"
Dvbbs.ReloadSetup
Dvbbs.CacheData=Dvbbs.value
Set tRs=dvbbs.Execute("Select BoardID From Dv_Board Where RootID="&UpdateRootID&" Order By Orders")
Do While Not tRs.Eof
Dvbbs.ReloadBoardInfo(tRs(0))
tRs.Movenext
Loop
Set tRs=Nothing
'Dvbbs.ReloadBoardInfo(request("editid"))
Dvbbs.DelCahe "BoardJumpList"
Dvbbs.DelCahe "MyAllBoardList"
response.write "<p>论坛删除成功!"
end sub
sub orders()
%>
<table width="95%" border="0" cellspacing="1" cellpadding="3" align=center class="tableBorder">
<tr>
<th height="22">论坛一级分类重新排序修改(请在相应论坛分类的排序表单内输入相应的排列序号)
</th>
</tr>
<tr>
<td class="Forumrow"><table width="50%">
<%
set rs = server.CreateObject ("Adodb.recordset")
sql="select * from dv_Board where ParentID=0 order by RootID"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "还没有相应的论坛分类。"
else
do while not rs.eof
response.write "<form action=admin_board.asp?action=updatorders method=post><tr><td width=""50%"">"&rs("boardtype")&"</td>"
response.write "<td width=""50%""><input type=text name=""OrderID"" size=4 value="""&rs("rootid")&"""><input type=hidden name=""cID"" value="""&rs("rootid")&"""> <input type=submit name=Submit value=修改></td></tr></form>"
rs.movenext
loop
%>
</table>
<BR> <font color=red>请注意,这里一定<B>不能填写相同的序号</B>,否则非常难修复!</font>
<%
end if
rs.close
set rs=nothing
%>
</td>
</tr>
</table>
<%
end sub
sub updateorders()
dim cID,OrderID,ClassName
'response.write request.form("cID")(1)
'response.end
cID=replace(request.form("cID"),"'","")
OrderID=replace(request.form("OrderID"),"'","")
set rs=Dvbbs.Execute("select boardid from dv_board where rootid="&orderid)
if rs.eof and rs.bof Then
Dv_suc("设置")
Dvbbs.Execute("update dv_board set rootid="&OrderID&" where rootid="&cID)
else
response.write "请不要和其他论坛设置相同的序号"
end if
Dvbbs.ReloadAllBoardInfo()
Dim Forum_Boards
Dvbbs.Name="setup"
Dvbbs.ReloadSetup
Dvbbs.CacheData=Dvbbs.value
Forum_Boards=Split(Dvbbs.CacheData(27,0),",")
For i=0 To Ubound(Forum_Boards)
Dvbbs.ReloadBoardInfo(Forum_Boards(i))
Next
end sub
Sub Boardorders()
%>
<table width="95%" border="0" cellspacing="1" cellpadding="3" align=center class="tableBorder">
<tr>
<th height="22">论坛N级分类重新排序修改(请在相应论坛分类的排序表单内输入相应的排列序号)
</th>
</tr>
<tr>
<td class="Forumrow"><table width="90%">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -