IP address limit function

zhaozj2021-02-16  48

<% 'Get the address of the visitor ip = Request.servervariables ("remote_addr")

'Allowed IP address segment is 10.0.0.0 ~ 10.68.63.255Allowip1 = "10.0.0.0" allowip2 = "10.68.10.71"

Response.write Checkip (IP, ALOWIP1, ALOWIP2)

Function Checkip (IP, Allowip1, Allowip2) DIM Check (4) checkip = falseipstr = Split (IP, ".") allow1 = split (allowip1, ".") allow2 = split (allowip2, ".") IF Cint (Allow1 (0))> CINT (allow2 (0)) THEN 'Judging whether the IP address segment is legal response.write "IP address paragraph error!" EXIT FUNCTIONEND IFOR I = 0 To Ubound (IPSTR) IF CINT (Allow1 (i)) < CINT (Allow2 (I)) THENIF CINT (Allow1 (i)) = CINT (IPSTR (I)) Thencheck (i) = trueCheckip = TrueExit Forum cint (allow2 (i)) thencheck (i) = falsecheckip = falseexit forelsecheck (i) = truecheckip = trueend ifend ifend ifelseif cint (allow1 (i))> cint ( IPSTR (I)) or CINT (AlLow1 (I)) ubound (ipstr) THENEXIT Forend ifelsecheck (i) = truend ifnd ifnext

IF (CHECK (0) = True and Check (1) = true and check (2) = true and check (3) = false) and (cint (allow2))> CINT (IPSTR (2))) ThenCheckip = TrueEnd IF

End function%>

IP limit function (www.jojoo.net) 2001-12-12 (please double-click automatic scroll to watch, click Stop, then hit ..)

If you still have a good suggestion algorithm, please contact me! ! :)

'*************************************' FUNCTION Checkip (Cinput_IP, CBound_ip) 'created by qqdao, qqdao@263.net 2001 / 11/28 'Description: First, it is necessary to cycle, then determine if "-", if there is a split processing, finally determine if the' parameter: Cinput_ip, the IP 'CBound_ip, given The range format is, single IP, and range IP, range IP finally uses "-" segmentation, if it is "*", you must add ": allow" after each range ": allow" means allowing login, add ": "Refer to refusing to log in. Multiple scope is ";" separated ", for example, 192.168.1 *. *: Allow; 192.168.1.1: allow; 192.168.1.1-10: refuse" 'return value: true / false' Update: 2001/12/05 Support Allow, Refuse supports' * ', don't want to be? Support, because and * almost' *************************************** FUNCTION Checkip (cInput_Ip, cBound_Ip) dim cSingle_Ip, cTemp_IP, cStart_IP, cEnd_IpCheckIp = falsecSingle_Ip = split (cBound_Ip, ";") for i = 0 to ubound (cSingle_Ip) if Instr (cSingle_Ip (i), "REFUSE") <> 0 then ' It is refused ctemp_ip = left (CSINGLE_IP (i), INSTR (CSINGLE_IP (I), ":") - 1)

IF INSTR (CTEMP_IP, "*") <> 0 THEN 'is a wide range of cstart_ip = left (ctemp_ip, instr (ctemp_ip, "*") - 1) if left (cinput_ip, len (cstract_ip)) = cstart_ip thencheckip = falseExit functionend IFEND IF

if Instr (cTemp_IP, "-") = 0 thencStart_IP = cTemp_IPcEnd_Ip = cTemp_IPelsecStart_IP = left (cTemp_IP, instr (cTemp_IP, "-") - 1) cEnd_Ip = left (cStart_IP, InStrRev (cStart_IP,) "." - 1) "." MID (CTEMP_IP, INSTR (CTEMP_IP, "-") 1) End IF

IF IP2STR (CINPUT_IP)> = IP2Str (cstract_ip) and ip2str (cinput_ip) <= IP2Str (CEND_IP) ThenCheckip = falseExit functionendiff

Elseif INSTR (CSINGLE_IP (i), "allow") <> 0 THEN 'Allow

CTEMP_IP = Left (CSINGLE_IP (I), INSTR (CSINGLE_IP (I), ":") - 1)

IF INSTR (CTEMP_IP, "*") <> 0 THEN 'is a wide range cstart_ip = left (ctemp_ip, instr (ctemp_ip, "*") - 1) if left (cinput_ip, len (cstract_ip)) = cstart_ip thencheckipipipipipipiP = trueEnd iFend ifif Instr (cTemp_IP, "-") = 0 thencStart_IP = cTemp_IPcEnd_Ip = cTemp_IPelsecStart_IP = left (cTemp_IP, instr (cTemp_IP, "-") - 1) cEnd_Ip = left (cStart_IP, InStrRev (cStart_IP,) "." - 1) "." MID (CTEMP_IP, INSTR (CTEMP_IP, "-") 1) End IF

IF IP2STR (CINPUT_IP)> = IP2Str (cstract_ip) and ip2str (cinput_ip) <= IP2Str (CEND_IP) ThencheckipiP = TrueElSecheckip = false dend ifnd IfNext

END FUNCTION

'*****************************' Function IP2STR (CIP) 'created by qqdao, qqdao@263.net 2001/11 / 28 'Reference IP IP Algorithm' Parameters: CIP IP Address 'Return Value: Convert Naturation' ************************************ ** Function IP2STR (CIP) DIM STR1, STR2, STR3, STR4DIM CIP_TEMPIF CIP = "127.0.0.1" THEN CIP = "192.168.0.1" STR1 = Left (CIP, INSTR (CIP, ".") - 1) CIP_TEMP = MID (CIP, INSTR (CIP, ") 1) STR2 = Left (CIP_TEMP, INSTR (CIP_TEMP,") - 1) CIP_TEMP = MID (CIP_TEMP, INSTR (CIP_TEMP, ".") 1) STR3 = Left (CIP_TEMP, INSTR (CIP_TEMP, ") - 1) STR4 = MID (CIP_TEMP, INSTR (CIP_TEMP,". ") 1)

IF isnumeric (str1) = 0 or isnumeric (str3) = 0 or isnumeric (str4) = 0 THEN

Elseip2Str = CINT (STR1) * 256 * 256 * 256 CINT (STR2) * 256 * 256 CINT (STR3) * 256 CINT (STR4) -1END IF

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-20391.html

New Post(0)