'-------------------------------------------
function SafeCheck(CheckString,CheckType,CheckLength)
On Error Resume Next
ErrorRoot="SYSTEM_ERROR|"
if checkString="" then
SafeCheck=ErrorRoot&"00001"
exit function
end if
CheckString=Replace(CheckString,"'","'")
select case CheckType
case 0
CheckString=trim(CheckString)
SafeCheck=Left(CheckString,CheckLength)
case 1
if not isnumberic(CheckString) then
SafeCheck=ErrorRoot&"00002"
exit function
else
SafeCheck=Left(CheckString,CheckLength)
end if
case 2
tempVar=IsDate(CheckString)
if Not TempVar then
SafeCheck=ErrorRoot&"00003"
exit function
else
select case CheckLength
case 0
SafeCheck=FormatDateTime(CheckString,vbShortDate)
case 1
SafeCheck=FormatDateTime(CheckString,vbLongDate)
case 2
SafeCheck=CheckString
end select
end if
case 3
tempVar=FormatCurrency(CheckString,0)
if Err then
SafeCheck=ErrorRoot&"00004"
exit function
else
SafeCheck=FormatCurrency(CheckString,CheckLength)
end if
case 4
sTemp = CheckString
If IsNull(sTemp) = True Then
SafeCheck=ErrorRoot&"00005"
Exit Function
End If
sTemp = Replace(sTemp, "&", "&")
sTemp = Replace(sTemp, "<", "<")
sTemp = Replace(sTemp, ">", ">")
sTemp = Replace(sTemp, Chr(34), """)
sTemp = Replace(sTemp, Chr(10), "<br>")
SafeCheck = Left(sTemp,CheckLength)
case 5
sTemp = CheckString
If IsNull(sTemp) = True Then
SafeCheck=ErrorRoot&"00006"
Exit Function
End If
sTemp = Replace(sTemp, "&", "&")
sTemp = Replace(sTemp, "<", "<")
sTemp = Replace(sTemp, ">", ">")
sTemp = Replace(sTemp, """, Chr(34))
sTemp = Replace(sTemp, "<br>",Chr(10))
SafeCheck = Left(sTemp,CheckLength)
case 6
s_BadStr = "' &<>?%,;:()`~!@#$^*{}[]|+-=" & Chr(34) & Chr(9) & Chr(32)
n = Len(s_BadStr)
IsSafeStr = True
For i = 1 To n
If Instr(CheckString, Mid(s_BadStr, i, 1)) > 0 Then
IsSafeStr = False
End If
Next
if IsSafeStr then
SafeCheck=left(CheckString,CheckLength)
else
SafeCheck=ErrorRoot&"00007"
Exit Function
end if
case 7
s_Filter="net user|xp_cmdshell|/add|select|count|asc|char|mid|'|""|"
S_Filter=S_Filter&"insert|delete|drop|truncate|from|%|declare|-"
S_Filters=split(S_Filter,"|")
isFound=false
for i=0 to ubound(S_Filters)-1
if Instr(lcase(CheckString),lcase(S_Filters(i)))<>0 then
isFound=true
exit for
end if
next
if isFound then
SafeCheck=ErrorRoot&"00008"
Exit Function
else
SafeCheck=left(CheckString,CheckLength)
end if
end select
end function
%>作者: 航母风云 时间: 2010-1-11 00:24
语文没学好吧
程序代码:
asd')") and select * from article where id=1
然后提交.
却给我返回了当前页面的sql语句代码
程序代码:
<%
'添加留言.
sql="select id from Message order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.bof and rs.eof then
id=1
else
id=rs("id")+1
end if
conn.Execute("insert into Message ([id],[user],[message],[date],[time]) values ('"&id&"','"&user&"','"&message&"','"&date&"','"&time&"')")
%>