'******************************
'function checkip(cinput_ip,cbound_ip)
'created by qqdao, [email protected] 2001/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支援'*『,不想對?支援,因為和*差不多
'******************************
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 「就是拒絕了
ctemp_ip = left(csingle_ip(i),instr(csingle_ip(i),":")-1)
if instr(ctemp_ip,"*") <> 0 then 「是寬範圍
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 「允許
ctemp_ip = left(csingle_ip(i),instr(csingle_ip(i),":")-1)
if instr(ctemp_ip,"*") <> 0 then 「是寬範圍
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_i程式設計客棧p = 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, [email protected] 2001/11/28
'參考動網ip演算法
'引數:cip ip位址
'返回值: 轉換後數值
'******************************
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&n程式設計客棧bsp;or isnumeric(str4)=0 then
else
ip2str=cint(str1)*2程式設計客棧56*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
end if
end function
本文標題: asp中實現限制ip的函式詳解
本文位址:
Tomcat中實現IP訪問限制
效果 只有指定的主機或ip位址才可以訪問部署在tomcat下的應用。tomcat提供了兩個引數供你配置 remotehostvalve 和remoteaddrvalve,前者用於限制主機名,後者用於限制ip位址。通過配置這兩個引數,可以讓你過濾來自請求的主機或ip位址,並允許或拒絕哪些主機 ip。一...
限制某IP段對網頁的訪問 ASP
function ip2num sip dim str1,str2,str3,str4 dim num ip2num 0 if isnumeric left sip,2 then str1 left sip,instr sip,1 sip mid sip,instr sip,1 str2 left ...
asp中的Rnd,Randomize 函式
randomize 初始化隨機數生成器,該生成器具有基於系統計時器的種子 不帶引數的randomize語句相當於randomize timer,也就是以timer函式返回的數值作為種子計算隨機數 rnd number 返回乙個小於 1 但大於或等於 0 的值。number 的值決定了 rnd 生成隨...