復制代碼 代碼如下:
'獲取參數(shù)值
Function getForm(element,ftype)
Select case ftype
case "get"
getForm=trim(request.QueryString(element))
case "post"
getForm=trim(request.Form(element))
case "both"
if isNul(request.QueryString(element)) then getForm=trim(request.Form(element)) else getForm=trim(request.QueryString(element))
End Select
getForm=replace(getForm,CHR(34),"quot;")
getForm=replace(getForm,CHR(39),"apos;")
End Function
'主要功能就是獲取參數(shù)值,比直接用request("element")要安全很多
'過濾參數(shù)
Function filterPara(byVal Para)
filterPara=preventSqlin(Checkxss(Para))
End Function
Function preventSqlin(content)
dim sqlStr,sqlArray,i,speStr
sqlStr="|>|%|%27|'|''|;|*|and|exec|dbcc|alter|drop|insert|select|update|delete|count|master|truncate|char|declare|where|set|declare|mid|chr"
if isNul(content) then Exit Function
sqlArray=split(sqlStr,"|")
for i=lbound(sqlArray) to ubound(sqlArray)
if instr(lcase(content),sqlArray(i))>0 then
select case sqlArray(i)
case "":speStr="lt;"
case ">":speStr="gt;"
case "'","""":speStr="quot;"
'case ";":speStr=";"
case else:speStr=""
end select
content=replace(content,sqlArray(i),speStr,1,-1,1)
end if
next
preventSqlin=content
End Function
'上面的參數(shù)過濾函主要是防止sql注入,加強的防護。