正则表达式检查来访IP是否合法的实际应用
程序员文章站
2022-03-27 12:08:39
正则表达式检查来访ip是否合法的实际应用 sub chkip(boardid) dim rsip dim ...
正则表达式检查来访ip是否合法的实际应用
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
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
上一篇: 正则表达式,相关链接
下一篇: js:日期正则表达式及检测