Asp下實(shí)現(xiàn)限制IP訪問的程序代碼
更新時(shí)間:2007年04月03日 00:00:00 作者:
<%
''獲取訪問者的地址
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 "禁止訪問"
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
%>
''獲取訪問者的地址
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 "禁止訪問"
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
%>
相關(guān)文章
asp之自動(dòng)閉合HTML/ubb標(biāo)簽函數(shù)附簡單注釋
這樣的功能就是實(shí)現(xiàn)一般html,ubb標(biāo)簽的閉合,以前在pjblog中見過,一直沒用,這個(gè)函數(shù)不錯(cuò),建議可以參考下pjblog中的函數(shù)。2009-01-01用ASP應(yīng)用程序?qū)崿F(xiàn)自己的UrlDeCode
URL編碼是指為了將信息通過URL進(jìn)行傳輸,所以必須將某些含有特殊意義的字符進(jìn)行替換的一種編碼方式,在asp中我們都知道有一個(gè)Server.URLEncode的函數(shù)可以完成這個(gè)功能。2006-08-08asp ADO GetString函數(shù)與用GetString來提高ASP的速度
沒想到asp下有g(shù)etstring這個(gè)東西,看樣子不熟悉這塊啊,以后考慮用這個(gè),應(yīng)該不錯(cuò),另外還有g(shù)etrows等,都是asp下提高性能不錯(cuò)的函數(shù)。2007-12-12一個(gè)改進(jìn)的ASP生成SQL命令字符串類的代碼[已測]
網(wǎng)上找資料發(fā)現(xiàn)的,但是調(diào)試的時(shí)候發(fā)現(xiàn)有一些問題,改了一下,還有一定的問題,但是可以做一般使用了。沒有考慮數(shù)據(jù)類型的問題,還有SQL Server 和access的區(qū)別,以后有時(shí)間再改進(jìn)吧,不知道效率怎么樣。如果有朋友改進(jìn),也麻煩給我發(fā)一份2011-12-12C語言數(shù)組添加和刪除元素的實(shí)現(xiàn)
這篇文章主要介紹了C語言數(shù)組添加和刪除元素的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-02-02