📄 admin_server.asp
字号:
Dim depth
Dim orders
Dim Maxrootid
Dim strParent
Dim neworders
'保存添加服务器信息
If Request("ServerName") = "" Then
ErrMsg = ErrMsg + "<br>" + "<li>请输入服务器名称。"
Founderr = True
Exit Sub
End If
If Request("class") = "" Then
ErrMsg = ErrMsg + "<br>" + "<li>请选择服务器分类。"
Founderr = True
Exit Sub
End If
If Server.HTMLEncode(Request("ServerUrl")) = "" Then
ErrMsg = ErrMsg + "<br>" + "<li>请输入服务器地址。"
Founderr = True
Exit Sub
End If
Set Rs = Server.CreateObject("adodb.recordset")
If Request("class") <> "0" Then
SQL = "select rootid,serverid,depth,orders,strparent from NC_ServerSite where serverid=" & Request("class")
Rs.Open SQL, Conn, 1, 1
rootid = Rs(0)
ParentID = Rs(1)
depth = Rs(2)
orders = Rs(3)
If depth + 1 > 1 Then
ErrMsg = "<li>本系统限制最多只能有1级子服务器</li>"
Founderr = True
Exit Sub
End If
strParent = Rs(4)
Rs.Close
neworders = orders
SQL = "select max(orders) from NC_ServerSite where ParentID=" & Request("class")
Rs.Open SQL, Conn, 1, 1
If Not (Rs.EOF And Rs.bof) Then
neworders = Rs(0)
End If
If IsNull(neworders) Then neworders = orders
Rs.Close
DownsysClass.Execute ("update NC_ServerSite set orders=orders+1 where orders>" & CInt(neworders) & "")
Else
SQL = "select max(rootid) from NC_ServerSite"
Rs.Open SQL, Conn, 1, 1
Maxrootid = Rs(0) + 1
If IsNull(Maxrootid) Then Maxrootid = 1
Rs.Close
End If
SQL = "select serverid from NC_ServerSite where serverid=" & Request("newserverid")
Rs.Open SQL, Conn, 1, 1
If Not (Rs.EOF And Rs.bof) Then
ErrMsg = "<li>您不能指定和别的服务器一样的序号。</li>"
Founderr = True
Exit Sub
Else
serverid = Request("newserverid")
End If
Rs.Close
SQL = "select * from NC_ServerSite"
Rs.Open SQL, Conn, 1, 3
Rs.addnew
If Request("class") <> "0" Then
Rs("depth") = depth + 1
Rs("rootid") = rootid
Rs("orders") = neworders + 1
Rs("parentid") = Request.Form("class")
If strParent = "0" Then
Rs("strparent") = Request.Form("class")
Else
Rs("strparent") = strParent & "," & Request.Form("class")
End If
Else
Rs("depth") = 0
Rs("rootid") = Maxrootid
Rs("orders") = 0
Rs("parentid") = 0
Rs("strparent") = 0
End If
Rs("child") = 0
Rs("serverid") = Request.Form("newserverid")
Rs("ServerName") = Server.HTMLEncode(Request.Form("ServerName"))
Rs("ServerUrl") = Server.HTMLEncode(Request.Form("ServerUrl"))
Rs.Update
Rs.Close
If Request("class") <> "0" Then
If depth > 0 Then DownsysClass.Execute ("update NC_ServerSite set child=child+1 where serverid in (" & strParent & ")")
DownsysClass.Execute ("update NC_ServerSite set child=child+1 where serverid=" & Request("class"))
End If
SucMsg = "<li>服务器添加成功!</li>"
NC_Admin.Succeed_Msg (SucMsg)
Set Rs = Nothing
End Sub
Private Sub savedit()
Dim newserverid
Dim Maxrootid
Dim ParentID
Dim depth
Dim Child
Dim strParent
Dim rootid
Dim iparentid
Dim istrparent
Dim trs
Dim brs
Dim mrs
Dim k
Dim nstrparent
Dim mstrparent
Dim ParentSql
Dim boardcount
'保存编辑服务器信息
If CLng(Request("editid")) = CLng(Request("class")) Then
ErrMsg = "<li>所属服务器不能指定自己</li>"
Founderr = True
Exit Sub
End If
Set Rs = CreateObject("adodb.recordset")
SQL = "select * from NC_ServerSite where serverid=" & Request("editid")
Rs.Open SQL, Conn, 1, 3
newserverid = Rs("serverid")
ParentID = Rs("parentid")
iparentid = Rs("parentid")
strParent = Rs("strparent")
depth = Rs("depth")
Child = Rs("child")
rootid = Rs("rootid")
If ParentID = 0 Then
If CLng(Request("class")) <> 0 Then
Set trs = DownsysClass.Execute("select rootid from NC_ServerSite where serverid=" & Request("class"))
If rootid = trs(0) Then
ErrMsg = "<li>您不能指定该服务器的下属服务器作为所属服务器</li>"
Founderr = True
Exit Sub
Response.End
End If
End If
Else
Set trs = DownsysClass.Execute("select serverid from NC_ServerSite where strparent like '%" & strParent & "%' and serverid=" & Request("class"))
If Not (trs.EOF And trs.bof) Then
ErrMsg = "<li>您不能指定该服务器的下属服务器作为所属服务器</li>"
Founderr = True
Exit Sub
Response.End
End If
End If
If ParentID = 0 Then
ParentID = Rs("serverid")
iparentid = 0
End If
Rs("ServerName") = Server.HTMLEncode(Request.Form("ServerName"))
Rs("ServerUrl") = Server.HTMLEncode(Request("ServerUrl"))
Rs.Update
Rs.Close
Set Rs = Nothing
Set mrs = DownsysClass.Execute("select max(rootid) from NC_ServerSite")
Maxrootid = mrs(0) + 1
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
DownsysClass.Execute ("update NC_ServerSite set depth=0,orders=0,rootid=" & Maxrootid & ",parentid=0,strparent='0' where serverid=" & newserverid)
strParent = strParent & ","
Set Rs = DownsysClass.Execute("select count(*) from NC_ServerSite where strparent like '%" & strParent & "%'")
boardcount = Rs(0)
If IsNull(boardcount) Then
boardcount = 1
Else
boardcount = boardcount + 1
End If
DownsysClass.Execute ("update NC_ServerSite set child=child-" & boardcount & " where serverid=" & iparentid)
For i = 1 To depth
Set Rs = DownsysClass.Execute("select parentid from NC_ServerSite where serverid=" & iparentid)
If Not (Rs.EOF And Rs.bof) Then
iparentid = Rs(0)
DownsysClass.Execute ("update NC_ServerSite set child=child-" & boardcount & " where serverid=" & iparentid)
End If
Next
If Child > 0 Then
i = 0
Set Rs = DownsysClass.Execute("select * from NC_ServerSite where strparent like '%" & strParent & "%'")
Do While Not Rs.EOF
i = i + 1
mstrparent = Replace(Rs("strparent"), strParent, "")
DownsysClass.Execute ("update NC_ServerSite set depth=depth-" & depth & ",rootid=" & Maxrootid & ",strparent='" & mstrparent & "' where serverid=" & Rs("serverid"))
Rs.movenext
Loop
End If
ElseIf iparentid > 0 And CInt(Request("class")) > 0 Then
Set trs = DownsysClass.Execute("select * from NC_ServerSite where serverid=" & Request("class"))
strParent = strParent & ","
Set Rs = DownsysClass.Execute("select count(*) from NC_ServerSite where strparent like '%" & strParent & "%'")
boardcount = Rs(0)
If IsNull(boardcount) Then boardcount = 1
DownsysClass.Execute ("update NC_ServerSite set orders=orders + " & boardcount & " + 1 where rootid=" & trs("rootid") & " and orders>" & trs("orders") & "")
DownsysClass.Execute ("update NC_ServerSite set depth=" & trs("depth") & "+1,orders=" & trs("orders") & "+1,rootid=" & trs("rootid") & ",ParentID=" & Request("class") & ",strparent='" & trs("strparent") & "," & trs("serverid") & "' where serverid=" & newserverid)
i = 1
Set Rs = DownsysClass.Execute("select * from NC_ServerSite where strparent like '%" & strParent & "%' order by orders")
Do While Not Rs.EOF
i = i + 1
istrparent = trs("strparent") & "," & trs("serverid") & "," & Replace(Rs("strparent"), strParent, "")
DownsysClass.Execute ("update NC_ServerSite set depth=depth+" & trs("depth") & "-" & depth & "+1,orders=" & trs("orders") & "+" & i & ",rootid=" & trs("rootid") & ",strparent='" & istrparent & "' where serverid=" & Rs("serverid"))
Rs.movenext
Loop
ParentID = Request("class")
If rootid = trs("rootid") Then
DownsysClass.Execute ("update NC_ServerSite set child=child+" & i & " where (not ParentID=0) and serverid=" & ParentID)
For k = 1 To trs("depth")
Set Rs = DownsysClass.Execute("select parentid from NC_ServerSite where (not ParentID=0) and serverid=" & ParentID)
If Not (Rs.EOF And Rs.bof) Then
ParentID = Rs(0)
DownsysClass.Execute ("update NC_ServerSite set child=child+" & i & " where (not ParentID=0) and serverid=" & ParentID)
End If
Next
DownsysClass.Execute ("update NC_ServerSite set child=child-" & i & " where (not ParentID=0) and serverid=" & iparentid)
For k = 1 To depth
Set Rs = DownsysClass.Execute("select parentid from NC_ServerSite where (not ParentID=0) and serverid=" & iparentid)
If Not (Rs.EOF And Rs.bof) Then
iparentid = Rs(0)
DownsysClass.Execute ("update NC_ServerSite set child=child-" & i & " where (not ParentID=0) and serverid=" & iparentid)
End If
Next
Else
DownsysClass.Execute ("update NC_ServerSite set child=child+" & i & " where serverid=" & ParentID)
For k = 1 To trs("depth")
Set Rs = DownsysClass.Execute("select parentid from NC_ServerSite where serverid=" & ParentID)
If Not (Rs.EOF And Rs.bof) Then
ParentID = Rs(0)
DownsysClass.Execute ("update NC_ServerSite set child=child+" & i & " where serverid=" & ParentID)
End If
Next
DownsysClass.Execute ("update NC_ServerSite set child=child-" & i & " where serverid=" & iparentid)
For k = 1 To depth
Set Rs = DownsysClass.Execute("select parentid from NC_ServerSite where serverid=" & iparentid)
If Not (Rs.EOF And Rs.bof) Then
iparentid = Rs(0)
DownsysClass.Execute ("update NC_ServerSite set child=child-" & i & " where serverid=" & iparentid)
End If
Next
End If
Else
Set trs = DownsysClass.Execute("select * from NC_ServerSite where serverid=" & Request("class"))
Set Rs = DownsysClass.Execute("select count(*) from NC_ServerSite where rootid=" & rootid)
boardcount = Rs(0)
ParentID = Request("class")
DownsysClass.Execute ("update NC_ServerSite set child=child+" & boardcount & " where serverid=" & ParentID)
For k = 1 To trs("depth")
Set Rs = DownsysClass.Execute("select parentid from NC_ServerSite where serverid=" & ParentID)
If Not (Rs.EOF And Rs.bof) Then
ParentID = Rs(0)
DownsysClass.Execute ("update NC_ServerSite set child=child+" & boardcount & " where serverid=" & ParentID)
End If
Next
DownsysClass.Execute ("update NC_ServerSite set orders=orders + " & boardcount & " + 1 where rootid=" & trs("rootid") & " and orders>" & trs("orders") & "")
i = 0
Set Rs = DownsysClass.Execute("select * from NC_ServerSite where rootid=" & rootid & " order by orders")
Do While Not Rs.EOF
i = i + 1
If Rs("parentid") = 0 Then
If trs("strparent") = "0" Then
strParent = trs("serverid")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -