加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

ASP对网页实行保护的简单代码 ip

发布时间:2023-06-03 12:36:31 所属栏目:Asp教程 来源:
导读:要使用request对象的ServerVariables属性,通过它来获得环境变量的值。使用的语法为:Request.ServerVariables(variable),“variable”表示环境变量的名称,如服务器主机名称、Web服务器软件名等等,若&l

要使用request对象的ServerVariables属性,通过它来获得环境变量的值。使用的语法为:Request.ServerVariables(variable),“variable”表示环境变量的名称,如服务器主机名称、Web服务器软件名等等,若“variable”为“REMOTE_ADDR”则表示访问者的IP地址,通过它就可以实现IP地址的过滤。 

源程序如下:(文件名:demo.ASP)

 <html> 

 <head> 

 <meta http-equiv=“Content-Type” content=“text/html; charset=gb_2312-80”> 

 <meta name=“GENERATOR” content=“Microsoft FrontPage Express 2.0”> 

 <style> 

 <!-- 

 .as{ line-height: 15px; font-size: 9pt } 

 a:hover {color: rgb(0,51,240);text-decoration:underline} 

 .p9 { font-family: “宋体”; font-size: 9pt; line-height: 15pt} 

 .p12 { font-family: “宋体”; font-size: 12pt; line-height: 18pt} 

 a:link { text-decoration: none;} 

 a:visited { text-decoration:none;} 

 a:hover {text-decoration: underline;font-size: 125%;color:blue} 

 --> 

 </style> 

 <title>ASP页面防火墙功能演示</title> 

 </head> 

 <body background=“back.jpg”> 

 <% 

 ′使用Request.ServerVariables(“REMOTE_ADDR”)得到IP地址并保存在变量rip中 

 rip=Request.ServerVariables(“REMOTE_ADDR”) 

 strip=cstr(rip) 

 ′取得IP地址第三个段的值并保存到strip中 

 for i=1 to 2 

 strip=right(strip,len(strip)-instr(1,strip,“.”)) 

 next 

 strip=left(strip,instr(1,strip,“.”)-1) 

 ′IP地址有效性检验及密码验证,包括两方面的内容: 

 ′如果IP地址符合则通过验证;如果IP地址不符合则检验输入的密码是否正确(此处密码为“asp”) 

 if (left(rip,5) <> “127.1” or strip<“1” or strip>“50”) and request(“Passwd”)<>“asp” then 

 %> 

 <p><font color=“#FF0000”>对不起,你的IP是<%=rip%>,本页面可以访问的IP是127.1.1.*到127.1.50.*之间,如果你是本单位内部网的用户,请确认你的浏览器没有使用代理!<BR></font></p> 

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章