ASP中實現(xiàn)限制IP的函數(shù)詳解
更新時間:2007年04月03日 00:00:00 作者:
'******************************
'Function CheckIp(cInput_Ip,cBound_Ip)
'Created by qqdao, qqdao@263.net 2001/11/28
'說明:首先需要根據(jù);號循環(huán),然后判斷是否含有"-",如果有則進(jìn)行拆分處理,最后判斷是否在范圍內(nèi)
'參數(shù): 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_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
'參考動網(wǎng)ip算法
'參數(shù):cIp ip地址
'返回值: 轉(zhuǎn)換后數(shù)值
'******************************
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
'Function CheckIp(cInput_Ip,cBound_Ip)
'Created by qqdao, qqdao@263.net 2001/11/28
'說明:首先需要根據(jù);號循環(huán),然后判斷是否含有"-",如果有則進(jìn)行拆分處理,最后判斷是否在范圍內(nèi)
'參數(shù): 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_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
'參考動網(wǎng)ip算法
'參數(shù):cIp ip地址
'返回值: 轉(zhuǎn)換后數(shù)值
'******************************
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
相關(guān)文章
面向小白visual studio 2019 添加第三方庫教程(入門)
這篇文章主要介紹了面向小白visual studio 2019 添加第三方庫教程,文中通過圖文介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03VBScript ASP CDbl() 函數(shù)轉(zhuǎn)換為雙精度類型
CDbl 函數(shù)用于進(jìn)行從其他數(shù)據(jù)類型到 Double 子類型的國際公認(rèn)的格式轉(zhuǎn)換。例如,十進(jìn)制分隔符和千位分隔符的識別取決于系統(tǒng)的區(qū)域設(shè)置。2011-05-05ASP中怎么實現(xiàn)SQL數(shù)據(jù)庫備份、恢復(fù)!
ASP中怎么實現(xiàn)SQL數(shù)據(jù)庫備份、恢復(fù)!...2007-03-03