天枫常用的ASP函数封装如下

2019-01-13 12:34:05王振洲

    '****************************************************
 '函数名:ResponseCookies
 '作  用:写入COOKIES
 '参  数:Key ----cookie名
 '        value ----cookie值
 '        expires ---- cookie过期时间
 '****************************************************
 Public Function ResponseCookies(Key,Value,Expires)
  DomainPath=Left(Request.ServerVariables("script_name"),inStrRev(Request.ServerVariables("script_name"),"/"))
  Response.Cookies(Key)=""&Value&""
  if Expires<>0 then Response.Cookies(Key).Expires=date+Expires
  Response.Cookies(Key).Path=DomainPath
 End Function

    '****************************************************
 '函数名:CleanCookies
 '作  用:清除COOKIES
 '****************************************************
 Public Function CleanCookies()
  DomainPath=Left(Request.ServerVariables("script_name"),inStrRev(Request.ServerVariables("script_name"),"/"))
  For Each objCookie In Request.Cookies
   Response.Cookies(objCookie)= ""
   Response.Cookies(objCookie).Path=DomainPath
  Next
 End Function

 '****************************************************
 '函数名:GetTimeOver
 '作  用:清除COOKIES
 '参  数:flag ---显示时间单位1=秒,否则毫秒
 '****************************************************
 Public Function GetTimeOver(flag)
  Dim EndTime
  If flag = 1 Then
   EndTime=FormatNumber(Timer() - StartTime, 6, true)
   getTimeOver = " 本页执行时间: " & EndTime & " 秒"
  Else
   EndTime=FormatNumber((Timer() - StartTime) * 1000, 3, true)
   getTimeOver =" 本页执行时间: " & EndTime & " 毫秒"
  End If
 End function
'-----------------系列格式化------------------------

 '****************************************************
 '函数名:FormatSize
 '作  用:大小格式化
 '参  数:size ----要格式化的大小
 '****************************************************
 Public Function FormatSize(dsize)
  if dsize>=1073741824 then
   FormatSize=Formatnumber(dsize/1073741824,2) & " GB"
  elseif dsize>=1048576 then
   FormatSize=Formatnumber(dsize/1048576,2) & " MB"
  elseif dsize>=1024 then
   FormatSize=Formatnumber(dsize/1024,2) & " KB"
  else
   FormatSize=dsize & " Byte"
  end if
 End Function