正则表达式检查来访IP是否合法的实际应用
发布时间:2016-12-29 来源:查字典编辑
摘要:正则表达式检查来访IP是否合法的实际应用subchkIP(boardid)dimrsIPdimipArrdimignoreddimidimi...
正则表达式检查来访IP是否合法的实际应用
subchkIP(boardid)
dimrsIP
dimipArr
dimignored
dimi
dimip
dimsql
ip=Request.ServerVariables("REMOTE_ADDR")
ignored=false
ifnotisempty(boardid)then
sql="selectignoreipfromboardwhereboardid="&cstr(boardid)
setrsIP=conn.execute(sql)
ifnot(rsIP.eofandrsIP.bof)then
ifinstr(cstr(rsIP("ignoreip")&""),chr(13)&chr(10))then
iparr=split(rsIP("ignoreip"),chr(13)&chr(10))
fori=0toubound(iparr)
iftrim(iparr(i))<>""andleft(ip,len(trim(iparr(i))))=trim(iparr(i))then
ignored=true
exitfor
endif
next
else
iparr=rsIP("ignoreip")
ifip=trim(iparr)then
ignored=true
endif
endif
endif
rsIP.close
endif
ifignoredthen
response.write"<scriptlanguage=javascript>window.location.href='ignoreip.htm'</script>"
endif
endsub