'此文件可以对整站提交文字进行过滤
'函数说明:对非法字符进行过滤
'这个函数将过滤所有非中文字符
function ClearString(str)
dim re,str1,str2,i
set re = new regexp re.Pattern = "^[\u4e00-\u9fa5\s\n\r\t]+$"
for i=1 to len(str)
str1 = mid(str,i,1)
clearString = re.Test(str1)
if clearString=true then
str2 = str2&str1
end if
next
str=str2
ClearString = str
end function
function KillKey(str)
KillKey=str
end function
'编写者:逸风
'编写日期:2008-6-4
'函数说明:对非法字符进行过滤
'这个函数将过滤所有非中文字符
function SearchKey(str)
Key="这里是非法字符 嘎嘎`~~CSDN也屏蔽的"
KeyArray=split(Key,",")
K=ubound(KeyArray)
str2=ClearString(str)
for i=0 to K
if Instr(str2,KeyArray(i)) then
response.Write("<font color=red>您所提交的信息中包含非法字符,请您返回后仔细检查所填写的内容然后再次提交您的信息!</font><a href='javascript:history.go(-1);'>返回</a><br/><font color=#0000FF>感谢您的支持!</font><br/>非法字符:" & KeyArray(i))
response.End()
end if
next
SearchKey=str
end function
function urldecode(encodestr) 'encodestr就是要解码的字符串
Dim newstr,havechar,lastchar,i,char_c,next_1_c,next_1_Num
newstr=""
havechar=false
lastchar=""
for i=1 to len(encodestr)
char_c=mid(encodestr,i,1)
if char_c="+" then
newstr=newstr & " "
elseif char_c="%" then
next_1_c=mid(encodestr,i+1,2)
next_1_num=cint("&H" & next_1_c)
if havechar then
havechar=false
newstr=newstr & chr(cint("&H" & lastchar & next_1_c))
else
if abs(next_1_num)<=127 then
newstr=newstr & chr(next_1_num)
else
havechar=true
lastchar=next_1_c
end if
end if
i=i+2
else
newstr=newstr & char_c
end if
next
urldecode=newstr
end function
TempStr1=urldecode(request.QueryString)
TempStr2=urldecode(request.Form)
'查询提交的信息 如有非法字符 直接终止程序运行
SearchKey(TempStr1)
SearchKey(TempStr2)
|