asp中如何对ip段进行过滤限制
发布时间:2007-09-17 11:14:00
标签:ip,限制,过滤
内容摘要:当我们不想让某IP服务我们的网站时,我们就要写段程序来限制IP地址。asp中如何对ip进行过滤限制?本文介绍了一种方法,这个函数只能限制某IP段,无法限制单独的IP地址,当然要限制单独的IP应该来说是很简单:基本思路就是一获取访问者的IP,二比较我们数据库中设置的限制IP,如果相等就可以不让他访问了,最好你要提示些禁止访问的文字,让访客明白是怎么回事。
<%
’获取访问者的地址
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 "IP地址段出错!"
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
%>
0
投稿
猜你喜欢
- 摘要:SELECT 语句可以帮助我们从MySQL中取出数据。SELECT 大概是 SQL 语言中最常用的语句,而且怎样使用它也最为讲究;用它
- 根据Django官方文档介绍:A one-to-one relationship. Conceptually, this is simila
- 本文实例讲述了Python排序搜索基本算法之冒泡排序。分享给大家供大家参考,具体如下:冒泡排序和选择排序类似,也是第n次把最小的元素排在第n
- 前言:作为一名从小就看篮球的球迷,会经常逛虎扑篮球及湿乎乎等论坛,在论坛里面会存在很多精美图片,包括NBA球队、CBA明星、花边新闻、球鞋美
- 用python画图很多是根据z=f(x,y)来画图的,本博文将三个对应的坐标点输入画图:散点图:import matplotlib.pypl
- 惊现!表面下的隐藏信息——浅谈信息可视化1910年,病卧床上的魏格那(德国气象学家,以“大陆漂移学说”闻名),无意地注视着墙上的世界地图……
- 业务场景使用elasticsearch作为全文搜索引擎,对标题、内容等,实现智能搜索、输入提示、拼音搜索等elasticsearch索引与数
- 这篇文章将介绍在Python中使用 "frozenset "函数的指南,该函数返回一个新的frozenset类型的Pyt
- 假设页面源代码如下:<input type="text"name="wd" id="
- 详解Oracle在out参数中访问光标一 概念申明包结构包头:负责申明包体:负责实现 二 需求查询某个部门中所有员工的所有信息三
- 简介:在视频相关测试场景下,例如:有时需要知道全部视频的汇总时长,显然一个个打开并且手工计算耗时耗力,我们可以通过编写脚本进行快速汇总。获取
- 演示时间是非常有限的,过去时光永远不会再回来。要在有限的时间里面,去面对生活的困难和生存的竞争,是需要强化自我的。而这些强化学习是最需时间的
- TensorFlow是一个采用数据流图(data flow graphs),用于数值计算的开源软件库。节点(Nodes)在图中表示数学操作,
- 以下效率,是奔腾 dual1.6G HZ,1G内存电脑,ie6.0下toggle()与slideToggle("fast"
- 代码#!/usr/bin/env python#coding=utf-8import random#生成[0, 1)直接随机浮点数print
- getattr`getattr`函数属于内建函数,可以通过函数名称获取value = obj.attributevalue = getatt
- 使用python实现双向链表,供大家参考,具体内容如下双向链表: 指的是讲数据链接在一起,每个数据是一个节点,每一个节点都有一个数据区,两个
- 本文实例讲述了vue组件定义,全局、局部组件,配合模板及动态组件功能。分享给大家供大家参考,具体如下:一、定义一个组件定义一个组件:1. 全
- 隐藏你的.php文件 隐藏你的.php文件 今天做PHP在线手册镜像的时候看到了这个方法,哈哈,以前都没有注意到,所以说,手册是
- 注:所有文字,除注明网站类型外,其他均针对企业站点.请随时注意留言,若修改则会在首页提示文字里标注.若牵扯到业务方面的问题,我可能不会做过多