ASP函数库

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2008-8-28 3:38:24 我要发布文章
译引擎
' 4 : 服务器软件的名称及版本
' 5 : 服务器正在运行的端口
' 6 : 服务器CPU数量
' 7 : 服务器Application数量
' 8 : 服务器Session数量
' 9 : 请求的物理路径
'10 : 请求的URL
'11 : 服务器当前时间
'12 : 脚本连接超时时间
'13 : 服务器CPU详情
'14 :
'返回值:返回信息字串
'示 例:GetServerInfo(2)
'**************************************************
Public Function GetServerInfo(ByVal Lx)
  GetServerInfo=""
  Dim okCPUS, okCPU, okOS
  on error resume next
  Set WshShell = server.CreateObject("WScript.Shell")
  Set WshSysEnv = WshShell.Environment("SYSTEM")
  okOS = cstr(WshSysEnv("OS"))
  okCPUS = cstr(WshSysEnv("NUMBER_OF_PROCESSORS"))
  okCPU = cstr(WshSysEnv("PROCESSOR_IDENTIFIER"))
  if isnull(okCPUS) & "" = "" then
    okCPUS = Request.ServerVariables("NUMBER_OF_PROCESSORS")
  end if
  tnow = now():oknow = cstr(tnow)
  if oknow <> year(tnow) & "-" & month(tnow) & "-" & day(tnow) & " " & hour(tnow) & ":" & right(FormatNumber(minute(tnow)/100,2),2) & ":" & right(FormatNumber(second(tnow)/100,2),2) then oknow = oknow & " (日期格式不规范)"
  If Lx=0  Then GetServerInfo=Request.ServerVariables("server_name")
  If Lx=1  Then GetServerInfo=Request.ServerVariables("LOCAL_ADDR")
  If Lx=2  Then GetServerInfo=okOS     ''  Request.ServerVariables("OS")
  If Lx=3  Then GetServerInfo=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion
  If Lx=4  Then GetServerInfo=Request.ServerVariables("SERVER_SOFTWARE")
  If Lx=5  Then GetServerInfo=Request.ServerVariables("server_port")
  If Lx=6  Then GetServerInfo=okCPUS   ''  Request.ServerVariables("NUMBER_OF_PROCESSORS")
  If Lx=7  Then GetServerInfo=Application.Contents.Count
  If Lx=8  Then GetServerInfo=Session.Contents.Count
  If Lx=9  Then GetServerInfo=Request.ServerVariables("path_translated")
  If Lx=10 Then GetServerInfo=Request.ServerVariables("server_name")&Request.ServerVariables("script_name")
  If Lx=11 Then GetServerInfo=oknow
  If Lx=12 Then GetServerInfo=Server.ScriptTimeout
  If Lx=13 Then GetServerInfo=okCPU
End Function
'**************************************************
'函数ID:0032[产生20位长度的唯一标识ID]
'函数名:MakeTheID
'作 用:产生20位长度的唯一标识ID
'参 数: ----
'返回值:返回20位长度的唯一标识ID
'示 例:MakeTheID()
'**************************************************
Public Function MakeTheID()
  DIM datestr,mytime,myyear,mymonth,myday,i
  myyear = cstr(year(date()))
  mymonth = cstr(month(date()))
  myday = cstr(day(date()))
  mymonth = lpad(mymonth,0,2)
  MakeTheID = myyear & "_" & mymonth & "_" & myday & "_"
  datestr=cstr(now())
  i = instr(datestr," ")
  mytime = right(datestr,len(datestr)-i)
  mytime = replace(mytime,":","_")
  randomize
  i = Int((9999 - 1000 + 1) * Rnd + 1000)
  MakeTheID = MakeTheID & mytime & "_" & i
  MakeTheID = replace(MakeTheID,"_","")
end function
'**************************************************
'函数ID:0033[用于左填充指定数量的字符,以达到规范长度]
'函数名:lpad
'作 用:用于左填充指定数量的字符,以达到规范长度
'参 数:desstr  ---- 目标字符
'参 数:padchar ---- 填充字符
'参 数:lenint  ---- 填充后的字符总长度
'返回值:返回字符
'示 例:response.write lpad(4,0,5),结果显示00004
'**************************************************
Public Function  lpad(ByVal desstr,ByVal padchar,ByVal lenint)
  dim d,p,t
  d = cstr(desstr)
  p = cstr(padchar)
  lpad=""
  for t=1 to lenint-len(d)
      lpad = p & lpad
  next
  lpad = lpad & d
end function
'**************************************************
'函数ID:0034[用于右填充指定数量的字符,以达到规范长度]
'函数名:rpad
'作 用:用于右填充指定数量的字符,以达到规范长度
'参 数:desstr  ---- 目标字符
'参 数:padchar ---- 填充字符
'参 数:lenint  ---- 填充后的字符总长度
'返回值:返回字符
'示 例:response.write rpad('a',0,5),结果显示a0000
'**************************************************
Public Function rpad(ByVal desstr,ByVal padchar,ByVal lenint)
  dim d,p,t
  d = cstr(desstr)
  p = cstr(padchar)
  rpad=""
  for t=1 to lenint-len(d)
      rpad = p & rpad 
  next
  rpad = d & rpad
end function
'**************************************************
'函数ID:0035[格式化时间(显示)]
'函数名:Format_Time
'作 用:格式化时间(显示)
'参 数:s_Time  ---- 时间变量
'参 数:n_Flag  ---- 时间样式类型代码
' 1:"yyyy-mm-dd hh:mm:ss"
' 2:"yyyy-mm-dd"
' 3:"hh:mm:ss"
' 4:"yyyy年mm月dd日"
' 5:"yyyymmdd"
' 6:"MM/DD"
'返回值:返回格式化后时间
'示 例:response.write Format_Time(now(),4)
'**************************************************
Public Function Format_Time(ByVal s_Time,ByVal n_Flag)
  Dim y, m, d, h, mi, s
  Format_Time = ""
  If IsDate(s_Time) = False Then Exit Function
  y = cstr(year(s_Time))
  m = cstr(month(s_Time))
  If len(m) = 1 Then m = "0" & m
  d = cstr(day(s_Time))
  If len(d) = 1 Then d = "0" & d
  h = cstr(hour(s_Time))
  If len(h) = 1 Then h = "0" & h
  mi = cstr(minute(s_Time))
  If len(mi) = 1 Then mi = "0" & mi
  s = cstr(second(s_Time))
  If len(s) = 1 Then s = "0" & s
  Select Case n_Flag
  Case 1
  ' yyyy-mm-dd hh:mm:ss
   Format_Time = y & "-" & m & "-" & d & " " & h & ":" & mi & ":" & s
  Case 2
  ' yyyy-mm-dd
   Format_Time = y & "-" & m & "-" & d
  Case 3
  ' hh:mm:ss
   Format_Time = h & ":" & mi & ":" & s
  Case 4
  ' yyyy年mm月dd日
   Format_Time = y & "年" & m & "月" & d & "日"
  Case 5
  ' yyyymm

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17]  下一页