看图猜成语一男一女:这段SQL代码是什么意思?

来源:百度文库 编辑:高考问答 时间:2024/05/12 18:29:55
'---------------------------------------------------------
'函数功能:防止SQL注入
'参 数:StrValue 用户提交的数据,BloType 数据类型
'参 数 值: true 数值型数据,false 字符型数据
'-----------------------------------------------------------------
function FunSQL(StrValue,BloType)
if BloType then
if Isnumeric(StrValue) then
FunSQL=clng(StrValue)
else
StrValue=0
end if
else
if not isnull(StrValue) then
StrValue=lcase(StrValue)
StrValue=replace(StrValue,"select","")
StrValue=replace(StrValue,"update","")
StrValue=replace(StrValue,"insert","")
StrValue=replace(StrValue,"delete","")
StrValue=replace(StrValue,";","")
StrValue=replace(StrValue," ","")
StrValue=replace(StrValue,"*","")
StrValue=replace(StrValue,"%","")
StrValue=replace(StrValue,"'","")
end if
end if
FunSQL=StrValue
end function

希望成一句一句分析,分析每句的意思
这段代码用在什么地方?是直接加入conn.asp中么?在其他文件中是否需要用上该代码中的某个函数呢?
.

还有这个

'********************************************
' 目的: 过滤表单、URL参数
' 入口: str----表单、URL参数
' 返回: 被过滤后的表单、URL参数
'********************************************
Public Function ChkRStr(strV)
If (Not IsNull(strV)) Then
ChkRStr=Replace(strV,"'","<li>'</li>")
Else
ChkRStr=""
End If
End Function

其中的函数都在哪个文件中出现呢?

意思就是:是不是只在conn.asp文件中加入就可以了,其他文件不用调用其中的函数么?也就是说其他文件与这段代码没关系么?

直接把这些代码加入或者调用用conn.asp中,IE就能认识这些代码,判断这些代码么

.

这段代码是的作用,过滤用户提交的数据中含有的SQL内容,发现select等字符串就替换成空。
可以加入到conn.asp中,也可以单独做一个文件,当用户提交数据后,用这个函数过滤一下就安全啦。

function FunSQL(StrValue,BloType)
if BloType then
if Isnumeric(StrValue) then '如果strvalue是数字 then
FunSQL=clng(StrValue) '再把 strvalue 转换成整数 给 funsql
else '如果strvalue不是数字型,则
StrValue=0 'strvalue=0
end if
else
if not isnull(StrValue) then '如果不为空 then
StrValue=lcase(StrValue) '参数是任意有效的字符串表达式。如果 string 参数中包含 Null,则返回 Null
StrValue=replace(StrValue,"select","") '将StrValue中含有select替代为空
StrValue=replace(StrValue,"update","") '将StrValue中含有update替代为空

StrValue=replace(StrValue,"insert","") '将StrValue中含有insert替代为空

StrValue=replace(StrValue,"delete","") '将StrValue中含有 delete 替代为空

StrValue=replace(StrValue,";","") '将StrValue中含有 ; 替代为空

StrValue=replace(StrValue," ","") '将StrValue中含有 替代为空

StrValue=replace(StrValue,"*","") '将StrValue中含有 * 替代为空

StrValue=replace(StrValue,"%","") '将StrValue中含有 % 替代为空

StrValue=replace(StrValue,"'","") '将StrValue中含有 ' 替代为空

end if
end if
FunSQL=StrValue '最后把StrValue 里面的值给FunSQL
end function

FunSQL 到最后都变成了数值型的啊

以上是当你要去检查用户从ie浏览器提交过来的信息时,只可以让用户提交数字的时候使用.
也不一定要放在conn.asp

Public Function ChkRStr(strV)
If (Not IsNull(strV)) Then
ChkRStr=Replace(strV,"'","<li>'</li>")
Else
ChkRStr=""
End If
End Function

上面的是把 strV 里面所有的单引 替换成 <li>'</li>