最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
利用代码实现对ip的访问限制
时间:2022-06-30 11:19:15 编辑:袖梨 来源:一聚教程网
这是以前用asp写的,本想改成asp.net的给大家,后来想大家能看懂算法就行了。
ip比对的关键是ip地址的线性化
<%
'可以进入的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("
")
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
%>
ip比对的关键是ip地址的线性化
<%
'可以进入的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("
")
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
%>
相关文章
- 《咏月风雅》翩然技能属性具体介绍 06-16
- 《零之战线》尼古拉一世约会位置怎么找 06-16
- 《这城有良田》仓廪有实有哪些玩法 06-16
- 《元梦之星》枪械瞄准哪些方法效果更好 06-16
- 《桃花师》改名可行的方法有哪些 06-16
- SNORT币是骗局吗?2025币安交易所赚币攻略 06-16