防止别人插入iframe的代码
2010-09-14 13:22:04 来源:WEB开发网一个数据转换函数,在每个用户提交数据的地方使用该函数把用户调入的值强制转换一次即可。
Function CData(ByVal strWord, ByVal intType)
On Error Resume Next
Select Case intType
Case 0
CData = 0
If IsNumeric(strWord) Then If strWord Then CData = 1
Case 1
CData = 0
If IsNumeric(strWord) Then CData = CInt(CByte(strWord))
Case 2
CData = 0
If IsNumeric(strWord) Then CData = CInt(strWord)
Case 3
CData = 0
If IsNumeric(strWord) Then CData = CLng(strWord)
Case 4
CData = 0
If IsNumeric(strWord) Then CData = CCur(strWord)
Case 5
CData = Now()
If IsDate(strWord) Then CData = strWord
Case 6
CData = ""
If strWord > "" Then CData = Replace(Replace(strWord, CHR(0), ""), "'", "''")
Case 7
If strWord > "" Then
strWord = Replace(strWord, CHR(0), "")
strWord = Replace(strWord, "'", "''")
strWord = Replace(strWord, "[", "[[]")
strWord = Replace(strWord, "%", "[%]")
CData = Replace(strWord, "_", "[_]")
Else
CData = ""
End If
Case Else
CData = ""
If strWord > "" Then CData = CStr(strWord)
End Select
On Error Goto 0
End Function
更多精彩
赞助商链接