国家扶贫政策建房政策:帮忙,ASP 过滤的问题

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/29 23:44:27
我的留言本如何进行词汇及危险符号过滤:
Function ChkInvaildWord(Words)
Const InvaildWords="select|update|delete|insert|@|--|," '需要过滤得字符以“|”隔开,最后结束的字符必须是|

ChkInvaildWord=True
InvaildWord=Split(InvaildWords,"|")
inWords=LCase(Trim(Words))

For i=LBound(InvaildWord) To UBound(InvaildWord)
If Instr(inWords,InvaildWord(i))>0 Then
ChkInvaildWord=True
Exit Function
End If
Next
ChkInvaildWord=False
End Function
这段函数怎么用

直接在页面中调用。
先把这个函数文件包含进去如

<!--#include file=\"文件地址\" -->
<%
str=\"sdfsfasf\"
str=ChkInvaildWord(str) %>

把一个字符串作为参数传进去
如果字符串里有非法字符
函数返回true
否则返回false