<!-- #include file="../conn.asp" -->
<!-- #include file="../admin.asp" -->
<%Call Head()
Call saycarda("IP管理")%>

您的IP：<%=User_Ip%><br/>
<%
Talesql="select boolbase from IpLockFlag"
Set Talers=server.createobject("adodb.recordset")
Talers.open Talesql,Conn,1,1
	if not(Talers.bof and Talers.eof) then
	Boolbase=split(talers("boolbase"),"|")
	End if
Talers.close
Set Talers=nothing
Sub Erasearraybase()
Erase boolbase
End Sub
%>
<%
Call DoNoIpLock
Operate=Trim(Request("operate"))
If Operate="del" Then
	DelLock
ElseIf Operate="save" Then
	Call SaveLock
Else
	Call LockList
End if

Sub Locklist
Set Talers=Conn.ExeCute("Select * from IpLock order by ipid desc")
If Not Talers.Eof Then
i=0
%>
=封锁IP列表=<br/>
<%
Do while Not Talers.eof
i=i+1
Dim WhyIpLock
WhyIpLock=split(TaleRS("iplock"),"|")
%>
<%=i%>.
<%=RealLock(Talers("ipsame"),Talers("ip1"),Talers("ip2"),Talers("ip3"),Talers("ip4"))%>
<%=WhyIPLOck(1)%>
<a href='IpLock.Asp?operate=del&amp;ipid=<%=Talers("ipid")%>&amp;sid=<%=sid%>'>删除</a><br/>
<%
Talers.Movenext
Loop 
Else
Response.Write"目前没有IP封锁的记录"
End If
Talers.Close
Set Talers=Nothing
Call  LockAdd
End Sub

Sub LockAdd
If saytk<>1 then
Response.write "<form name=""form"" method=""post"" action=""IpLock.Asp?operate=save&amp;saytk="&saytk&"&amp;sid="&sid&""">"
End if
%>
<br/>-----------<br/>IP地址：
<input name="ip1" value="" type="text" format="*N" size="4"/>.
<input name="ip2" value="" type="text" format="*N" size="4"/>.
<input name="ip3" value="" type="text" format="*N" size="4"/>.
<input name="ip4" value="" type="text" format="*N" size="4"/>
<br/>IP段数：
<select name="ipsame" value="1">
<%
For i=1  to  4 
Response.write"<option value="""&i&""">前 "&i&" 段相同</option>"
Next
%>
</select>
<br/>原因说明：
<input name="reason" value=""/>
<%If saytk<>1 Then
response.write "<input type=""submit"" name=""Submit"" value=""封锁IP""></form><br/>"
else%>
<br/><anchor>封锁IP
<go href="IpLock.Asp?operate=save&amp;sid=<%=sid%>" method="post">
<postfield name="ip1" value="$(ip1:n)" />
<postfield name="ip2" value="$(ip2:n)" />
<postfield name="ip3" value="$(ip3:n)" />	
<postfield name="ip4" value="$(ip4:n)" />
<postfield name="ipsame" value="$(ipsame:n)" />	
<postfield name="reason" value="$(reason:n)" />	
</go></anchor><br/>

<%End if
End Sub
Sub SaveLock
DIm IPArr(3)
For i=0 to 3 
IPArr(i)=Trim(request.form("ip"&i+1&""))
If IpArr(i)="" Or IsNumeric(IpArr(i))=False Then 
	response.write ("错误提示：第"&i+1&"段必须数字")
response.write"<br/><a href='iplock.asp?sid="&sid&"'>返回IP管理</a><br/>"
	Exit Sub
End If
Next
	Lockss=Cint(IPArr(0))&"."&Cint(IPArr(1))&"."&Cint(IPArr(2))&"."&Cint(IPArr(3))
	if Lockss=User_Ip then
	call error("请不要尝试封锁自己的IP！")
End If

Conn.Execute("insert into IpLock (ip1,ip2,ip3,ip4,ipsame,iplock) values ("&Cint(IPArr(0))&","&Cint(IPArr(1))&","&Cint(IPArr(2))&","&Cint(IPArr(3))&","&Cint(Request.Form("ipsame"))&",'"&Now&"|"&Request.form("reason")&"')")
BoolBase=1
dim BoolBasef
BoolBasef=BoolBase&"|"
Conn.ExeCute("Update IpLockFlag set Boolbase='"&BoolBasef&"'")
response.write ("操作提示：ＩＰ-"&RealLock(Cint(Request.Form("ipsame")),iparr(0),iparr(1),iparr(2),iparr(3))&" 已被锁定！")
response.write"<br/><a href='iplock.asp?sid="&sid&"'>返回IP管理</a><br/>"
End Sub

Function RealLock(IPsame,Ip1,ip2,ip3,ip4)
IF IPsame=1 Then
	RealLock=""&IP1&".*.*.*"
ElseIF IPsame=2 Then
	RealLock=""&IP1&"."&IP2&".*.*"
ElseIF IPsame=3 Then
	RealLock=""&IP1&"."&IP2&"."&IP3&".*"
ElseIF IPsame=4 Then
	RealLock=""&IP1&"."&IP2&"."&IP3&"."&IP4&""
End IF
End Function

Sub DelLock
	Conn.Execute("Delete from IpLock where ipid="&Cint(Request("ipid"))&"")
	response.write ("操作提示：IP已被删除！")
response.write"<br/><a href='iplock.asp?sid="&sid&"'>返回IP管理</a><br/>"
End Sub

Sub DoNoIpLock()
Set Talers=Conn.Execute("select top 1 ipid from IpLock")
	If Talers.Eof Then
		BoolBase=0
dim BoolBasef
BoolBasef=BoolBase&"|"
		Conn.ExeCute("Update IpLockFlag set Boolbase='"&BoolBasef&"'")
	End If
Talers.Close
Set Talers=Nothing
End Sub
response.write"------------<br/>"&chr(13)
response.write"<a href='iphelp.asp?sid="&sid&"'>[操作说明]</a><br/>"
response.write"<a href='index.asp?sid="&sid&"'>[站长工具]</a><br/>"
response.write"<a href='../index.asp?sid="&sid&"'>[后台管理]</a>"
Call headsay()
%>


