<% ' TSystem 系统函数类 ' 可独立,不用包含其他文件 Dim sys : Set sys = new TSystem Class TSystem Property Get SID() SID = Session.SessionID End Property Function getSession(aKey) getSession = Session(SID & aKey) End Function Sub setSession(aKey,aValue) Session(SID & aKey) = aValue End sub Function getCookie(aName) getCookie = Trim(request.cookies(aName)) End Function Sub setCookie(aName,aValue,aDay) Response.cookies(aName) = aValue If IsNumeric(aDay) Then Response.cookies(aName).expires = DateAdd("d",aDay,Now()) End If End Sub Sub print(aStr) response.write aStr End Sub Sub halt response.End End Sub Sub go(aURL) response.redirect aURL End Sub Function goBack(aMessage) Dim MSG : MSG = "<script language=""javascript"">alert(""{0}"");self.history.go(-1);</script>" print Replace(MSG,"{0}",aMessage) halt End Function Function toStr(aStr) If isnull(aStr) then toStr = "" Else toStr = cstr(aStr) End If End Function Function toHtml(aText) toHtml = server.htmlencode(tostr(aText)) End Function Function toUrl(aText) toUrl = server.urlencode(tostr(aText)) End Function Function toByte(aStr) dim i,iChr,sChr,iLow,iHigh toByte = "" For i = 1 To Len(aStr) sChr = mid(aStr,i,1) iChr = Asc(sChr) If iChr < 0 Then iChr = iChr + 65535 If iChr > 255 Then iLow = Left(Hex(Asc(sChr)),2) iHigh = Right(Hex(Asc(sChr)),2) toByte = toByte & chrB("&H" & iLow) & chrB("&H" & iHigh) Else toByte = toByte & chrB(AscB(sChr)) End If Next End Function Function toDir(aDir) ' + / If Right(aDir,1) <> "/" Then aDir = aDir & "/" toDir = aDir End Function Function toPath(aPath) ' + / If Right(aPath,1) <> "/" Then aPath = aPath & "/" toPath = aPath End Function Function iif(aBool,aTrue,aFalse) if aBool = true then iif = aTrue else iif = aFalse End if End Function Function getPath(aPath) getPath = server.mappath(aPath) End Function Function getObj(aName) Set getObj = server.CreateObject(aName) End Function Function getRq(aName) getRq = Trim(request(aName)) End Function Function getReferer() getReferer = getVar("http_referer") End Function Function getIP() getURL = getVar("remote_addr") End Function Function getURL() getURL = getVar("path_info")' & "?" & request.querystrings End Function Function getVar(aName) getVar = request.servervariables(aName) End Function Function replaceCR(aText) aText = iif(IsNull(aText),"",aText) replaceCR = Replace(aText,Chr(13),"<br/>") End Function Function replaceRegExp(aText,aPattern,aStr) aText = iif(IsNull(aText),"",aText) Dim re Set re = new RegExp re.IgnoreCase = False re.Global = True re.MultiLine = true re.Pattern = aPattern replaceRegExp = re.Replace(aText,aStr) Set re = nothing End Function Function format(str,arr) Dim fs : fs = str If Not IsArray(arr) Then Exit Function Dim i For i = LBound(arr) To UBound(arr) fs = Replace(fs,"{" & i & "}",tostr(arr(i))) Next format = fs End Function Function formatDate(value,format) Dim y,m,d,h,mi,s If Not IsDate(value) Then Exit Function y = Year(value) m = Right("0" & Month(value),2) d = Right("0" & Day(value),2) h = Right("0" & hour(value),2) mi = Right("0" & minute(value),2) s = Right("0" & second(value),2) format = Replace(Replace(Replace(format,"yyyy",y),"mm",m),"dd",d) format = Replace(Replace(Replace(format,"hh",h),"mi",mi),"ss",s) formatDate = format End Function Function guid() Dim lib set lib = getObj("ScriptLet.TypeLib") guid = lib.Guid Set lib = nothing End Function 'trimAll Functions begin Private Function checkChr(aChr) Dim chrs,i chrs = Array(" ",Chr(9),Chr(10),Chr(13)) For i = lBound(chrs) To UBound(chrs) If aChr = chrs(i) Then checkChr = True Exit Function End if Next checkChr = false End Function Function trimLeft(str) While checkChr(Left(str,1)) str = Right(str,Len(str) - 1) WEnd trimLeft = str End Function Function trimRight(str) While checkChr(right(str,1)) str = left(str,Len(str) - 1) WEnd trimRight = str End Function Function trimAll(str) trimAll = trimLeft(trimRight(str)) End Function 'trimAll Functions End Function FileExists(aFile) Dim fso:Set fso = getObj("Scripting.FileSystemObject") FileExists = fso.FileExists(aFile) 'FolderExists Set fso = Nothing End Function Function getDir(aPath) getDir = left(aPath,InstrRev(aPath,"/")) End Function Function getName(aPath) getName = right(aPath,Len(aPath) - InstrRev(aPath,"/")) End function End Class %>