Byzkxp2/15/2006http://zkxp.cnblogs.com
'The blocked IP address (segment) collection, the asterisk is a wildcard, and is usually saved in the configuration file.
<%
ConstBadIPGroup="220.200.59.136|220.205.168.141"
IfIsForbidIP(BadIPGroup)=TrueThen
Response.Write(GetUserIP&"IP address prohibited access")
Response.End()
EndIf
'************************************************************************
'Parameter vBadIP: IP segment to be blocked, IP address collection, separate multiple IP addresses (segments) with | symbols
'Return to Bool: True user IP is in blocked range, False is the opposite
'************************************************************************
FunctionIsForbidIP (vBadIP)
Dimcounter, arrIPPart, arrBadIP, arrBadIPPart, i, j
arrBadIP=Split(vBadIP,"|")
arrIPPart=Split(GetUserIP(),".")
Fori=0ToUBound(arrBadIP)
counter=0
arrBadIPPart=Split(arrBadIP(i),".")
Forj=0ToUBound(arrIPPart)
If(arrBadIPPart(j))="*"orCstr(arrIPPart(j))=Cstr(arrBadIPPart(j)) Then
counter=counter+1
EndIf
Next
Ifcounter=4Then
IsForbidIP=True
ExitFunction
EndIf
Next
IsForbidIP=False
EndFunction
'***************
'Return to the client IP address
'***************
FunctionGetUserIP()
DimIP
IP=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
IfIP=""ThenIP=Request.ServerVariables("REMOTE_ADDR")
GetUserIP=IP
EndFunction
%>