<!--#include file="setup.asp"-->
<%
Dim i, action, userip
Dim ips, GetIp1, GetIp2
Set Rs = Server.CreateObject("ADODB.Recordset")
NC_Admin.AdminChk = "53"
NC_Admin.Check
DownsysClass.admin_header
If Request("userip") <> "" Then
	userip = Request("userip")
	ips = Split(userip, ".")
	If UBound(ips) = 3 Then GetIp1 = ips(0) & "." & ips(1) & "." & ips(2) & ".*"
End If
action = Trim(Request("action"))
Select Case action
	Case "save"
		Call saveip
	Case "delip"
		Call delip
	Case "add"
		Call addip
	Case Else

		Call ListMain
End Select
If Founderr = True Then
	Response.redirect ("showerr.asp?action=error&Message=" & Server.URLEncode(ErrMsg) & "")
End If
DownsysClass.admin_footer
NothingObject
Public Sub addip()
	Response.Write "<table border=""0"" cellspacing=""1"" cellpadding=""3""  align=center class=""tableBorder"">" & vbCrLf
	Response.Write "<tr> " & vbCrLf
	Response.Write "<th width=""100%"" colspan=2>IP限制管理－－添加</th>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "<form action=""admin_Lockip.asp?action=save"" method=""post"">" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td width=""100%"" class=forumrow colspan=2><B>说明</B>：您可以添加多个限制IP，每个IP用|号分隔，限制IP的书写方式如202.152.12.1就限制了202.152.12.1这个IP的访问，如202.152.12.*就限制了以202.152.12开头的IP访问，同理*.*.*.*则限制了所有IP的访问。在添加多个IP的时候，请注意最后一个IP的后面不要加|这个符号</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td width=""20%"" class=forumrow>限制I&nbsp;P</td>" & vbCrLf
	Response.Write "<td width=""80%"" class=forumrow><input type=""text"" name=""ip1"" size=""38"" value=""" & GetIp1 & """>&nbsp;如202.152.12.*</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td width=""20%"" class=forumrow></td>" & vbCrLf
	Response.Write "<td width=""80%"" class=forumrow>" & vbCrLf
	Response.Write "<input type=""submit"" name=""Submit"" value=""添 加"" class=button>" & vbCrLf
	Response.Write "</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "</form>" & vbCrLf
	Response.Write "</table>" & vbCrLf
End Sub

Public Sub ListMain()
	Response.Write "<table border=""0"" cellspacing=""1"" cellpadding=""3""  align=center class=""tableBorder"">" & vbCrLf
	Response.Write "<FORM METHOD=POST ACTION=""?action=delip"">" & vbCrLf
	Response.Write "<tr> " & vbCrLf
	Response.Write "<th width=""100%"" colspan=2>IP限制管理－－管理</th>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td width=""100%"" class=forumrow colspan=2>" & vbCrLf
	Response.Write "<B>说明</B>：您可以添加多个限制IP，每个IP用回车分隔，限制IP的书写方式如202.152.12.1就限制了202.152.12.1这个IP的访问，如202.152.12.*就限制了以202.152.12开头的IP访问，同理*.*.*.*则限制了所有IP的访问。在添加多个IP的时候，请注意最后一个IP的后面不要加回车" & vbCrLf
	Response.Write "</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td width=""100%"" class=forumrow colspan=2>" & vbCrLf
	Response.Write "<textarea name=""ips"" cols=""80"" rows=""10"">" & vbCrLf
	Dim BadWord
	BadWord = Split(DownsysClass.Badwords, "|")
	userip = Split(Trim(DownsysClass.LockipList), "|")
	For i = 0 To UBound(userip)
		Response.Write userip(i)
		If i < UBound(BadWord) Then Response.Write Chr(10)
	Next
	Response.Write "</textarea>" & vbCrLf
	Response.Write "</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "<tr>" & vbCrLf
	Response.Write "<td width=""20%"" class=forumrow></td>" & vbCrLf
	Response.Write "<td width=""80%"" class=forumrow>" & vbCrLf
	Response.Write "<input type=""submit"" name=""Submit"" value=""修 改"" class=button>" & vbCrLf
	Response.Write "</td>" & vbCrLf
	Response.Write "</tr>" & vbCrLf
	Response.Write "</FORM>" & vbCrLf
	Response.Write "</table>" & vbCrLf
End Sub

Public Sub saveip()
	Dim sip
	If Trim(Request.Form("ip1")) = "" Then
		Founderr = True
		ErrMsg = ErrMsg + "<li>IP不能为空！</li>"
		Exit Sub
	End If
	sip = CStr(Request.Form("ip1"))
	If sip <> "" Then
		If Trim(DownsysClass.LockipList) <> "" Then
			sip = Trim(DownsysClass.LockipList) & "|" & Replace(sip, "|", "")
		End If
	End If
	If sip <> "" Then
		DownsysClass.Execute ("update NC_Config set LockipList='" & Replace(sip, "'", "''") & "'")
		DownsysClass.Name = "Config"
		DownsysClass.ReloadConfig
	End If
	NC_Admin.Succeed_Msg ("添加限制IP成功！")
End Sub

Public Sub delip()
	userip = Request("ips")
	userip = Split(userip, vbCrLf)
	For i = 0 To UBound(userip)
		If Not (userip(i) = "" Or userip(i) = " ") Then
			If i = 0 Then
				GetIp1 = userip(i)
			Else
				GetIp1 = GetIp1 & "|" & userip(i)
			End If
		End If
	Next
	DownsysClass.Execute ("update NC_Config set LockipList='" & Replace(GetIp1, "'", "''") & "'")
	DownsysClass.Name = "Config"
	DownsysClass.ReloadConfig
	NC_Admin.Succeed_Msg ("更新限制IP成功！")
End Sub
%>
