aspでIP制限関数コードを実現します。

2675 ワード

IP制限関数の皆さん、いい提案アルゴリズムがあれば、連絡してください。Function CheckIp(cInput_)Ip,cBound_Ip)「Created by qqdao [email protected] 2001/11/28「説明:まず根拠が必要です。番号を循環して、-が含まれているかどうかを判断し、ある場合は分割処理を行い、最後に範囲内のパラメータがあるかどうかを判断します。 cInput_Ip,代理検査のip" cBound_Ipは、与えられた範囲フォーマットは、単一のip、範囲ip、範囲ipが最後に使用されます。 各範囲に「:ALLOW」を追加してログイン許可を表し、「:REFSE」を追加してログイン拒否を表します。複数の範囲を使用します。仕切り 例えば192.168.1*.*:ALLOW;192.168.1.1:ALLOW192.168.11-10:REFSE“戻り値: true/false「更新:2001/12/05 ALLOWを支持して、REFSEは支持します。支持、とほぼ同じですので、*********ファンクション CheckIp(cInput_)Ip,cBound_Ip)dim cSingle_Ip,cTemp_IP,cStart_IP,cEnd_Ip CheckIp = false cSingle_Ip=split(cBound_Ip,")for i=0 ト ound(cSingle_)Ip)if Instr(cSingle_)Ip(i)「REFSE」) <> 0 then “cTempを拒否しました。IP = left(cSingle_)Ip(i)、instr(cSingle_Ip(i),「-」-1)if Instr(cTemp_)IP,“*”) <> 0 then “広い範囲ですIP = left(cTemp_IP,instr(cTemp_)IP,「*」)-1)if left(cInput_)Ip,len(c Start_)IP)=cStart_IP then CheckIp = false exit function end if end if Instr(cTemp_)IP,「-」) = 0 then c Start_IP = cTemp_IP cEnd_Ip = cTemp_IP else cStart_IP = left(cTemp_IP,instr(cTemp_)IP,「-」-1)cEnd_Ip = left(cStart_)IP,InStrRevIP,「.」-「1」+「.」+mid(cTemp_)IP,instr(cTemp_)IP,「-」++1)end if Ip 2 Str(cInput_)Ip)>=Ip 2 Str(cStart_)IP) and Ip 2 Str(cInput_)Ip)<=Ip 2 Str(cEnd_)Ip) then CheckIp = false exit function end if elseif Instr(cSingle_)Ip(i)「ALLOW」) <> 0 then “cTemp_を許可するIP = left(cSingle_)Ip(i)、instr(cSingle_Ip(i),「-」-1)if Instr(cTemp_)IP,“*”) <> 0 then “広い範囲ですIP = left(cTemp_IP,instr(cTemp_)IP,「*」)-1)if left(cInput_)Ip,len(c Start_)IP)=cStart_IP then CheckIp = true end if end if Instr(cTemp_)IP,「-」) = 0 then c Start_IP = cTemp_IP cEnd_Ip = cTemp_IP else cStart_IP = left(cTemp_IP,instr(cTemp_)IP,「-」-1)cEnd_Ip = left(cStart_)IP,InStrRevIP,「.」-「1」+「.」+mid(cTemp_)IP,instr(cTemp_)IP,「-」++1)end if Ip 2 Str(cInput_)Ip)>=Ip 2 Str(cStart_)IP) and Ip 2 Str(cInput_)Ip)<=Ip 2 Str(cEnd_)Ip) then CheckIp =true else CheckIp =false end if end if next end function"***************************************************を"Function" Ip 2 Str(cIp)「Created」 by qqdao [email protected] 2001/11/28「動画ネットワークipアルゴリズム」パラメータ:cIp ipアドレス「戻り値: 変換後の値「******************************function」 Ip 2 Str(cIp)Dim str 1、str 2、str 3、str 4 Dim cIp_Temp if cIp=「127.1.0.1」 then cIp=「192.168.0.1」str 1=left(cIp,instr(cIp)-1)cIp_Temp=mid(cIp,instr(cIp)+1)str 2=left(cIp_Temp、instr(cIp_)Temp,「.」-1)cIp_Temp=mid(cIp_)Temp、instr(cIp_)Temp,「.」++1)str 3=left(cIp_Temp、instr(cIp_)Temp,「.」-1)str 4=mid(cIp_Temp、instr(cIp_)Temp,「.」++1)if isNumeric(str 1)=0 or isNumeric(str 2)=0 or isNumeric(str 3)=0 or isNumeric(str 4)=0 then else Ip 2 Str=cint(str 1)*256*256+cint(str 2)*256*256+cint(str 3)*256+cint(str 4)-1 end if end 機能