<!--#include file="../conn.asp"-->
<!-- #include file="inc/const.asp" -->
<!-- #include file="../inc/dv_clsother.asp" -->
<!-- #include file="../inc/GroupPermission.asp" -->
<!--#include file=../inc/md5.asp-->
<%
dim keywords
keywords=trim(request("keywords"))
%><title>创建贴吧 - <%=keywords%></title>
<%
Head()
Server.ScriptTimeout=999999
dim Str
dim admin_flag
admin_flag="9,10"
founderr=False 
'if not Dvbbs.master or instr(","&session("flag")&",",",9,")=0 or instr(","&session("flag")&",",",10,")=0 then
'Errmsg=ErrMsg + "<BR><li>本页面为管理员专用，请<a href=../admin_login.asp target=_top>登录</a>后进入。<br><li>您没有管理本页面的权限。"
'dvbbs_error()
'else
call main()
footer()
'end if

sub main()
%>
<table width="95%" border="0" cellspacing="0" cellpadding="0"  align=center class="tableBorder">
<tr> 
<th width="50%" class="tableHeaderText" colspan=2 height=25>
<span style="font-size: 11pt">创建您自己的超级贴吧</span></th>
<th width="50%" class="tableHeaderText" colspan=2 height=25><a href="../index.asp">
<font color="#E8E8E8">贴吧首页</font></a><font color="#E8E8E8"> | 
</font> 
<a href="?action=RestoreBoardCache" onclick="{if(confirm('如果您对新建贴吧在主页看不到，这很可能是相应贴吧的没有生效，在这里将更新缓存，确定吗?')){return true;}return false;}">
<font color="#E8E8E8">更新贴吧</font></a></th>
</tr>
</table>
<%
select case Request("action")
case "add"
call add()
case "edit"
call edit()
case "savenew"'新增贴吧
call savenew()
Case "savedit"
call savedit()
Case "del"
call del()
Case "orders"
call orders()
case "updatorders"
call updateorders()
Case "boardorders"
call boardorders()
case "updatboardorders"
call updateboardorders()
Case "mode"
call mode()
case "savemod"
call savemod()
Case "permission"
call boardpermission()
case "editpermission"
call editpermission()
case "RestoreBoard"
call RestoreBoard()
Case "RestoreBoardCache"
Call RestoreBoardCache()
Case "clearDate"
Call clearDate
Case "delDate"
Call delDate
Case "RestoreClass"
Call RestoreClass
Case "handorders"
Call handorders
Case "savehandorders"
Call savehandorders
Case "savesid"
Call savesid
Case "upallsid"
Call upallsid
Case "settemplates"
Call Settemplates
Case Else
Call boardinfo()
end select
end Sub
Sub upallsid()
Dim Sid,cid,board
SID= Request("Sid")
cid=Request("CID")
If SID="" Then SID=1
If CID="" Then CID=1
SID=CLng(SID)
CID=CLng(CID)
Dvbbs.Execute("Update Dv_Setup Set Forum_Sid="& SID &",Forum_CID="& CID )
Dvbbs.Execute("Update Dv_Board Set Sid="& SID &",CID="& CID )
Dvbbs.loadSetup()
For Each board in Application(Dvbbs.CacheName&"_boardlist").documentElement.selectNodes("board/@boardid")
Dvbbs.LoadBoardData(board.text)
Next
Dv_suc("贴吧版面风格样式统一设置成功!")
End Sub
Sub savesid
Dim i,boardid,TempStr
Dim Templateslist,sid,j,bid,cid
sid=""
For Each TempStr in Request.form("upboardid")
If Bid="" Then
Bid=TempStr
Else
Bid=Bid&","&TempStr
End If 
Next
Bid=split(Bid,",")
For i=0 to UBound(bid)
If sid="" Then
sid=Request("sid"&bid(i))
Else
sid=sid&","&Request("sid"&bid(i))
End If
If cid="" Then
cid=Request("cid"&bid(i))
Else
cid=cid&","&Request("cid"&bid(i))
End If
Next
sid=split(sid,",")
cid=split(cid,",")
For i=0 to UBound(bid)
Dvbbs.Execute("Update Dv_board set sid="&CLng(sid(i))&" ,cid="&CLng(cid(i))&" Where BoardId="&bid(i)&" ")
Dvbbs.LoadBoardData(bid(i))
Next 
Dv_suc("贴吧模板批量设置成功!")
End Sub

Sub Settemplates
'Application(Dvbbs.CacheName &"_style")
Dim reBoard_Setting,MoreMenu,i
Dim Templateslist

%>

<form action ="userBoard.asp?action=savesid" method=post name="dv1">
<table cellspacing="0" cellpadding="0" align=center Class="tableBorder" style="width:98%" >
<tr> 
<th width="70%" class="tableHeaderText" align=Left height=25>&nbsp;贴吧版面
</th>
<th width="30%" class="tableHeaderText" align=Left height=25>采用风格样式
</th>
</tr>
<%
dim classrow
sql="select * from dv_board order by rootid,orders"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
do while not rs.eof
reBoard_Setting=split(rs("Board_setting"),",")
if classrow="forumRowHighlight" then
classrow="forumRow"
else
classrow="forumRowHighlight"
end if
%>
<tr> 
<td height="25"  class="<%=classrow%>">
<%if rs("depth")>0 then%>
<%for i=1 to rs("depth")%>
&nbsp;
<%next%>
<%end if%>
<%if rs("child")>0 then%><img src="../skins/default/plus.gif"><%else%><img src="../skins/default/nofollow.gif"><%end if%>
<%if rs("parentid")=0 then%><b><%end if%><%=rs("boardtype")%><%if rs("child")>0 then%>(<%=rs("child")%>)<%end if%>
<%if rs("parentid")=0 then%></b><%end if%>
</td>
<td align=Left  class="<%=classrow%>">
<Select Size=1 Name="sid<%=Rs("BoardID")%>">
<%
For Each Templateslist in Application(Dvbbs.CacheName &"_style").documentElement.selectNodes("style")
Response.Write "<Option value="""& Templateslist.selectSingleNode("@id").text &""""
If Rs("SID") = CLng(Templateslist.selectSingleNode("@id").text) Then Response.Write " selected "
Response.Write ">"& Templateslist.selectSingleNode("@stylename").text &" </Option>"
Next
%>
</Select>Css样式:<Select Size=1 Name="Cid<%=Rs("BoardID")%>">
<%
For Each Templateslist in Application(Dvbbs.CacheName & "_csslist").documentElement.selectNodes("css[tid="& Rs("SID") &"]")
Response.Write "<Option value="""& Templateslist.selectSingleNode("@id").text &""""
If Rs("cid") = CLng(Templateslist.selectSingleNode("@id").text)  Then Response.Write " selected "
Response.Write ">"& Templateslist.selectSingleNode("@type").text &" </Option>"
Next
%>
</Select>
<Input type="hidden" name="upboardid" value="<%=rs("boardid")%>">
</td></tr>
<%
Rs.movenext
loop
set rs=nothing
%>
<tr>
<td width=300 align=Left  class="forumRowHighlight" ></td>
<td width=300 align=Left  class="forumRowHighlight" ><input type="submit" name="Submit" value="设 定"></td>
</tr>
</table><BR><BR>
</form>

<%
End Sub 
sub boardinfo()
Dim reBoard_Setting,MoreMenu
Dim classrow,iii
%>
<table width="95%" cellspacing="0" cellpadding="0" align=center class="tableBorder">
<tr> 
<th width="35%" class="tableHeaderText" height=25>贴吧版面
</th>
<th width="35%" class="tableHeaderText" height=25>操作
</th>
</tr>
<%
SQL="select boardid,boardtype,parentid,depth,child,Board_setting from dv_board order by rootid,orders"
SET Rs = Conn.Execute(SQL)
If Rs.eof Then
Rs.close:Set Rs = Nothing
Else

SQL=Rs.GetRows(-1)
Rs.close:Set Rs = Nothing
For iii=0 To Ubound(SQL,2)
reBoard_Setting=split(SQL(5,iii),",")
if classrow="forumRowHighlight" then
classrow="forumRow"
else
classrow="forumRowHighlight"
end if
Response.Write "<tr>"
Response.Write "<td height=""25"" width=""55%""  class="
Response.Write classrow
Response.Write ">"
if SQL(3,iii)>0 then
for i=1 to SQL(3,iii)
Response.Write "&nbsp;&nbsp;"
next
end if
if SQL(4,iii)>0 then
Response.Write "<img src=""../skins/default/plus.gif"">"
else
Response.Write "<img src=""../skins/default/nofollow.gif"">"
end if
if SQL(2,iii)=0 then
Response.Write "<b>"
end if
Response.Write SQL(1,iii)
if SQL(4,iii)>0 then
Response.Write "("
Response.Write SQL(4,iii)
Response.Write ")"
end if
%>
</td>
<td width="45%" class="<%=classrow%>">
　</td></tr>
<%
MoreMenu=""
Next
End If
%>
</table><BR><BR>
<SCRIPT LANGUAGE="JavaScript">
<!--
function alertreadme(str,url){
{if(confirm(str)){
location.href=url;
return true;
}return false;}
}
//-->
</SCRIPT>
<%
end sub

sub add()
dim rs_c
Dim forum_sid,forum_cid,Style_Option,TempOption,RootID
Dim iCssName,iCssID,iStyleName
set rs_c= server.CreateObject ("adodb.recordset")
sql = "select * from dv_board order by rootid,orders"
rs_c.open sql,conn,1,1
dim boardnum
set rs = server.CreateObject ("Adodb.recordset")
sql="select Max(boardid) from dv_board"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
boardnum=1
else
boardnum=rs(0)+1
end if
if isnull(boardnum) then boardnum=1
if boardnum=444 then boardnum=445
if boardnum=777 then boardnum=778
rs.close
%>
<form action ="userBoard.asp?action=savenew" method=post name=theform>
<input type="hidden" name="newboardid" value=<%=boardnum%>>
<div align="center">
<table border="0" cellspacing="1" cellpadding="0" class="tableBorder">
<tr> 
<td width="100%" height=39 class="forumrowHighLight" colspan=2>
<p align="center"><font color="#808000"><B><span style="font-size: 11pt">温馨提示:您
所查询的贴吧不存在或已被删除,您可以通过添加操作来创建该贴吧!!!</span></b></font></p>
</td>
</tr>
<tr> 
<td width="25%" height=21 class="forumrow" align="right">您申请的贴吧是：</td>
<td class="forumrow">
<input type="text"  readonly="this.false" name="boardtype" size="80%" value="<%=keywords%>" style="color: #FF0000; border: 1px solid #F1F3F5; background-color: #F1F3F5"></td>
</tr>
<tr> 
<td width="25%" height=24 class="forumrow" align="right">贴吧的简要说明：<BR>　</td>
<td width="75%" class="forumrow"> 
<textarea name="Readme" cols="66" rows="2"></textarea>
<font color="#FF0000">*必填</font></td>
</tr>
<tr> 
<td width="25%" height=24 class="forumrow" align="right" valign="top">贴吧使用及吧规：</td>
<td width="75%" class="forumrow"> 
<textarea name="Rules" cols="66" rows="3"></textarea>
可不填</td>
</tr>
<tr> 
<td width="25%" height=30 class="forumrow" align="right">请选择所属类别：</td>
<td width="75%" class="forumrow"> 
<select name=class>
<% do while not rs_c.EOF%>
<%
//定义那些分类用户可兴建贴吧
IF rs_c("RootID")="2" or rs_c("RootID")="6" or rs_c("RootID")="16" then
if rs_c("Depth")>"0" and rs_c("Depth")<"3" then
%> 
<option value="<%=rs_c("boardid")%>" <%if request("editid")<>"" and clng(request("editid"))=rs_c("boardid") then%>selected<%end if%>>
<%if rs_c("depth")>0 then%>
<%for i=1 to rs_c("depth")%>
<%next%>
<%end if%>
<% if rs_c("Depth")>"1" then %>
|_______
<%else%>
  <% Select Case rs_c("RootID")
Case "2" 
Response.Write "城市贴吧-"
Case "6"
Response.Write "自建贴吧-"
Case "16"
Response.Write "行业贴吧-"
end Select %>
<%end if%>
<%=rs_c("boardtype")%>
</option><%end if%><%end if%>
<%
rs_c.MoveNext 
loop
rs_c.Close 
%>
</select>
请选择所属分类，目前支持3-4级
<font color="#FF0000">*必选</font></td>
</tr>
<tr> 
<td width="25%" height=30 class="forumrow" align="right">请选择样式风格：</td>
<td width="75%" class="forumrow">
<%
set rs_c=dvbbs.execute("select forum_sid,forum_cid from dv_setup")
Forum_sid=rs_c(0)
Forum_cid=rs_c(1)
rs_c.close:Set rs_c=Nothing
%>
<Select Size=1 Name="sid">
<%
Dim Templateslist
For Each Templateslist in Application(Dvbbs.CacheName &"_style").documentElement.selectNodes("style")
Response.Write "<Option value="""& Templateslist.selectSingleNode("@id").text &""""
If Forum_sid = CLng(Templateslist.selectSingleNode("@id").text) Then Response.Write " selected "
Response.Write ">"& Templateslist.selectSingleNode("@stylename").text &" </Option>"
Next
%>
</Select> Css样式:<Select Size=1 Name="cid">
<%
For Each Templateslist in Application(Dvbbs.CacheName & "_csslist").documentElement.selectNodes("css")
Response.Write "<Option value="""& Templateslist.selectSingleNode("@id").text &""""
If Forum_cid = CLng(Templateslist.selectSingleNode("@id").text)  Then Response.Write " selected "
Response.Write ">"& Templateslist.selectSingleNode("@type").text &" </Option>"
Next
%>
</Select>
相关样式风格中包含贴吧颜色、图片等信息</td>
</tr>
<tr> 
<td width="25%" height=30 class="forumrow" align="right">请您任命正吧主：</td>
<td width="75%" class="forumrow"> 
<input type="text" name="boardmaster" size="20">
需要
多吧主的请在创建贴吧后设置</td>
</tr>
<tr> 
<td width="25%" height=30 class="forumrow" align="right">请您输入验证码：</td>
<td width="75%" class="forumrow">
<input name="verifycode" type="text">&nbsp;请在左边输入 
<img src="../Dv_getcode.asp"  alt="验证码,看不清楚?请点击刷新验证码" height="16" style="cursor : pointer;" onclick="this.src='../DV_getcode.asp'" />
<font color="#FF0000">*必填</font></td>
</tr>
<tr>
<td width="25%" height=24 class="forumRow" valign="top" align="right">贴吧新创建须知：</td>
<td width="75%" class="forumRow"> 
1、新建贴吧后，相关的设置均为默认设置，个性化请到<font color=blue><a href="../set.asp">吧主管理中心</a></font>设置
。<br>
2、选择合适的类别：比如您选择在‘自建贴吧’下建立子贴吧，则要选中‘自建贴吧’！<br>
3、您可添加自己为正吧主，请填上您的用户名；允许有多如有多位副吧主！<br>
4、贴吧名称请少于20个汉字或字母！修改贴吧名称请返回首页重新查询！</td>
</tr>
<tr> 
<td width="100%" height=54 class="forumrow" align="center" colspan="2">
<input type="hidden" name="indexIMG" size="35">
<input type=checkbox name="okba" value="我已阅读" checked ><a href="../xyfzc.asp">我已阅读贴吧协议,遵守国家相关法律!严格管理所申请的贴吧!</a> 
<input type="submit" name="Submit" value="确认添加贴吧" style="font-size: 13pt" >
</td>
</tr></table>
</div></form>
<%
set rs_c=nothing
set rs=nothing
end sub

sub edit()
dim rs_c,reBoard_Setting
Dim forum_sid,forum_cid,Style_Option,TempOption
Dim iCssName,iCssID,iStyleName
sql = "select * from dv_board order by rootid,orders"
set rs_c=Dvbbs.Execute(sql)
sql = "select * from dv_board where boardid="&request("editid")
set rs=Dvbbs.Execute(sql)
reBoard_Setting=split(rs("Board_setting"),",")

forum_sid=rs("sid")
forum_cid=rs("cid")
%>        
<form action ="userBoard.asp?action=savedit" method=post name=theform>       
<input type="hiddords=<%=keywords%>">修改</a>
]请少于20个汉字或字母[ 
<a href="../url_search.asp?keywords=<%=keywords%>">修改</a>
]请少于20个汉字或字母lign=center class="tableBorder">
<tr> 
<th height=24 colspan=2>编辑贴吧：<%=rs("boardtype")%></th>
</tr>
<tr> 
<td width="100%" height=30 class="forumrowHighLight" colspan=2>
说明：<BR>1、添加贴吧版面后，相关的设置均为默认设置，请返回贴吧版面管理首页版面列表的高级设置中设置该贴吧的相应属性，如果您想对该贴吧做更具体的权限设置，请到<A HREF="userBoard.asp?action=permission"><font color=blue>贴吧权限管理</font></A>中设置相应用户等级在该版面的权限。<BR>
2、<font color=blue>如果您添加的是贴吧分类</font>，只需要在所属分类中选择作为贴吧分类即可；<font color=blue>如果您添加的是贴吧版面</font>，则要在所属分类中确定并选择该贴吧版面的上级版面
</td>
</tr>
<tr> 
<td width="40%" height=30 class="forumrow">贴吧名称</td>
<td width="60%" class="forumrow"> 
<input type="text" name="boardtype" size="35"  value="<%=Server.htmlencode(rs("boardtype"))%>" >
</td>
</tr>
<tr> 
<td width="40%" height=24 class="forumrow">版面说明<BR>可以使用HTML代码</td>
<td width="60%" class="forumrow"> 
<textarea name="Readme" cols="50" rows="5"><%=server.HTMLEncode(Rs("readme")&"")%></textarea>
</td>
</tr>
<tr> 
<td width="40%" height=24 class="forumrow">版面规则<BR>可以使用HTML代码</td>
<td width="60%" class="forumrow"> 
<textarea name="Rules" cols="50" rows="5"><%=server.HTMLEncode(Rs("Rules")&"")%></textarea>
</td>
</tr>
<tr> 
<td width="40%" height=30 class="forumrow"><U>所属类别</U><BR>所属贴吧不能指定为当前版面<BR>所属贴吧不能指定为当前版面的下属贴吧</td>
<td width="60%" class="forumrow"> 
<select name=class>
<option value="0">做为贴吧分类</option>
<% do while not rs_c.EOF%>
<option value="<%=rs_c("boardid")%>" <% if cint(rs("parentid")) = rs_c("boardid") then%> selected <%end if%>><%if rs_c("depth")>0 then%>
<%for i=1 to rs_c("depth")%>
－
<%next%>
<%end if%><%=rs_c("boardtype")%></option>
<%
rs_c.MoveNext 
loop
rs_c.Close 
%>
</select>
</td>
</tr>
<tr> 
<td width="40%" height=30 class="forumrow"><U>使用样式风格</U><BR>相关样式风格中包含贴吧颜色、图片<BR>等信息</td>
<td width="60%" class="forumrow">
<%
set rs_c=dvbbs.execute("select forum_sid,forum_cid from dv_setup")
Forum_sid=rs_c(0)
Forum_cid=rs_c(1)
rs_c.close:Set rs_c=Nothing
%>
<Select Size=1 Name="sid">
<%
Dim Templateslist
For Each Templateslist in Application(Dvbbs.CacheName &"_style").documentElement.selectNodes("style")
Response.Write "<Option value="""& Templateslist.selectSingleNode("@id").text &""""
If rs("sid") = CLng(Templateslist.selectSingleNode("@id").text) Then Response.Write " selected "
Response.Write ">"& Templateslist.selectSingleNode("@stylename").text &" </Option>"
Next
%>
</Select>Css样式:<Select Size=1 Name="cid">
<%
For Each Templateslist in Application(Dvbbs.CacheName & "_csslist").documentElement.selectNodes("css[tid="& rs("sid")&"]")
Response.Write "<Option value="""& Templateslist.selectSingleNode("@id").text &""""
If rs("cid") = CLng(Templateslist.selectSingleNode("@id").text)  Then Response.Write " selected "
Response.Write ">"& Templateslist.selectSingleNode("@type").text &" </Option>"
Next
%>
</Select>
</td>
</tr>
<tr> 
<td width="40%" height=30 class="forumrow"><U>贴吧吧主</U><BR>多斑竹添加请用|分隔，如：沙滩小子|wodeail</td>
<td width="60%" class="forumrow"> 
<input type="text" name="boardmaster" size="35"  value='<%=rs("boardmaster")%>'>
<<input type="submit" name="Submit" value="确认添加贴吧" >input type="hidden" name="oldboardmaster" value='<%=rs("boardmaster")%>'>
</td>
</tr>
<tr> 
<td width="40%" height=边<BR>请直接填写图片URL</td>
<td width="60%" class="forumrow">
<input type="text" name="indexIMG" size="35" value="<%=rs("indexIMG")%>">
</td>
</tr>
<tr> 
<td width="40%" height=24 class="forumrow">　</td>
<td width="60%" class="forumrow"> 
<input type="submit" name="Submit" value="提交修改">
</td>
</tr>
<tr> 
<td width="100%" height=30 class="forumrowHighLight" colspan=2 align=right>
<a href="userBoard.asp?action=add&editid=<%=Request("editid")%>"><font color="<%=Dvbbs.mainsetting(3)%>"><U>添加版面</U></font></a> | <a href="userBoard.asp?action=edit&editid=<%=Request("editid")%>"><font color="<%=Dvbbs.mainsetting(3)%>"><U>基本设置</U></font></a> | <a href="BoardSetting.asp?editid=<%=Request("editid")%>"><font color="<%=Dvbbs.mainsetting(3)%>"><U>高级设置</U></font></a>
<%if reBoard_Setting(2)=1 then%>
| <a href="userBoard.asp?action=mode&boardid=<%=Request("editid")%>"><font color="<%=Dvbbs.mainsetting(3)%>"><U>认证用户</U></font></a>
<%end if%>
| <a href="update.asp?action=updat&submit=更新贴吧数据&boardid=<%=Request("editid")%>" title="更新最后回复、帖子数、回复数"><font color="<%=Dvbbs.mainsetting(3)%>"><U>更新数据</U></font></a> | <a href="update.asp?action=delboard&boardid=<%=Request("editid")%>" onclick="{if(confirm('清空将包括该贴吧所有帖子置于回收站，确定清空吗?')){return true;}return false;}"><font color="<%=Dvbbs.mainsetting(3)%>"><U>清空</U></font></a> | <%if rs("child")=0 then%><a href="userBoard.asp?action=del&editid=<%=Request("editid")%>" onclick="{if(confirm('删除将包括该贴吧的所有帖子，确定删除吗?')){return true;}return false;}"><font color="<%=Dvbbs.mainsetting(3)%>"><U>删除</U></a><%else%><a href="#" onclick="{if(confirm('该贴吧含有下属贴吧，必须先删除其下属贴吧方能删除本贴吧！')){return true;}return false;}"><font color="<%=Dvbbs.mainsetting(3)%>"><U>删除</U></a><%end if%>
| <a href="userBoard.asp?action=clearDate&boardid=<%=Request("editid")%>"> <font color="<%=Dvbbs.mainsetting(3)%>"><u>清理数据</u></a>
</td>
</tr>
</table>
</form>
<%
rs.close
set rs=nothing
set rs_c=nothing
end sub

Sub Mode()
Dim Boarduser
Dim BoarduserNum
%>
<form action ="userBoard.asp?action=savemod" method=post>
<table width="95%" class="tableBorder" cellspacing="1" cellpadding="1" align="center">
<tr> 
<th width="52%" height=22>说明：</th>
<th width="48%">操作：</th>
</tr>
<tr> 
<td width="52%" height=22 class=forumrow><B>贴吧名称</B></td>
<td width="48%" class=forumrow> 
<%
Sql = "SELECT Boardid, Boardtype, Boarduser FROM Dv_Board WHERE Boardid = " & Request("boardid")
Set Rs = Dvbbs.Execute(Sql)
If Rs.Eof And Rs.Bof Then
Response.Write "该版面并不存在或者该版面不是加密版面。"
Else
Response.Write Rs(1)
Response.Write "<input type=hidden value=" & Rs(0) & " name=boardid>"
Boarduser = Rs(2)
End If
Set Rs = Nothing
%>
</td>
</tr>
<tr> 
<td width="52%" class=forumrow valign=top><B>认证用户</B>：
<%
If Not Isnull(Boarduser) Or Boarduser <> "" Then
BoarduserNum = Split(Boarduser,",")
Response.Write "（本版共有<font color=red>" & Ubound(BoarduserNum)+1 & "</font>位认证用户）"
Else
Response.Write "（本版暂时没有认证用户）"
End If
%>
<br>
只有设定为认证贴吧的贴吧需要填写能够进入该版面的用户，每输入一个用户请确认用户名在贴吧中存在，每个用户名用<B>回车</B>分开</font>
<%
If Clng(Dvbbs.Board_Setting(62))>0 Or Clng(Dvbbs.Board_Setting(63))>0 Then Response.Write "<BR><font color=blue>此吧面设置了支付贴币或点卡方能进入，有效期为<font color=red>" & Clng(Dvbbs.Board_Setting(64)) & "</font>个月，请在每个用户名后面加上：=当前时间，每行效果如：admin="&Now&"</font>"
%>
</td>
<td width="48%" class=forumrow> 
<textarea cols="50" rows="3" name="vipuser" id="vipuser">
<%if not isnull(boarduser) or boarduser<>"" then
response.write Replace(boarduser,",",Chr(10))
end if%></textarea>
<br><a href="javascript:admin_Size(-3,'vipuser')"><img src="images/minus.gif" unselectable="on" border='0'></a> <a href="javascript:admin_Size(3,'vipuser')"><img src="images/plus.gif" unselectable="on" border='0'></a>
</td>
</tr>
<tr> 
<td width="52%" height=22 class=forumrow>　</td>
<td width="48%" class=forumrow> 
<input type="submit" name="Submit" value="设 定">
</td>
</tr>
</table>
</form>
<%
End Sub 

'保存编辑贴吧认证用户信息
'入口：用户列表字符串
sub savemod()
dim boarduser
dim boarduser_1
dim userlen
dim updateinfo
'清理付费贴吧过期的认证用户 2005-3-10 Dv.Yz
Dim Get_BoardUser_Money, BoardUser_Money
Get_BoardUser_Money = False
If Clng(Dvbbs.Board_Setting(62))>0 Or Clng(Dvbbs.Board_Setting(63))>0 Then Get_BoardUser_Money = True

If trim(request("vipuser"))<>"" then
boarduser=request("vipuser")
boarduser=split(boarduser,chr(13)&chr(10))
For i = 0 To Ubound(Boarduser)
If Not (Boarduser(i) = "" Or Boarduser(i) = " ") Then
If Get_BoardUser_Money Then
BoardUser_Money = Split(Boarduser(i),"=")
If Not DateDiff("d",BoardUser_Money(1),Now()) > Cint(Dvbbs.Board_Setting(64))*30 Then
Boarduser_1 = "" & Boarduser_1 & "" & Boarduser(i) & ","
End If
Else
Boarduser_1 = "" & Boarduser_1 & "" & Boarduser(i) & ","
End If
End If
Next
userlen=len(boarduser_1)
if boarduser_1<>"" then
boarduser=left(boarduser_1,userlen-1)
updateinfo=" boarduser='"&boarduser&"' "
Dvbbs.Execute("update dv_board set "&updateinfo&" where boardid="&request("boardid"))
Dv_suc("贴吧设置成功!<LI>成功添加认证用户："&boarduser&"<LI><a href=""?action=RestoreBoardCache"" >请执行重建版面缓存才能生效</a><br>")
RestoreBoardCache()
else
response.write "<p><font color=red>你没有添加认证用户</font><br><br>"
Exit Sub
end if
Else
response.write "<p><font color=red>你没有添加认证用户</font><br><br>"
End If

End Sub

'保存添加贴吧信息
Sub savenew()
If request("boardtype")="" Then
Errmsg=Errmsg+"<br>"+"<li>请输入贴吧名称。"
founderr=true
End If
If request("class")="" Then
Errmsg=Errmsg+"<br>"+"<li>请选择贴吧分类。"
founderr=true
End If
If request("readme")="" Then
Errmsg=Errmsg+"<br>"+"<li>请输入贴吧说明。"
founderr=true
End If
If founderr=true Then
dvbbs_error()
exit sub
End If
Dim boardid,rootid,parentid,depth,orders,Fboardmaster,maxrootid,parentstr
If request("class")<>"0" Then
Set rs=Dvbbs.Execute("select rootid,boardid,depth,orders,boardmaster,ParentStr from dv_board where boardid="&request("class"))
rootid=rs(0)
parentid=rs(1)
depth=rs(2)
orders=rs(3)
If depth+1>20 Then
Errmsg="本贴吧限制最多只能有20级分类"
  dvbbs_error()
  Exit Sub
 End If 
parentstr=rs(5)
Else
Set rs=Dvbbs.Execute("select max(rootid) from dv_board")
  maxrootid=rs(0)+1
If  IsNull(MaxRootID) Then MaxRootID=1
End If
sql="select boardid from dv_board where boardid="&request("newboardid")
Set rs=Dvbbs.Execute(sql)
If not (rs.eof and rs.bof) then
Errmsg="该贴吧已存在，请重新申请。"
dvbbs_error()
exit sub
Else
boardid=request("newboardid")
End If
Dim trs,forumuser,setting
Set trs=Dvbbs.Execute("select * from dv_setup")
Setting=Split(trs("Forum_Setting"),"|||")
forumuser=Setting(2)
set rs = server.CreateObject ("adodb.recordset")
sql = "select * from dv_board"
rs.Open sql,conn,1,3
rs.AddNew
If request("class")<>"0" Then
rs("depth")=depth+1
rs("rootid")=rootid
rs("orders") = Request.form("newboardid")
rs("parentid") = Request.Form("class")
if ParentStr="0" then
rs("ParentStr")=Request.Form("class")
Else
 rs("ParentStr")=ParentStr & "," & Request.Form("class")
End If
Else
rs("depth")=0
rs("rootid")=maxrootid
rs("orders")=0
rs("parentid")=0
rs("parentstr")=0
end if
rs("boardid") = Request.form("newboardid")
rs("boardtype") = request.form("boardtype")
rs("readme") = Request.form("readme")
rs("Rules") = Request.form("Rules")
rs("TopicNum") = 0
rs("PostNum") = 0
rs("todaynum") = 0
rs("child")=0
rs("LastPost")="$0$"&Now()&"$$$$$"
rs("Board_Setting")="0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,16240,3,0,gif|jpg|jpeg|bmp|png|rar|txt|zip|mid,0,0,1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1,0,1,100,20,10,9,normal,1,10,10,0,0,0,0,1,0,0,1,4,0,0,0,200,0,0,,$$,0,0,0,1,0|0|0|0|0|0|0|0|0,0|0|0|0|0|0|0|0|0,0,0,0,0,0,0,0,0,0,灌水|广告|奖励|惩罚|好文章|内容不符|重复发帖,0,1,0,24,0,0"
rs("sid")=request.form("sid")
rs("cid")=request.form("cid")
rs("board_ads")=trs("forum_ads")
rs("board_user")=forumuser
If Request("boardmaster")<>"" Then 
rs("boardmaster") = Request.form("boardmaster")
End If
If request.form("indexIMG")<>"" Then
rs("indexIMG")=request.form("indexIMG")
End If
rs.Update 
rs.Close
If Request("boardmaster")<>"" Then Call addmaster(Request("boardmaster"),"none",0)
dv_suc("尊敬的用户，您的贴吧已经创建成功！贴吧目前个性化设置为默认选项，建议您吧主管理中心修改！<A HREF=../set.asp?boardid="&Request.form("newboardid")&">进入吧主管理中心</A>" & str)
set rs=nothing
trs.close
set trs=nothing
CheckAndFixBoard 0,1
RestoreBoardCache()
End Sub

'保存编辑贴吧信息
Sub savedit()
if clng(request("editid"))=clng(request("class")) then
Errmsg="所属贴吧不能指定自己"
dvbbs_error()
exit sub
end if
dim newboardid,maxrootid
dim parentid,boardmaster,depth,child,ParentStr,rootid,iparentid,iParentStr
dim trs,brs,mrs
Dim iii
set rs = server.CreateObject ("adodb.recordset")
sql = "select * from dv_board where boardid="&request("editid")
rs.Open sql,conn,1,3
newboardid=rs("boardid")
parentid=rs("parentid")
iparentid=rs("parentid")
boardmaster=rs("boardmaster")
ParentStr=rs("ParentStr")
depth=rs("depth")
child=rs("child")
rootid=rs("rootid")
'判断所指定的贴吧是否其下属贴吧
if ParentID=0 then
if clng(request("class"))<>0 then
set trs=Dvbbs.Execute("select rootid from dv_board where boardid="&request("class"))
if rootid=trs(0) then
errmsg="您不能指定该版面的下属贴吧作为所属贴吧1"
dvbbs_error()
exit sub
end if
end if
else
set trs=Dvbbs.Execute("select boardid from dv_board where ParentStr like '%"&ParentStr&","&newboardid&"%' and boardid="&request("class"))
if not (trs.eof and trs.bof) then
errmsg="您不能指定该版面的下属贴吧作为所属贴吧2"
dvbbs_error()
exit sub
end if
end if
if parentid=0 then
parentid=rs("boardid")
iparentid=0
end if
rs("boardtype") = Request.Form("boardtype")'取消JS过滤。
rs("parentid") = Request.Form("class")
rs("boardmaster") = Request("boardmaster")
rs("readme") = Request("readme")
rs("Rules") = Request.form("Rules")
rs("indexIMG")=request.form("indexIMG")
rs("sid")=Cint(request.form("sid"))
rs("cid")=Cint(request.form("cid"))
rs.Update 
rs.Close
set rs=nothing
if request("oldboardmaster")<>Request("boardmaster") then call addmaster(Request("boardmaster"),request("oldboardmaster"),1)

set mrs=Dvbbs.Execute("select max(rootid) from dv_board")
Maxrootid=mrs(0)+1
mrs.close:set mrs=nothing
dv_suc("贴吧修改成功！<br>" & str)
CheckAndFixBoard 0,1
RestoreBoardCache()
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) & ")")
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"))
'删除被删除贴吧的自定义用户权限 2004-11-15 Dv.Yz
Dvbbs.Execute("DELETE FROM Dv_UserAccess WHERE NOT Uc_BoardID IN (SELECT BoardID FROM Dv_Board)")
End If
Set Rs = Nothing
CheckAndFixBoard 0,1
RestoreBoardCache()
Dv_suc("<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=userBoard.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")&""">&nbsp;&nbsp;<input type=submit name=Submit value=修改></td></tr></form>"
rs.movenext
loop
%>
</table>
<BR>&nbsp;<font color=red>请注意，这里系统会<B>自动修复</B>不正确的序号！</font>
<%
end if
rs.close
set rs=nothing
%>
</td>
</tr>
</table>
<%
end sub

sub updateorders()
dim cID,OrderID,ClassName
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
Dvbbs.Execute("update dv_board set rootid="&OrderID&" where rootid="&cID)
Dv_suc("设置成功")
Else
response.write "请不要和其他贴吧设置相同的序号"
end if
RestoreBoardCache()
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%">
<%
Dim Trs, Uporders, Doorders
Set Rs = Server.CreateObject ("Adodb.recordset")
Sql = "SELECT Depth, Child, Parentid, Boardtype, Orders, BoardId FROM Dv_Board ORDER BY RootID, Orders"
Set Rs = Dvbbs.Execute(Sql)
If Rs.Eof And Rs.Bof Then
Response.Write "还没有相应的贴吧分类。"
Else
Sql = Rs.GetRows(-1)
Dim Bn
Rs.Close:Set Rs = Nothing
For Bn = 0 To Ubound(Sql,2)
Response.Write "<form action=userBoard.asp?action=updatboardorders method=post><tr><td width=""50%"">"
If Sql(0,Bn) > 0 Then
For i = 1 To Sql(0,Bn)
Response.Write "&nbsp;"
Next
End If
If Sql(1,Bn) > 0 Then
Response.Write "<img src=../skins/default/plus.gif>"
Else
Response.Write "<img src=../skins/default/nofollow.gif>"
End If
If Sql(2,Bn) = 0 Then
Response.Write "<b>"
End If
Response.Write Sql(3,Bn)
If Sql(1,Bn) > 0 Then
Response.Write "(" & Sql(1,Bn) & ")"
End If
Response.Write "</td><td width=""50%"">"
If Sql(2,Bn) > 0 Then
'算出相同深度的版面数目，得到该版面在相同深度的版面中所处位置（之上或者之下的版面数）
'所能提升最大幅度应为For i=1 to 该版之上的版面数
Set Trs = Dvbbs.Execute("SELECT COUNT(*) FROM Dv_Board WHERE ParentID = " & Sql(2,Bn) & " AND ORDERS < " & Sql(4,Bn) &"")
Uporders = Trs(0)
If Isnull(Uporders) Then Uporders = 0
'所能降低最大幅度应为For i=1 to 该版之下的版面数
Set Trs = Dvbbs.Execute("SELECT COUNT(*) FROM Dv_Board WHERE ParentID = " & Sql(2,Bn) &" AND ORDERS > " & Sql(4,Bn) &"")
Doorders = Trs(0)
If Isnull(doorders) Then Doorders = 0
If Uporders > 0 Then
Response.Write "<select name=uporders size=1><option value=0>向上移动</option>"
For i = 1 To Uporders
Response.Write "<option value=" & i & ">" & i & "</option>"
Next
Response.Write "</select>"
End If
If Doorders > 0 Then
If uporders > 0 Then Response.Write "&nbsp;"
Response.Write "<select name=doorders size=1><option value=0>向下移动</option>"
For i = 1 To Doorders
Response.Write "<option value=" & i & ">" & i & "</option>"
Next
Response.Write "</select>"
End If
If Doorders > 0 Or Uporders > 0 Then
Response.Write "<input type=hidden name=""editID"" value=""" & Sql(5,Bn) & """>&nbsp;<input type=submit name=Submit value=修改>"
End If
End If
Response.Write "</td></tr></form>"
Uporders = 0
Doorders = 0
Next
Response.Write "</table>"
End If
%>
</td>
</tr>
</table>
<%
End Sub

'N级分类移动 2004-10-18 Dv.Yz
Sub Updateboardorders()
Dim Orders, tRs, Parentid
Dim Uporders, Doorders
Dim Frontorders, Nextorders, Lastorders
Dim Rootid, Depth, Child, Parentstr
If Not Isnumeric(Request("EditID")) Then
Response.Write "非法的参数！"
Exit Sub
End If
If Request("Uporders") <> "" And Not Cint(Request("Uporders")) = 0 Then
If Not Isnumeric(Request("Uporders")) Then
Response.Write "非法的参数！"
Exit Sub
Elseif Cint(Request("Uporders")) = 0 Then
Response.Write "请选择要提升的数字！"
Exit Sub
End If
Uporders = Cint(Request("Uporders"))
'向上移动
Set Rs = Dvbbs.Execute("SELECT Orders, Rootid, Depth, ParentID, Child, ParentStr FROM Dv_Board WHERE Boardid = " & Request("EditID"))
Orders = Rs(0)
Rootid = Rs(1)
Depth = Rs(2)
Parentid = Rs(3)
Child = Rs(4)
ParentStr = Rs(5) & "," & Request("EditID")
Set Rs = Nothing

'取Lastorders值
Sql = "SELECT Top 1 Orders FROM Dv_Board WHERE Rootid = " & Rootid & " ORDER BY Orders DESC"
Set Rs = Dvbbs.Execute(Sql)
Lastorders = Rs(0)
Set Rs = Nothing

'取取移动结属ORDERS值
If Child > 0 Then
Sql = "SELECT COUNT(*) FROM Dv_Board WHERE ParentStr LIKE '%" & ParentStr & "%' AND Rootid = " & Rootid
Set Rs = Dvbbs.Execute(Sql)
Nextorders = Orders + Rs(0)
Else
Nextorders = Orders
End If
Doorders = Nextorders
Set Rs = Nothing

'取同级版面往上的版面ORDERS值
Sql = "SELECT Top " & Uporders & " Orders FROM Dv_Board WHERE Rootid = " & Rootid & " AND Depth = " & Depth & " AND ParentID = " & Parentid & " AND Orders < " & Orders & " ORDER BY Orders Desc"
Set Rs = Dvbbs.Execute(Sql)
If Rs.Eof And Rs.Bof Then
Frontorders = 0
Else
Sql = Rs.GetRows(-1)
Frontorders = Sql(0,Ubound(Sql,2))
End If

'一次更新Orders
Sql = "UPDATE Dv_Board SET Orders = Orders + " & Doorders & " WHERE Rootid = " & Rootid & " AND (Orders >= " & Frontorders & " AND Orders < " & Orders & " OR Orders > " & Nextorders & ")"
'Response.Write Sql
Dvbbs.Execute(Sql)

Elseif Request("Doorders") <> "" Then
If Not Isnumeric(Request("Doorders")) Then
Response.Write "非法的参数！"
Exit Sub
Elseif Cint(Request("doorders")) = 0 Then
Response.Write "请选择要下降的数字！"
Exit Sub
End If
Uporders = Cint(Request("doorders"))
'向下移动
Set Rs = Dvbbs.Execute("SELECT Orders, Rootid, Depth, ParentID, Child, ParentStr FROM Dv_Board WHERE Boardid = " & Request("EditID"))
Orders = Rs(0)
Rootid = Rs(1)
Depth = Rs(2)
Parentid = Rs(3)
Child = Rs(4)
ParentStr = Rs(5) & "," & Request("EditID")
Set Rs = Nothing

'取Lastorders值
Sql = "SELECT Top 1 Orders FROM Dv_Board WHERE Rootid = " & Rootid & " ORDER BY Orders DESC"
Set Rs = Dvbbs.Execute(Sql)
Lastorders = Rs(0)
Set Rs = Nothing

'取取移动结属ORDERS值
If Child > 0 Then
Sql = "SELECT COUNT(*) FROM Dv_Board WHERE ParentStr LIKE '%" & ParentStr & "%' AND Rootid = " & Rootid
Set Rs = Dvbbs.Execute(Sql)
Nextorders = Orders + Rs(0)
Else
Nextorders = Orders
End If
Set Rs = Nothing

'取同级版面移下后上一个版面ORDERS值
Sql = "SELECT Top " & Uporders + 1 & " Orders, Child, ParentStr, BoardID FROM Dv_Board WHERE Rootid = " & Rootid & " AND Depth = " & Depth & " AND ParentID = " & Parentid & " AND Orders > " & Orders & " ORDER BY Orders"
Set Rs = Dvbbs.Execute(Sql)
If Rs.Eof And Rs.Bof Then
Frontorders = Lastorders
Else
Sql = Rs.GetRows(-1)
Frontorders = Sql(0,Ubound(Sql,2)) - 1
If Not Ubound(Sql,2) = Uporders Then
If Sql(1,Ubound(Sql,2)) > 0 Then
ParentStr = Sql(2,Ubound(Sql,2)) & "," & Sql(3,Ubound(Sql,2))
Set Rs = Dvbbs.Execute("SELECT COUNT(*) FROM Dv_Board WHERE ParentStr LIKE '%" & ParentStr & "%' AND Rootid = " & Rootid)
Frontorders = Sql(0,Ubound(Sql,2)) + Rs(0)
Else
Frontorders = Sql(0,Ubound(Sql,2))
End If
End If
End If
Doorders = Frontorders

'一次更新Orders
Sql = "UPDATE Dv_Board SET Orders = Orders + " & Doorders & " WHERE Rootid = " & Rootid & " AND Orders >= " & Orders & " AND Orders <= " & Nextorders & " OR Orders > " & Frontorders
'Response.Write Sql
Dvbbs.Execute(Sql)

End If
CheckAndFixBoard 0,1
RestoreBoardCache()
Response.Redirect "userBoard.asp?action=boardorders"
End Sub

Sub Addmaster(s,o,n)
Dim Arr, Pw, Oarr
Dim Classname, Titlepic
Set Rs = Dvbbs.Execute("SELECT Usertitle, GroupPic FROM Dv_UserGroups WHERE Usergroupid = 3")
If Not (Rs.Eof And Rs.Bof) Then
Classname = Rs(0)
Titlepic = Rs(1)
End If
Randomize
Pw = Cint(Rnd * 9000) + 1000
Arr = Split(s,"|")
Oarr = Split(o,"|")
Set Rs = Server.Createobject("Adodb.Recordset")
For i = 0 To Ubound(Arr)
Sql = "SELECT * FROM [Dv_User] WHERE Username = '" & Arr(i) & "'"
Rs.Open Sql,Conn,1,3
If Rs.Eof And Rs.Bof Then
Rs.Addnew
Rs("Username") = Arr(i)
Rs("Userpassword") = Md5(Pw,16)
Rs("Userclass") = Classname
Rs("UserGroupID") = 3
Rs("Titlepic") = Titlepic
Rs("UserWealth") = 100
Rs("Userep") = 30
Rs("Usercp") = 30
Rs("Userisbest") = 0
Rs("Userdel") = 0
Rs("Userpower") = 0
Rs("Lockuser") = 0
'加入更详细资料使登录与显示资料不会出错。
Rs("UserSex") = 1
Rs("UserEmail") = Arr(i) & "@sg188.com"
Rs("UserFace") = "Images/userface/image1.gif"
Rs("UserWidth") = 32
Rs("UserHeight") = 32
Rs("UserIM") = "||||||||||||||||||"
Rs("UserFav") = "陌生人,我的好友,黑名单"
Rs("LastLogin") = Now()
Rs("JoinDate") = Now()
Rs("Userpost") = 0
Rs("Usertopic") = 0
Rs.Update
Str = Str & "你添加了以下用户：<b>" & Arr(i) & "</b> 密码：<b>" & Pw & "</b><br><br>"
Dvbbs.Execute("UPDATE Dv_Setup SET Forum_Usernum = Forum_Usernum + 1, Forum_Lastuser = '" & Arr(i) & "'")
Else
'修正添加吧主不改变等级的错误 2005-3-7 Dv.Yz
If Rs("UserGroupID") > 3 Then
Rs("Userclass") = Classname
Rs("UserGroupID") = 3
Rs("Titlepic") = Titlepic
Rs.Update
End If
End If
Rs.Close
Next
'判断原吧主在其他版面是否还担任吧主，如没有担任则撤换该用户职位。
If n = 1 Then
Dim Iboardmaster
Dim UserGrade, Article
Iboardmaster = False
For i = 0 To Ubound(Oarr)
Set Rs = Dvbbs.Execute("SELECT Boardmaster FROM Dv_Board")
Do While Not Rs.Eof
If Instr("|" & Trim(Rs("Boardmaster")) & "|","|" & Trim(Oarr(i)) & "|") > 0 Then
Iboardmaster = True
Exit Do
End If
Rs.Movenext
Loop
If Not Iboardmaster Then
Set Rs = Dvbbs.Execute("SELECT Userid, UserGroupID, UserPost FROM [Dv_User] WHERE Username = '" & Trim(Oarr(i)) & "'")
If Not (Rs.Eof And Rs.Bof) Then
If Rs(1) > 2 Then
If Not Isnumeric(Rs(2)) Or Rs(2) = "" Then
Article = 0
Else
Article = Cstr(Rs(2))
End If
'取对应注册会员的等级
Set UserGrade = Dvbbs.Execute("SELECT TOP 1 Usertitle, Grouppic,UserGroupID FROM Dv_Usergroups WHERE Minarticle <= " & Article & " AND NOT MinArticle = -1 AND ParentGID = 4 ORDER BY MinArticle DESC")
If Not (UserGrade.Eof And UserGrade.Bof) Then
Dvbbs.Execute("UPDATE [Dv_User] SET UserGroupID = 10, Titlepic = '" & UserGrade(1) & "', Userclass = '" & UserGrade(0) & "' WHERE Userid = " & Rs(0))
End If
UserGrade.Close:Set UserGrade = Nothing
End If
End If
End If
Iboardmaster = False
Next
End If
Set Rs = Nothing
End Sub

Rem 子版面用户权限设置 重写2004-5-2 Dvbbs.YangZheng
Sub BoardPerMission()
Dim iUserGroupID(100), UserTitle(100),iParentID(100)
Dim Trs, Ars, k, ii
Dim Bn
Set Trs = Dvbbs.Execute("SELECT Usertitle,Usergroupid,ParentGID FROM Dv_UserGroups WHERE Not ParentGID=0 ORDER BY ParentGID,UserGroupId")
If Not (Trs.Eof And Trs.Bof) Then
Sql = Trs.GetRows(-1)
Trs.Close:Set Trs = Nothing
For ii = 0 To Ubound(Sql,2)
UserTitle(ii) = Sql(0,ii)
iUserGroupID(ii) = Sql(1,ii)
iParentID(ii) = Sql(2,ii)
Next
End If
%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
<tr>
<th height="25">编辑贴吧权限</th>
</tr>
<tr>
<td class=forumrow>
①您可以设置不同用户等级在不同贴吧内的权限，红色表示为该贴吧该用户等级使用的是用户定义属性<BR>
②该权限不能继承，比如您设置了一个包含下级贴吧的版面，那么只对您设置的版面生效而不对其下属贴吧生效<BR>
③如果您想设置生效，必须在设置页面<B>选择自定义设置</B>，选择了自定义设置后，这里设置的权限将<B>优先</B>于用户等级设置，比如用户等级默认不能管理帖子，而这里设置了该用户等级可管理帖子，那么该用户等级在这个版面就可以管理帖子
</td>
</tr>
</table><BR>
<table width="95%" cellspacing="1" cellpadding="1" align=center class="tableBorder">
<tr> 
<th width="35%" class="tableHeaderText" height=25>贴吧版面
</th>
<th width="35%" class="tableHeaderText" height=25>设置用户等级权限
</th>
</tr>
<%
Dim Percount
Sql = "SELECT Depth, Child, Parentid, BoardType, Boardid,IsGroupSetting FROM Dv_Board ORDER BY Rootid, Orders"
Set Rs = Dvbbs.Execute(Sql)
If Not (Rs.Eof And Rs.Bof) Then
Sql = Rs.GetRows(-1)
Set Rs = Nothing
For Bn = 0 To Ubound(Sql,2)
Response.Write "<tr><td height=25 width=40% class=forumrow>"
If Sql(0,Bn) > 0 Then
For i = 1 To Sql(0,Bn)
Response.Write "&nbsp;"
Next
End If
If Sql(1,Bn) > 0 Then
Response.Write "<img src=../skins/default/plus.gif>"
Else
Response.Write "<img src=../skins/default/nofollow.gif>"
End If
If Sql(2,Bn) = 0 Then
Response.Write "<b>"
End If
Response.Write Sql(3,Bn)
If Sql(1,Bn) > 0 Then
Response.Write "(" & Sql(1,Bn) & ")"
End If
'Percount = Dvbbs.Execute("SELECT COUNT(*) FROM Dv_BoardPermission WHERE Boardid = " & Sql(4,Bn))(0)
%>
</td>
<FORM METHOD=POST ACTION="?action=editpermission">
<td width=60% class="forumrow">&nbsp;
<select name="groupid" size=1>
<%
For k = 0 To ii-1
Response.Write "<option value=""" & iUserGroupID(k) & """>" & SysGroupName(iParentID(k)) & UserTitle(k)
If Sql(5,Bn)<>"" Then
Set Ars = Dvbbs.Execute("SELECT Pid FROM Dv_BoardPerMission WHERE BoardID = " & Sql(4,Bn) & " AND GroupID = " & iUserGroupID(k))
If Not Ars.Eof Then
Response.Write "(自定义)"
End If
End If
Response.Write "</option>"
Next
Response.Write "</select><input type=hidden value="
Response.Write Sql(4,Bn)
Response.Write " name=reboardid><input type=submit name=submit value=设置>"
If Sql(5,Bn)<>"" Then
Response.Write "(有自定义版面)"
End If
Response.Write "</td></FORM></tr>"
Next
End If
Response.Write "</table><BR><BR>"
Set Ars = Nothing
Set Trs = Nothing
End Sub

Sub editpermission()
if not isnumeric(request("groupid")) Or request("groupid")="" Or request("reBoardID")="" Or not isnumeric(request("reBoardID"))  then
response.write "错误的参数，请返回子版面权限设置首页选择正确的设置！"
exit sub
end if
if request("groupaction")="yes" then
dim GroupSetting,rspid,SaveGroupid,NewGroupid
Dim IsGroupSetting,MyIsGroupSetting
Dim Sql,i,k
Dim UpdateStr,OldStr,NewStr
GroupSetting=GetGroupPermission
If Not IsNumeric(Replace(Request.Form("GroupID"),",","")) or Request.Form("GroupID")="" Then
Errmsg = ErrMsg + "<BR><li>请选择对应的用户等级。"
Dvbbs_Error()
Exit Sub
End If
SaveGroupid = Request.Form("groupid")
Set rs= Server.CreateObject("ADODB.Recordset")
if Request("isdefault")=1 then
'清理ID
Dvbbs.Execute("Delete from dv_BoardPermission where BoardID="&request.Form("reBoardID")&" and GroupID in ("&SaveGroupid&")")
Else
'使用自定义
sql="Select Pid,GroupID,PSetting from dv_BoardPermission where BoardID="&request("reBoardID")&" And GroupID in ("&SaveGroupid&") "
NewGroupid = ","&SaveGroupid&","
Set Rs=Dvbbs.Execute(sql)
If Not Rs.eof And Not Rs.bof Then
If Instr(SaveGroupid,",")=0 Then
sql="update dv_BoardPermission set PSetting='"&GroupSetting&"' where pid="&Rs(0)
Dvbbs.Execute(Sql)
NewGroupid = ""
Else
Do while Not Rs.Eof
NewStr = Split(GroupSetting,",")
OldStr = Split(Rs(2),",")
UpdateStr = ""
For K = 0 To 90
If Request.Form("CheckGroupSetting("&K&")")="on" Then
UpdateStr = UpdateStr & NewStr(k)
Else
UpdateStr = UpdateStr & OldStr(k)
End If
If K<90 Then
UpdateStr = UpdateStr & ","
End If
Next
sql="update dv_BoardPermission set PSetting='"&UpdateStr&"' where pid="&Rs(0)
Dvbbs.Execute(Sql)
NewGroupid = Replace(NewGroupid,","&Rs(1)&",",",")
Rs.MoveNext
Loop
End If
Else
Dim iSaveGroupID
iSaveGroupID = Split(SaveGroupid,",")
For i = 0 To Ubound(iSaveGroupID)
sql="insert into dv_BoardPermission (BoardID,GroupID,PSetting) values ("&request("reBoardID")&","&iSaveGroupID(i)&",'"&GroupSetting&"')"
Dvbbs.Execute(Sql)
Next
NewGroupid = ""
End If
Set Rs=Nothing


If Replace(NewGroupid,",","")<>"" Then
'有新组添加
NewGroupid = Split(NewGroupid,",")
For i=1 to Ubound(NewGroupid)-1
Sql = Dvbbs.Execute("select GroupSetting From Dv_UserGroups where UserGroupID="&NewGroupid(i))(0)
If Sql<>"" Then
NewStr = Split(GroupSetting,",")
OldStr = Split(Sql,",")
UpdateStr = ""
For K = 0 To 90
If Request.Form("CheckGroupSetting("&K&")")="on" Then
UpdateStr = UpdateStr & NewStr(k)
Else
UpdateStr = UpdateStr & OldStr(k)
End If
If K<90 Then
UpdateStr = UpdateStr & ","
End If
Next
sql="insert into dv_BoardPermission (BoardID,GroupID,PSetting) values ("&request("reBoardID")&","&NewGroupid(i)&",'"&UpdateStr&"')"
Dvbbs.Execute(Sql)
End If
Next
End If
End If

'重新提取有自定义的ID
Sql = "select GroupID From Dv_BoardPermission Where BoardID="&request.Form("reBoardID")
Set Rs=Dvbbs.Execute(Sql)
If Not Rs.eof Then
MyIsGroupSetting=Rs.GetString(,-1, "", ",", "")
MyIsGroupSetting = Left(MyIsGroupSetting,InStrRev(MyIsGroupSetting,",")-1)
Else
MyIsGroupSetting = ""
End If
Rs.close:Set Rs = Nothing
Dvbbs.Execute("update dv_Board set IsGroupSetting='"&MyIsGroupSetting&"' Where BoardID="&request("reBoardID"))
RestoreBoardCache()
Set Rs=Nothing
Dv_suc("修改成功！")
Else
Dim reGroupSetting,reBoardID,groupid
Dim Groupname,Boardname,founduserper
founduserper=false
if request("GroupID")<>"" then
set rs=Dvbbs.Execute("select * from dv_BoardPermission where boardid="&request("reBoardID")&" and GroupID="&request("GroupID"))
if rs.eof and rs.bof then
founduserper=false
else
groupid=rs("groupid")
reGroupSetting=rs("PSetting")
reBoardID=rs("boardid")
set rs=Dvbbs.Execute("select usertitle from dv_UserGroups where usergroupid="&groupid)
groupname=rs("usertitle")
founduserper=true
end if
if not founduserper then
set rs=Dvbbs.Execute("select * from dv_usergroups where usergroupid="&request("groupid"))
if rs.eof and rs.bof then
response.write "未找到该用户等级！"
exit sub
end if
groupid=request("groupid")
reGroupSetting=rs("GroupSetting")
reBoardID=request("reBoardID")
Groupname=rs("usertitle")
end if
end if
set rs=Dvbbs.Execute("select boardtype from dv_board where boardid="&reBoardID)
Boardname=rs("boardtype")
%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
<FORM METHOD=POST ACTION="?action=editpermission">
<input type=hidden name="groupid" value="<%=groupid%>">
<input type=hidden name="reBoardID" value="<%=reBoardID%>">
<input type=hidden name="pID" value="<%=request("pid")%>">
<tr> 
<th height="23" colspan="4" >编辑贴吧用户等级权限&nbsp;>> <%=boardname%>&nbsp;>> <%=groupname%></th>
</tr>
<tr> 
<td height="23" colspan="4" class=forumrow><input type=radio name="isdefault" value="1" <%if not founduserper then%>checked<%end if%>><B>使用用户等级默认值</B> (注意: 这将删除任何之前所做的自定义设置)</td>
</tr>
<tr> 
<td height="23" colspan="4"  class=forumrow><input type=radio name="isdefault" value="0" <%if founduserper then%>checked<%end if%>><B>使用自定义设置</B>&nbsp;(选择自定义才能使以下设置生效) </td>
</tr>
<tr> 
<td height="23" colspan="4"  class=forumrow>
①<font color="red">在更新多个用户等级设置时，请选取最左边的复选表单，只有选取的设置项目才会更新；</font>;
<BR>②不执行多用户等级更新时，不需要选取左边的复选表单；
<br><b>批量更新用户等级设置</b>：<input type="button" value="选择用户等级" onclick="getGroup('Select_Group');">
 <INPUT TYPE="checkbox" NAME="chkall" onclick="CheckAll(this.form);">[全选]
</td>
</tr>
<%
GroupPermission(reGroupSetting)
%>
<input type=hidden value="yes" name="groupaction">
</FORM>
</table>
<%
Call Select_Group(Request("groupid"))
end if
end sub

sub RestoreBoard()
'按照目前的排序循环i数值更新rootid
'还原所有版面的depth,orders,parentid,parentstr,child为0
i=0
set rs=Dvbbs.Execute("select boardid from dv_board order by rootid,orders")
do while not rs.eof
i=i+1
Dvbbs.Execute("update dv_board set rootid="&i&",depth=0,orders=0,ParentID=0,ParentStr='0',child=0 where boardid="&rs(0))
rs.movenext
loop
Set Rs=Nothing
Dv_suc("请返回做贴吧归属设置。复位")
RestoreBoardCache()
End sub

Sub clearDate
If Dvbbs.Boardid=0 Then
errmsg=errmsg+"<br><li>请选择贴吧版面"
dvbbs_error()
Exit Sub
End If
Dim Rs,str1,str2,str3,str4
Set Rs=Dvbbs.Execute("Select Count(*) from dv_topic where Boardid="& Dvbbs.boardid &"")
str1=Rs(0)
str3=0
str4=0
For i= 0 to UBound(AllPostTable)
Set Rs=Dvbbs.Execute("Select Count(*) from "&AllPostTable(i)&" where Boardid="& Dvbbs.boardid &"")
str2=str2&"其中在"&AllPostTable(i)&"有"&Rs(0)&"篇文章，"
str3=str3+Rs(0)
Set Rs=Dvbbs.Execute("Select Count(*) from "&AllPostTable(i)&" where Boardid="& Dvbbs.boardid &" and isbest=1")
str4=str4+Rs(0)
Next
Response.Write"<br>"
Response.Write"<table cellpadding=0 cellspacing=0 align=center class=""tableBorder"" style=""width:90%"">"
Response.Write"<tr align=center>"
Response.Write"<th width=""100%"" height=25 colspan=2>"
Response.Write Dvbbs.BoardType
Response.Write "-贴子信息"
Response.Write"</td>"
Response.Write"</tr>"
Response.Write"<tr>"
Response.Write"<td width=""100%"" class=""ForumrowHighLight"" colspan=2>"
Response.Write "<li>主题总数:<b>"
Response.Write str1
Response.Write "</b><li>文章总数:<b>"
Response.Write str3
Response.Write "</b><li>"
Response.Write str2
Response.Write "<li>有<B>"&str4&"</B>篇精华文章"
Response.Write"</td></tr>"
Response.Write "<form action =""?action=delDate&boardid="&Dvbbs.boardid&""" method=post>"
Response.Write"<tr>"
Response.Write"<td class=""ForumrowHighLight"" valign=middle colspan=2 align=left><li>  清除<b>"
Response.Write Dvbbs.BoardType
Response.Write "</b>在 "
Response.Write "<select name=""tablelist""><option value=""all"">所有数据表</option>"
For i= 0 to UBound(AllPostTable)
Response.Write "<option value="""&AllPostTable(i)&""">"
Response.Write AllPostTableName(i)
Response.Write "</option>"
Next 
Response.Write "</select>"
Response.Write " 中 <input type=text name=dd value=365 size=5 > 天前的贴子"
Response.Write " <input type=""submit"" name=""Submit"" value=""执 行""> <b>注意:此操作不可恢复！</b>其中精华贴不会被删除。<BR><BR>如果您的贴吧数据众多，执行此操作将消耗大量的服务器资源，执行过程请耐心等候，最好选择夜间在线人少的时候更新。"
Response.Write "</td></tr>"
Response.Write "</form>"
Response.Write"</table>"
End Sub
Sub delDate
If Dvbbs.Boardid=0 Then
errmsg=errmsg+"<br><li>请选择贴吧版面"
dvbbs_error()
Exit Sub
End If
Dim tablelist
If request.form("tablelist")<>"all" Then
tablelist=Dvbbs.checkstr(request.form("tablelist"))
Else
For i= 0 to UBound(AllPostTable)
If i=0 Then
tablelist=AllPostTable(i)
Else
tablelist=tablelist&","&AllPostTable(i)
End If
Next
End If
tablelist=split(tablelist,",")
Dim SqlTopic
Dim k
k=0
For i= 0 to UBound(tablelist)
'删除数据表记录
If IsSqlDataBase=1 Then
SqlTopic="Select TopicID,isvote,PollID from dv_Topic where Boardid="&Dvbbs.boardid&" and isbest=0 and PostTable='"&tablelist(i)&"' and Datediff(d,LastPostTime,"&SqlNowString&") > "& CLng(request.form("dd"))&" "
Else
SqlTopic="Select TopicID,isvote,PollID from dv_Topic where Boardid="&Dvbbs.boardid&" and isbest=0 and PostTable='"&tablelist(i)&"' and Datediff('d',LastPostTime,"&SqlNowString&") > "& CLng(request.form("dd"))&" "
End If
Set rs=Dvbbs.Execute(SqlTopic)
Do While Not Rs.Eof
Sql="Delete from "&tablelist(i)&" where Boardid="&Dvbbs.boardid&" and rootid="&RS(0)&""
Dvbbs.Execute(Sql) 
If Rs(1)=1 And Not IsNull(Rs(2)) Then
Sql="Delete from dv_vote where voteid="&RS(2)&""
Dvbbs.Execute(Sql)
End If 
Rs.movenext
k=k+1
Loop 
'删除主题表记录
If IsSqlDataBase=1 Then
SqlTopic="Delete from dv_Topic where Boardid="&Dvbbs.boardid&" and isbest=0 and PostTable='"&tablelist(i)&"' and Datediff(d,LastPostTime,"&SqlNowString&") > "& CLng(request.form("dd"))&" "
Else
SqlTopic="Delete from dv_Topic where Boardid="&Dvbbs.boardid&" and isbest=0 and PostTable='"&tablelist(i)&"' and Datediff('d',LastPostTime,"&SqlNowString&") > "& CLng(request.form("dd"))&" "
End If
Dvbbs.Execute(SqlTopic) 
Set rs=Nothing 
Next
Response.Write "删除了"&k&"个主题。"
End Sub

Sub RestoreClass()
Dim ClassID,RootID,RootIDNum,ParentID
ClassID=Request("ClassID")
If Not IsNumeric(ClassID) Or ClassID="" Then
Response.Write "错误的版面参数！"
Exit Sub
Else
ClassID=Clng(ClassID)
End If
Set Rs=Dvbbs.Execute("Select RootID,BoardID From Dv_Board Where BoardID="&ClassID)
If Rs.Eof And Rs.Bof Then
Response.Write "错误的版面参数！"
Exit Sub
Else
RootID=Rs(0)
ParentID=Rs(1)
End If
i=0
Set Rs=Dvbbs.Execute("Select BoardID,ParentID From Dv_Board Where RootID="&RootID&" Order By ParentID,Orders,Depth")
Do While Not Rs.Eof
If Rs(1)=0 Then
Dvbbs.Execute("UpDate Dv_Board Set Orders="&i&" Where BoardID="&Rs(0))
Else
Dvbbs.Execute("UpDate Dv_Board Set Orders="&i&",ParentID="&ParentID&",ParentStr='"&ParentID&"',Depth=1,child=0 Where BoardID="&Rs(0))
End If
i=i+1
Rs.MoveNext
Loop
Set Rs=Dvbbs.Execute("Select Count(*) From Dv_Board Where RootID="&RootID)
RootIDNum=Rs(0)
If IsNull(RootIDNum) Or RootIDNum="" Then
RootIDNum=0
Else
RootIDNum=RootIDNum-1
End If
Dvbbs.Execute("UpDate Dv_Board Set Child="&RootIDNum&" Where BoardID="&ClassID)
dv_suc("复位分类成功！")
RestoreBoardCache()
Set Rs=Nothing
End Sub

Sub handorders()
%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
<tr> 
<th height="22">贴吧分类重新排序修改(请在相应贴吧分类的排序表单内输入相应的排列序号)
</th>
</tr>
<tr>
<td class="Forumrow">
<B>注意</B>：<BR>
1、由于本贴吧排序算法不是递归，所以请正确输入排序的序号，否则将引起贴吧显示不正常，<font color=red>如果您未正确了解说明，请不要随意更改</font><BR>
2、一级分类排序序号为0，请正确输入，<font color=blue>所有输入框请输入数字</font><BR>
3、排序规则为数字最大的排在后面，<font color=blue>在这里不能用排序来指定某个版面的所属分类或版面</font>，如下为正确的排序输入方式：<BR>
<B>分类</B> 0<BR>
--二级版面A 1<BR>
--二级版面B 2<BR>
----三级版面A 3<BR>
----三级版面B 4<BR>
----三级版面C 5<BR>
--二级版面C 6<BR>
A.<font color=blue>要把三级版面C提到三级版面A上面</font>，则依次输入：分类(0)-二级A(1)-二级B(2)-三级A(<font color=red>4</font>)-三级B(<font color=red>5</font>)-三级C(<font color=red>3</font>)-二级C(6)<BR>
B.<font color=blue>要把二级版面C提到二级版面B上面</font>，则依次输入：分类(0)-二级A(1)-二级B(<font color=red>3</font>)-三级A(<font color=red>4</font>)-三级B(<font color=red>5</font>)-三级C(<font color=red>6</font>)-二级C(<font color=red>2</font>)<BR>
B.<font color=blue>要把二级版面B提到二级版面A上面</font>，则依次输入：分类(0)-二级A(<font color=red>5</font>)-二级B(<font color=red>1</font>)-三级A(<font color=red>2</font>)-三级B(<font color=red>3</font>)-三级C(<font color=red>4</font>)-二级C(6)
</td></tr>
<form action="userBoard.asp?action=savehandorders" method=post>
<tr>
<td class="Forumrow"><table width="90%">
<%
dim trs,uporders,doorders,RootID
Set Rs=Dvbbs.Execute("Select RootID From Dv_Board Where BoardID="&Request("classid"))
If Rs.eof And Rs.bof Then
response.write "还没有相应的贴吧分类。"
exit sub
Else
RootID=Rs(0)
End If
set rs = server.CreateObject ("Adodb.recordset")
sql="select * from dv_Board Where RootID="&RootID&" order by RootID,orders"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "还没有相应的贴吧分类。"
else
do while not rs.eof
response.write "<tr><td width=""50%"">"
if rs("depth")>0 then
for i=1 to rs("depth")
response.write "&nbsp;"
next
end if
if rs("child")>0 then
response.write "<img src=../skins/default/plus.gif>"
else
response.write "<img src=../skins/default/nofollow.gif>"
end if
if rs("parentid")=0 then
response.write "<b>"
end if
response.write rs("boardtype")
if rs("child")>0 then
response.write "("&rs("child")&")"
end if
response.write "</td><td width=""50%"">"
Response.Write "<input type=hidden value="""&rs("boardid")&""" name=getboard>"
Response.Write "<input type=text size=5 value="""&rs("orders")&""" name=orders>"
response.write "</td></tr>"
uporders=0
doorders=0
rs.movenext
loop
Response.Write "<tr><td class=Forumrow><input type=submit name=submit value=提交></td></tr>"
response.write "</table>"
end if
rs.close
set rs=nothing
%>
</td>
</tr></form>
</table>
<%
End Sub

Sub savehandorders()
dim cID,OrderID,ClassName
cID=replace(request.form("getboard"),"'","")
OrderID=replace(request.form("Orders"),"'","")
For i=1 to request.form("getboard").count
cID=request.form("getboard")(i)
OrderID=request.form("Orders")(i)
Dvbbs.Execute("Update Dv_Board Set Orders="&OrderID&" Where BoardID="&cID)
next
Dv_suc("更改分类排序成功！")
CheckAndFixBoard 0,1
RestoreBoardCache()
End Sub

Sub RestoreBoardCache()

Dim Board
Dvbbs.LoadBoardList()
For Each board in Application(Dvbbs.CacheName&"_boardlist").documentElement.selectNodes("board/@boardid")
Dvbbs.LoadBoardData board.text
Dvbbs.LoadBoardinformation board.text
Next
If Request("action")="RestoreBoardCache" Then dv_suc("重建所有版面缓存成功！")
End Sub
Sub CheckAndFixBoard(ParentID,orders)
Dim Rs,Child,ParentStr
If ParentID=0 Then
Dvbbs.Execute("update dv_board set Depth=0,ParentStr='0' where ParentID=0")
End If
Set Rs=Dvbbs.Execute("Select BoardID,rootid,ParentStr,Depth From Dv_Board  where ParentID="&ParentID&" order by Rootid,orders")
Do while Not Rs.EOF
If Rs(2)<>"0" Then
ParentStr=Rs(2)&","&Rs(0)
Else
ParentStr=Rs(0)
End If
Conn.Execute "update dv_board set Depth="&Rs(3)+1&",ParentStr='"&ParentStr&"',rootid="&rs(1)&" where ParentID="&Rs(0)&"",Child
Dvbbs.Execute("update dv_board set Child="&Child&",orders="&orders&" Where BoardID="&Rs(0)&"")
orders=orders+1
CheckAndFixBoard Rs(0),orders
Rs.MoveNext
Loop
Set Rs=Nothing
End Sub
%>