几个比较好用的asp检查函数
2008-02-23 09:46:51来源:互联网 阅读 ()
因为比较简单,我就不说什么了。一看就明白的!
Function ChkStr(InString)
If InString<>"" Then
?InString=Replace(LCase(InString)," ","")
?InString=Replace(LCase(InString),";","")
?InString=Replace(LCase(InString),"'","")
?InString=Replace(LCase(Instring),"--","")
?Instring=Replace(LCase(Instring),"%","")
?InString=Replace(LCase(InString)," ","")
?
?InString=Replace(LCase(InString),"admin","")
?
?InString=Replace(LCase(InString),"and","")
?InString=Replace(LCase(InString),"or","")
?
?InString=Replace(LCase(InString),"asc","")
?InString=Replace(LCase(Instring),"chr","")
?InString=Replace(LCase(InString),"mid","")
?InString=Replace(LCase(InString),"len","")
?
?InString=Replace(LCase(InString),"select","")
?InString=Replace(LCase(InString),"insert","")
?InString=Replace(LCase(InString),"delete","")
?InString=Replace(LCase(InString),"update","")
?
?
?ChkStr=InString
End If
End Function
Function CheckFileExt(FileExt)
?Dim FileAccessExt,AccessExt
?AccessExt="gif,jpg,jpeg,bmp,doc,txt,png"
?FileAccessExt=Split(AccessExt,",")
?For i=LBound(FileAccessExt) to UBound(FileAccessExt)
??If LCase(FileExt)=LCase(FileAccessExt(i)) Then
???CheckFileExt=True
??Else
???CheckFileExt=False
??End If
?Next
End Function
Function CheckStr(str,IsStr)
CheckStr=str
If IsStr And InStr(str,",")>0 Then
?Call errmsg("提交字符中包含非法字符")
ElseIf (Not IsStr) And (Not IsNumeric(str)) Then
?Call errmsg("提交不是数字型")
End If
End Function
Sub errmsg(str)
?If Not IsNull(str) Then
??Response.Write(str)&"< br >"
??Call ASCpy()
??Response.End()? 'Very Improtan.Stop execute program.
?End If
End Sub
?
?Sub ASCpy()
?Response.Write ""
?Response.Write "
"
??? Response.Write("
Error happed!
Please Contract ")
?Response.Write("Name:")
?Response.Write("AloneSword")
?Response.Write(".
Thank you!!!
")
?Response.Write "
--------------------------------------------------------------------------------
Copyright © By 建大网络 ™
"
??? Response.Write "Last Modified:21/08/2004
"
?Response.Write("Author:AloneSword")
?Response.Write "
"
End Sub
?
小结:
最值得学习的还是response.End()的合理使用,非常的好。只要出现错误马上终止程序的运行,不给后面的机会,保证数据的安全。
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:ASP特殊字符过滤
下一篇:ASP实现新闻中限制显示字数目
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash