asp下實(shí)現(xiàn)IP限制函數(shù)代碼
大家如果還有好的建議算法,就聯(lián)系我?。。海?
“******************************
“Function CheckIp(cInput_Ip,cBound_Ip)
“Created by qqdao, qqdao@263.net 2001/11/28
“說(shuō)明:首先需要根據(jù);號(hào)循環(huán),然后判斷是否含有"-",如果有則進(jìn)行拆分處理,最后判斷是否在范圍內(nèi)
“參數(shù): cInput_Ip,代檢查的ip
“ cBound_Ip,給定的范圍格式為,單個(gè)ip,和范圍ip,范圍ip最后使用”-“分割,如果是“*”則必須放到最后一位
“ 每個(gè)范圍后添加":ALLOW"表示允許登陸,添加":REFUSE"表示拒絕登陸。多個(gè)范圍用”;“隔開(kāi)
“ 例如192.168.1*.*:ALLOW;192.168.1.1:ALLOW;192.168.1.1-10:REFUSE"
“返回值: true/false
“更新:2001/12/05 支持ALLOW,REFUSE支持'*‘,不想對(duì)?支持,因?yàn)楹?差不多
“******************************
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
“參考動(dòng)網(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)文章
在asp中使用js的encodeURIComponent方法
encodeURIComponent 方法返回一個(gè)已編碼的 URI。如果您將編碼結(jié)果傳遞給 decodeURIComponent,那么將返回初始的字符串2012-03-03
用asp實(shí)現(xiàn)網(wǎng)頁(yè)郵箱訪問(wèn)的方法
用asp實(shí)現(xiàn)網(wǎng)頁(yè)郵箱訪問(wèn)的方法...2007-04-04
ASP網(wǎng)站出現(xiàn) msxml3.dll 錯(cuò)誤 80072ee7 錯(cuò)誤的解決方法
這兩天接到通知,說(shuō)公司的一個(gè)網(wǎng)站訪問(wèn)不了,經(jīng)訪問(wèn)發(fā)現(xiàn)頁(yè)面提示如下錯(cuò)誤2011-08-08
asp下取得客戶(hù)端IP地址函數(shù) 轉(zhuǎn)換IP地址函數(shù)
asp下取得客戶(hù)端IP地址函數(shù) 轉(zhuǎn)換IP地址函數(shù)...2007-08-08
ajax+asp無(wú)限級(jí)分類(lèi)樹(shù)型結(jié)構(gòu)(帶數(shù)據(jù)庫(kù))
帶數(shù)據(jù)庫(kù)的ajax+asp無(wú)限級(jí)分類(lèi)樹(shù)型結(jié)構(gòu),好東西別錯(cuò)過(guò)2009-07-07
asp 讀取通過(guò)表單發(fā)送的post數(shù)據(jù)
學(xué)習(xí)ASP,最重要的就是要掌握ASP內(nèi)置的六大對(duì)象,如果以前沒(méi)接觸過(guò),聰明的您就不要管這些概念了,知道怎么用就行了,我的觀點(diǎn)是剛開(kāi)始關(guān)鍵在于臨摹2012-12-12
在asp中通過(guò)vbs類(lèi)實(shí)現(xiàn)rsa加密與解密的代碼
在asp中通過(guò)vbs類(lèi)實(shí)現(xiàn)rsa加密與解密的代碼...2007-03-03
asp Response.flush 實(shí)時(shí)顯示進(jìn)度
如果你知道Response.Flush和Response.Clear,那你就可以不用這樣的等待了。每生成一個(gè)Html頁(yè)面,就用Response.write立即返回一條信息,提示該條數(shù)據(jù)庫(kù)記錄已經(jīng)生成Html。2008-08-08

