Asp 常用函数

Asp 常用函数

'===textarea显示用===
function htmlencode1(fString) 
if fString<>"" and not isnull(fString) then
  fString = replace(fString, "&gt;", ">")
  fString = replace(fString, "&lt;", "<")
  fString = Replace(fString, "&nbsp;", chr(32))
  fString = Replace(fString, "</p><p>", CHR(10) & CHR(10))
  fString = Replace(fString, "<br>", CHR(10))
  htmlencode1=fString
else
  htmlencode1="" 
end if
end function


'===页面显示用===
function htmlencode2(fString)  
if fString<>"" and not isnull(fString) then
  fString = replace(fString, ">", "&gt;")
  fString = replace(fString, "<", "&lt;")
  fString = Replace(fString, chr(32), "&nbsp;")
  fString = Replace(fString, CHR(10) & CHR(10), "</p><p>")
  fString = Replace(fString, CHR(10), "<br>")
  htmlencode2=fString
else
  htmlencode2=""
end if
end function

'===取出指定字符串前后的字符串方法===
function GetStrs(str1,CharFlag,Dflag)
dim tmpstr
if Dflag=0 then'取左
  pos1=instr(str1,charFlag)
  if pos1<=20 then
      tmpstr=left(str1,pos1-1)
  else
     tmpstr=mid(str1,pos1-20,20)
  end if
else            '取右
   pos1=instr(str1,charFlag)+len(charFlag)
   if len(str1)-pos1<=20 then
      tmpstr=right(str1,len(str1)-pos1)
   else
      tmpstr=mid(str1,pos1+1,20)
   end if
end if
GetStrs=tmpstr
end function

'===取出文件名===
function getfilename(str)
 pos=instr(str,".")
 if str<>"" then
  str=mid(str,pos,len(str))
 end if
 getfilename=str
end function

 


'===取到浏览器版本转换字符串===
function browser()
 dim text 
 text = Request.ServerVariables("HTTP_USER_AGENT")
 if Instr(text,"MSIE 5.5")>0 then
  browser="IE 5.5"
 elseif Instr(text,"MSIE 6.0")>0 then
  browser="IE 6.0"
 elseif Instr(text,"MSIE 5.01")>0 then
  browser="IE 5.01"
 elseif Instr(text,"MSIE 5.0")>0 then
  browser="IE 5.00"
 elseif Instr(text,"MSIE 4.0")>0 then
  browser="IE 4.01"
  else
  browser="未知"
 end if
end function

'===取到系统脚本转换字符串===
function system(text)
 if Instr(text,"NT 5.1")>0 then
  system=system+"Windows XP"
 elseif Instr(text,"NT 5")>0 then
  system=system+"Windows 2000"
 elseif Instr(text,"NT 4")>0 then
  system=system+"Windows NT4"
 elseif Instr(text,"4.9")>0 then
  system=system+"Windows ME"
 elseif Instr(text,"98")>0 then
  system=system+"Windows 98"
 elseif Instr(text,"95")>0 then
  system=system+"Windows 95"
  else
  system=system+"未知"
 end if
end function
'====删除文件===
function delfile(filepath)
 imangepath=trim(filepath)
 path=server.MapPath(imangepath)
 SET fs=server.CreateObject("Scripting.FileSystemObject")
 if FS.FileExists(path) then
  FS.DeleteFile(path)     
 end if 
    set fs=nothing
end function

'===得到真实的客户端IP===
Public Function GetClientIP()
dim uIpAddr
' 本函数参考webcn.Net/AspHouse 文献<取真实的客户IP>
uIpAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If uIpAddr = "" Then uIpAddr = Request.ServerVariables("REMOTE_ADDR")
GetClientIP = uIpAddr
uIpAddr = ""
End function  


'===取到浏览器版本转换字符串===
function browser()
 dim text 
 text = Request.ServerVariables("HTTP_USER_AGENT")
 if Instr(text,"MSIE 5.5")>0 then
  browser="IE 5.5"
 elseif Instr(text,"MSIE 6.0")>0 then
  browser="IE 6.0"
 elseif Instr(text,"MSIE 5.01")>0 then
  browser="IE 5.01"
 elseif Instr(text,"MSIE 5.0")>0 then
  browser="IE 5.00"
 elseif Instr(text,"MSIE 4.0")>0 then
  browser="IE 4.01"
  else
  browser="未知"
 end if
end function

'===取到系统脚本转换字符串===
function system(text)
 if Instr(text,"NT 5.1")>0 then
  system=system+"Windows XP"
 elseif Instr(text,"NT 5")>0 then
  system=system+"Windows 2000"
 elseif Instr(text,"NT 4")>0 then
  system=system+"Windows NT4"
 elseif Instr(text,"4.9")>0 then
  system=system+"Windows ME"
 elseif Instr(text,"98")>0 then
  system=system+"Windows 98"
 elseif Instr(text,"95")>0 then
  system=system+"Windows 95"
  else
  system=system+"未知"
 end if
end function
'====删除文件===
function delfile(filepath)
 imangepath=trim(filepath)
 path=server.MapPath(imangepath)
 SET fs=server.CreateObject("Scripting.FileSystemObject")
 if FS.FileExists(path) then
  FS.DeleteFile(path)     
 end if 
    set fs=nothing
end function

'===得到真实的客户端IP===
Public Function GetClientIP()
dim uIpAddr
' 本函数参考webcn.Net/AspHouse 文献<取真实的客户IP>
uIpAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If uIpAddr = "" Then uIpAddr = Request.ServerVariables("REMOTE_ADDR")
GetClientIP = uIpAddr
uIpAddr = ""
End function

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值