Asp下實(shí)現(xiàn)限制IP訪問(wèn)的程序代碼
更新時(shí)間:2007年04月03日 00:00:00 作者:
<%
''獲取訪問(wèn)者的地址
ip=Request.ServerVariables("REMOTE_ADDR")
''允許的IP地址段為10.0.0.0~10.68.63.255
allowip1="10.0.0.0"
allowip2="10.68.10.71"
response.write checkip(ip,allowip1,allowip2)
function checkip(ip,allowip1,allowip2)
dim check(4)
checkip=false
ipstr=split(ip,".")
allow1=split(allowip1,".")
allow2=split(allowip2,".")
if cint(allow1(0))>cint(allow2(0)) then ''判斷IP地址段是否合法
response.write "禁止訪問(wèn)"
exit function
end if
for i=0 to ubound(ipstr)
if cint(allow1(i))<cint(allow2(i)) then
if cint(allow1(i))=cint(ipstr(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))<cint(allow2(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))>cint(allow2(i)) then
check(i)=false
checkip=false
exit for
else
check(i)=true
checkip=true
end if
end if
end if
else
if cint(allow1(i))>cint(ipstr(i)) or cint(allow1(i))<cint(ipstr(i)) then
check(i)=false
checkip=false
if i<>ubound(ipstr) then
exit for
end if
else
check(i)=true
end if
end if
next
if (check(0)=true and check(1)=true and check(2)=true and check(3)=false) and (cint(allow2(2))>cint(ipstr(2))) then
checkip=true
end if
end function
%>
''獲取訪問(wèn)者的地址
ip=Request.ServerVariables("REMOTE_ADDR")
''允許的IP地址段為10.0.0.0~10.68.63.255
allowip1="10.0.0.0"
allowip2="10.68.10.71"
response.write checkip(ip,allowip1,allowip2)
function checkip(ip,allowip1,allowip2)
dim check(4)
checkip=false
ipstr=split(ip,".")
allow1=split(allowip1,".")
allow2=split(allowip2,".")
if cint(allow1(0))>cint(allow2(0)) then ''判斷IP地址段是否合法
response.write "禁止訪問(wèn)"
exit function
end if
for i=0 to ubound(ipstr)
if cint(allow1(i))<cint(allow2(i)) then
if cint(allow1(i))=cint(ipstr(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))<cint(allow2(i)) then
check(i)=true
checkip=true
exit for
else
if cint(ipstr(i))>cint(allow2(i)) then
check(i)=false
checkip=false
exit for
else
check(i)=true
checkip=true
end if
end if
end if
else
if cint(allow1(i))>cint(ipstr(i)) or cint(allow1(i))<cint(ipstr(i)) then
check(i)=false
checkip=false
if i<>ubound(ipstr) then
exit for
end if
else
check(i)=true
end if
end if
next
if (check(0)=true and check(1)=true and check(2)=true and check(3)=false) and (cint(allow2(2))>cint(ipstr(2))) then
checkip=true
end if
end function
%>
您可能感興趣的文章:
- ASP.net做的IP訪問(wèn)限制
- 用ASP代碼實(shí)現(xiàn)對(duì)IP的訪問(wèn)限制的代碼
- 用asp腳本實(shí)現(xiàn)限制IP訪問(wèn)
- 推薦的用Asp實(shí)現(xiàn)屏蔽IP地址訪問(wèn)的代碼
- ADSI+ASP添加IP到IIS禁止訪問(wèn)列表中
- 記錄游客頁(yè)面訪問(wèn)IP的簡(jiǎn)易實(shí)現(xiàn)代碼 (asp.net+txt)
- 通過(guò)ASP禁止指定IP和只允許指定IP訪問(wèn)網(wǎng)站的代碼
- Asp限制IP訪問(wèn) 阻止某一個(gè)IP段禁止訪問(wèn)本站的代碼
- asp實(shí)現(xiàn)限制一個(gè)ip只能訪問(wèn)一次的方法
相關(guān)文章
asp之自動(dòng)閉合HTML/ubb標(biāo)簽函數(shù)附簡(jiǎn)單注釋
這樣的功能就是實(shí)現(xiàn)一般html,ubb標(biāo)簽的閉合,以前在pjblog中見(jiàn)過(guò),一直沒(méi)用,這個(gè)函數(shù)不錯(cuò),建議可以參考下pjblog中的函數(shù)。2009-01-01新增加一個(gè)防垃圾評(píng)論的asp代碼,鄙視垃圾
最近開(kāi)通了,可以發(fā)表評(píng)論就一直被垃圾評(píng)論和留言困擾,一直沒(méi)有找到很好的解決辦法。今天發(fā)現(xiàn)了這個(gè)可以防止垃圾評(píng)論的asp代碼,特提供給大家,希望大家能擺脫2007-12-12用ASP應(yīng)用程序?qū)崿F(xiàn)自己的UrlDeCode
URL編碼是指為了將信息通過(guò)URL進(jìn)行傳輸,所以必須將某些含有特殊意義的字符進(jìn)行替換的一種編碼方式,在asp中我們都知道有一個(gè)Server.URLEncode的函數(shù)可以完成這個(gè)功能。2006-08-08asp ADO GetString函數(shù)與用GetString來(lái)提高ASP的速度
沒(méi)想到asp下有g(shù)etstring這個(gè)東西,看樣子不熟悉這塊啊,以后考慮用這個(gè),應(yīng)該不錯(cuò),另外還有g(shù)etrows等,都是asp下提高性能不錯(cuò)的函數(shù)。2007-12-12一個(gè)改進(jìn)的ASP生成SQL命令字符串類的代碼[已測(cè)]
網(wǎng)上找資料發(fā)現(xiàn)的,但是調(diào)試的時(shí)候發(fā)現(xiàn)有一些問(wèn)題,改了一下,還有一定的問(wèn)題,但是可以做一般使用了。沒(méi)有考慮數(shù)據(jù)類型的問(wèn)題,還有SQL Server 和access的區(qū)別,以后有時(shí)間再改進(jìn)吧,不知道效率怎么樣。如果有朋友改進(jìn),也麻煩給我發(fā)一份2011-12-12C語(yǔ)言數(shù)組添加和刪除元素的實(shí)現(xiàn)
這篇文章主要介紹了C語(yǔ)言數(shù)組添加和刪除元素的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-02-02