快乐的黎波里

用自己的脚来走路,用自己语言来表达,用自己方式来生活!

 

用ASP对网页进行限制性的访问的代码

 

以下红色部分可以自行修改

html 
   head 
   meta httpequiv=“ContentType” content=“text/html; charset=gb_231280” 
   meta name=“GENERATOR” content=“Microsoft FrontPage Express 2.0” 
   style 
   !-- 
   .as{ lineheight: 15px; fontsize: 9pt } 
   a:hover {color: #0033f0;textdecoration:underline} 
   .p9 { fontfamily: “宋体”; fontsize: 9pt; lineheight: 15pt} 
   .p12 { fontfamily: “宋体”; fontsize: 12pt; lineheight: 18pt} 
   a:link { textdecoration: none;} 
   a:visited { textdecoration:none;} 
   a:hover {textdecoration: underline;fontsize: 125;color:blue} 
   --> 
   /style 
   title>网页限制性访问</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%>,你不是本网用户<BR></font></p 
   form action=“demo.asp” method=“POST” id=form1 name=form1 
   p>请输入访问密码:<input type=“password” name=“Passwd” input type=“submit” value=“确认” name=“B1”
   /p 
   /form 
   <%else %> 
  祝贺您,您已经顺利通过了页面的安全认证,可以直接使用本站点的资源
   <%end if%> 
   /body 
   /html 

posted on 2008-07-30 14:34  M  阅读(543)  评论(0)    收藏  举报

导航