欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

如何验证IP地址?

程序员文章站 2022-03-10 13:29:13
 sub chkip(boardid)    dim rsip    dim iparr    dim...

 sub chkip(boardid)
   dim rsip
   dim iparr
   dim ignored
   dim i
   dim ip
   dim sql

   ip=request.servervariables("remote_addr")   
   ignored=false
   if not isempty(boardid) then   
     sql="select ignoreip from board where boardid="&cstr(boardid)
     set rsip=conn.execute(sql)
     if not (rsip.eof and rsip.bof) then
      if instr(cstr(rsip("ignoreip")&""),chr(13)&chr(10)) then
        iparr=split(rsip("ignoreip"),chr(13)&chr(10))
        for i=0 to ubound(iparr)
          if trim(iparr(i))<>"" and left(ip,len(trim(iparr(i))))=trim(iparr(i)) then
           ignored=true
           exit for
          end if
        next
      else
        iparr=rsip("ignoreip")
        if ip=trim(iparr) then
         ignored=true
        end if
      end if
     end if
     rsip.close
   end if
   if ignored then
     response.write "<script language=javascript>window.location.href='ignoreip.htm'</script>"
   end if
 end sub