用ASP代碼實(shí)現(xiàn)對IP的訪問限制的代碼
更新時(shí)間:2007年03月22日 00:00:00 作者:
這是以前用ASP寫的,本想改成ASP.net的給大家,后來想大家能看懂算法就行了。IP比對的關(guān)鍵是IP地址的線性化,下面就是代碼。
'可以進(jìn)入的ip
'218.7.44.0 - 218.7.45.253
'61.180.240.0 - 61.180.240.253
'202.118.208.0 - 202.118.223.253
'
'218.7.44.0 3657903103
'218.7.45.253 3657903612
'
'61.180.240.0 1035268095
'61.180.240.253 1035268348
'
'202.118.208.0 3396784127
'202.118.223.253 3396788220
ip=request.servervariables("remote_addr")
sip=split(ip,".")
num=cint(sip(0))*256*256*256+cint(sip(1))*256*256+cint(sip(2))*256+cint(sip(3))-1
response.write(ip)
response.write("<br>")
if ((num>=3657903103 and num<=3657903612) or (num>=1035268095 and num<=1035268348)
or (num>=3396784127 and num<=3396788220)) then
response.write("抱歉,您的ip不合法!")
response.End()
else
response.write("您的ip合法")
end if
復(fù)制代碼 代碼如下:
'可以進(jìn)入的ip
'218.7.44.0 - 218.7.45.253
'61.180.240.0 - 61.180.240.253
'202.118.208.0 - 202.118.223.253
'
'218.7.44.0 3657903103
'218.7.45.253 3657903612
'
'61.180.240.0 1035268095
'61.180.240.253 1035268348
'
'202.118.208.0 3396784127
'202.118.223.253 3396788220
ip=request.servervariables("remote_addr")
sip=split(ip,".")
num=cint(sip(0))*256*256*256+cint(sip(1))*256*256+cint(sip(2))*256+cint(sip(3))-1
response.write(ip)
response.write("<br>")
if ((num>=3657903103 and num<=3657903612) or (num>=1035268095 and num<=1035268348)
or (num>=3396784127 and num<=3396788220)) then
response.write("抱歉,您的ip不合法!")
response.End()
else
response.write("您的ip合法")
end if
相關(guān)文章
微軟NET Framework 3.5 Beta 1 發(fā)布 提供下載
微軟NET Framework 3.5 Beta 1 發(fā)布 提供下載...2007-04-04
系統(tǒng)優(yōu)化和設(shè)置軟件MagicTweak v3.40 簡體中文版附注冊機(jī)下載
系統(tǒng)優(yōu)化和設(shè)置軟件MagicTweak v3.40 簡體中文版附注冊機(jī)下載...2007-05-05
影音全能播放器KMPlayer V2.9.3.1384 Beta 漢化增強(qiáng)版 提供下載
影音全能播放器KMPlayer V2.9.3.1384 Beta 漢化增強(qiáng)版 提供下載...2007-10-10
精通CSS高級web標(biāo)準(zhǔn)解決方案 下載
精通CSS高級web標(biāo)準(zhǔn)解決方案 下載...2007-05-05
圖像瀏覽軟件 ACDSee Photo Manager v9.0 Build 108 下載
圖像瀏覽軟件 ACDSee Photo Manager v9.0 Build 108 下載...2007-03-03
微軟MSDN Library (April 2007 Edition) 下載
微軟MSDN Library (April 2007 Edition) 下載...2007-04-04

