IP限制函數
大家如果還有好的建議算法,就聯繫我! ! :)
“******************************
“FunctionCheckIp(cInput_Ip,cBound_Ip)
“Createdbyqqdao,[email protected]/11/28
“說明:首先需要根據;號循環,然後判斷是否含有"-",如果有則進行拆分處理,最後判斷是否在範圍內
“參數:cInput_Ip,代檢查的ip
“cBound_Ip,給定的範圍格式為,單個ip,和範圍ip,範圍ip最後使用”-“分割,如果是“*”則必須放到最後一位
“每個範圍後添加":ALLOW"表示允許登陸,添加":REFUSE"表示拒絕登陸。多個範圍用”;“隔開
“例如192.168.1*.*:ALLOW;192.168.1.1:ALLOW;192.168.1.1-10:REFUSE"
“返回值:true/false
“更新:2001/12/05支持ALLOW,REFUSE支持'*',不想對?支持,因為和*差不多
“******************************
functionCheckIp(cInput_Ip,cBound_Ip)
dimcSingle_Ip,cTemp_IP,cStart_IP,cEnd_Ip
CheckIp=false
cSingle_Ip=split(cBound_Ip,";")
fori=0toubound(cSingle_Ip)
ifInstr(cSingle_Ip(i),"REFUSE")<>0then“就是拒絕了
cTemp_IP=left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)
ifInstr(cTemp_IP,"*")<>0then“是寬範圍
cStart_IP=left(cTemp_IP,instr(cTemp_IP,"*")-1)
ifleft(cInput_Ip,len(cStart_IP))=cStart_IPthen
CheckIp=false
exitfunction
endif
endif
ifInstr(cTemp_IP,"-")=0then
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)
endif
ifIp2Str(cInput_Ip)>=Ip2Str(cStart_IP)andIp2Str(cInput_Ip)<=Ip2Str(cEnd_Ip)then
CheckIp=false
exitfunction
endif
elseifInstr(cSingle_Ip(i),"ALLOW")<>0then“允許
cTemp_IP=left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)
ifInstr(cTemp_IP,"*")<>0then“是寬範圍
cStart_IP=left(cTemp_IP,instr(cTemp_IP,"*")-1)
ifleft(cInput_Ip,len(cStart_IP))=cStart_IPthen
CheckIp=true
endif
endif
ifInstr(cTemp_IP,"-")=0then
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)
endif
ifIp2Str(cInput_Ip)>=Ip2Str(cStart_IP)andIp2Str(cInput_Ip)<=Ip2Str(cEnd_Ip)then
CheckIp=true