做网页时常用的ASP函数

作者:凯旋网络来源:凯旋网络

''----------------------------------------------------------------------
'' 函数功能: 屏蔽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 字符型数据

_com


''----------------------------------------------------------------------
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
 
  • 广告推荐