幾個比較好用的asp檢查函數

來源:互聯網
上載者:User
比較|函數 因為比較簡單,我就不說什麼了。一看就明白的!

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),"%20","")

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 "<link href='Css/Maincss.css' rel='stylesheet' type='text/css'>"
Response.Write "<div align='center' class='Maincss'>"
Response.Write("<Center>Error happed!<br>Please Contract ")
Response.Write("Name:<a href='mailto:jdqn@sjzu.edu.cn' style='text-decoration:none'>")
Response.Write("<font Color=red>AloneSword</font>")
Response.Write("</a>.<br>Thank you!!!</Center><br>")
Response.Write "<hr>Copyright © By <a href='#' style='text-decoration:none'>建大網路</a> ™<br>"
Response.Write "Last Modified:21/08/2004<br>"
Response.Write("Author:<a href='http://blog.csdn.net/alonesword/' style='text-decoration:none' target='_blank'>AloneSword</a>")
Response.Write "</div>"
End Sub



小結:

最值得學習的還是response.End()的合理使用,非常的好。只要出現錯誤馬上終止程式的運行,不給後面的機會,保證資料的安全。




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.