'******************************
'Function CheckIp (cInput_Ip, cBound_Ip)
'Created by qqdao, qqdao@263.net 2001/11/28
'Note: First, you need to cycle by the; sign, and then determine whether "-" is contained. If yes, you need to split the data and determine whether the data is in the specified range.
'Parameter: cInput_Ip, ip address used for check
'Cbound _ Ip, the specified range format is: Single ip address, and range ip address. The range ip address is separated by "-". If it is "*", it must be placed in the last position.
'Add ": ALLOW" after each range to ALLOW login, and add ": REFUSE" to deny login. Multiple ranges are separated by commas (,).
'Example: 192.168.1 *. *: ALLOW; 192.168.1.1: ALLOW; 192.168.1.1-10: REFUSE"
'Return value: true/false
'Update: supports ALLOW and REFUSE supports '*'. Don't you want? Yes, because it is similar *
'******************************
Function CheckIp (cInput_Ip, cBound_Ip)
Dim cSingle_Ip, cTemp_IP, cStart_IP, cEnd_Ip
CheckIp = false
CSingle_Ip = split (cBound_Ip ,";")
For I = 0 to ubound (cSingle_Ip)
If Instr (cSingle_Ip (I), "REFUSE") <> 0 then "is rejected
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 (cStart_IP) = cStart_IP then
CheckIp = false
Exit function
End if
End if
If Instr (cTemp_IP, "-") = 0 then
CStart_IP = cTemp_IP
CEnd_Ip = cTemp_IP
Else
CStart_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 (cStart_IP) and Ip2Str (cInput_Ip) <= Ip2Str (cEnd_Ip) then
CheckIp = false
Exit function
End if
Elseif Instr (cSingle_Ip (I), "ALLOW") <> 0 then "Allowed
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 (cStart_IP) = cStart_IP then
CheckIp = true
End if
End if
If Instr (cTemp_IP, "-") = 0 then
CStart_IP = cTemp_IP
CEnd_Ip = cTemp_IP
Else
CStart_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 (cStart_IP) and Ip2Str (cInput_Ip) <= Ip2Str (cEnd_Ip) then
CheckIp = true
Else
CheckIp = false
End if
End if
Next
End function
'******************************
'Function Ip2Str (cIp)
'Created by qqdao, qqdao@263.net 2001/11/28
'Refer to the dynamic ip address algorithm.
'Parameter: cIp IP Address
'Return value: converted value
'******************************
Function Ip2Str (cIp)
Dim str1, str2, str3, str4
Dim cIp_Temp
If 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 (str2) = 0 or isNumeric (str3) = 0 or isNumeric (str4) = 0 then
Else
Ip2Str = cint (str1) * 256*256*256 + cint (str2) * 256*256 + cint (str3) * 256 + cint (str4)-1
End if
End function