By zkxp 2/15/2006 http://zkxp.cnblogs.com
'The set of blocked IP addresses (segments). The asterisk is a wildcard and is usually stored in the configuration file.
<%
Const badipgroup = "220.200.59.136 | 220.205.168.141"
If isforbidip (badipgroup) = true then
Response. Write (getuserip & "Access prohibited from IP addresses ")
Response. End ()
End if
'*************************************** *************************
'Parameter vbadip: IP segment to be blocked, IP address set. Use the | symbol to separate multiple IP addresses (segments)
'Return bool: true: the user IP address is in the blocked range; false: otherwise
'*************************************** *************************
Function isforbidip (vbadip)
Dim counter, arrippart, arrbadip, arrbadippart, I, j
Arrbadip = Split (vbadip, "| ")
Arrippart = Split (getuserip (),".")
For I = 0 to ubound (arrbadip)
Counter = 0
Arrbadippart = Split (arrbadip (I ),".")
For J = 0 to ubound (arrippart)
If (arrbadippart (j) = "*" or CSTR (arrippart (j) = CSTR (arrbadippart (j) then
Counter = counter + 1
End if
Next
If counter = 4 then
Isforbidip = true
Exit Function
End if
Next
Isforbidip = false
End Function
'***************
'Return customer IP Address
'***************
Function getuserip ()
Dim IP
IP = request. servervariables ("http_x_forwarded_for ")
If IP = "" Then IP = request. servervariables ("remote_addr ")
Getuserip = IP
End Function
%>