日期:2010-03-11  浏览次数:20759 次

'----------------------------------------------------------------------
' 函数功能: 屏蔽HTML代码
' 参  数: StrInput 用户输入信息
'----------------------------------------------------------------------
function FunInput(StrInput)
if not isnull(Str) then
  StrInput=RePlace(StrInput,"<","<")
  StrInput=replace(StrInput,">",">")
  StrinPut=replace(Strinput,chr(32)," ")
  strinput=replace(strinput,chr(34),""")
  strinput=replace(strinput,chr(39),"'")
  strinput=replace(strinput,chr(13),"")
  FunInput=strinput
end if
end function
 
'----------------------------------------------------------------------
' 函数功能: 防止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,"'","''")
   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,chr(255),"")
   StrValue=replace(StrValue,"*","")
   StrValue=replace(StrValue,"%","")
  end if
end if
FunSQL=StrValue
end function
 
'--------------------------------------------------------------------------
' 函数功能: 常用类型转换
' 参    数:   _Type 数据类型
'    _Value  数据
' 参 数 值:   _Type  1 :  转换成数值型数据
'               _Type  2 :  转换成字符型数据
'               _Type  3 :  转换成布尔型数据   
'--------------------------------------------------------------------------
function FunSwitch(Value_,Type_)
on error resume next
select case Type_
  case 1
  if isnumeric(Value_) then
   if not isnull(Value_) then
    FunSwitch=clng(Value_)
   else
    FunSwitch=0
   end if
  else
   FunSwitch=0
  end if
  case 2
   if not isnull(Value_) then
    FunSwitch=cstr(Value_)
   else
    FunSwitch=""
   end if
  case 3
   if not isnull(Value_) and isnumeric(Value_) then
    FunSwitch=cbool(Value_)
   else
    FunSwitch=false
   end if
  case else
   response.redirect("Error.asp?err=请指定 FunSwitch 中要转达换成的数据类型!")
end select
if err.number<>0 then
response.redirect("Error.asp?err=数据转换时产生未知错误!")
err.clear
end if
end function
''----------------------------------------------------------------------
' 函数功能: 验证是数据是否来自外部
' 参    数: