File: D:/web/itpartnership/browsertest/apputils.asp
<%
' global constants and variables '
Dim strWebLog
strWebLog = ""
' main variables '
Initialise
' (SS,13/8/04) runs code to be run before all templates '
Sub Initialise
End Sub
' (SS,28/9/2004) sends email with the browser info, inc form values etc. '
' also writes to file '
Sub WebDebugLog(AParameter)
Dim NL
NL = Chr(13) & Chr(10)
If Application("WebDebugLogType") = "" Then Exit Sub
Dim LBody, LName, LKeyName, i
LBody = ""
LBody = LBody & "----------------" & NL
LBody = LBody & "Server Date/Time" & NL
LBody = LBody & "----------------" & NL
LBody = LBody & Now & NL
LBody = LBody & NL
LBody = LBody & "------------------------" & NL
LBody = LBody & "Parameter to WebDebugLog" & NL
LBody = LBody & "------------------------" & NL
LBody = LBody & AParameter & NL
LBody = LBody & NL
LBody = LBody & "----------------------" & NL
LBody = LBody & "QueryString Collection" & NL
LBody = LBody & "----------------------" & NL
For Each LName in Request.QueryString
LBody = LBody & LName & " = " & Request.QueryString(LName) & NL
Next
LBody = LBody & NL
LBody = LBody & "---------------" & NL
LBody = LBody & "Form Collection" & NL
LBody = LBody & "---------------" & NL
For Each LName in Request.Form
LBody = LBody & LName & " = " & Request.Form(LName) & NL
Next
LBody = LBody & NL
LBody = LBody & "------------------" & NL
LBody = LBody & "Cookies Collection" & NL
LBody = LBody & "------------------" & NL
For Each LName in Request.Cookies
If Request.Cookies(LName).HasKeys Then 'cookies with keys '
For Each LKeyName in Request.Cookies(LName)
LBody = LBody & LName & "(" & LKeyName & ")" & " = " & Request.Cookies(LName)(LKeyName) & NL
Next
Else ' normal cookies '
LBody = LBody & LName & " = " & Request.Cookies(LName) & NL
End If
Next
LBody = LBody & NL
LBody = LBody & "-----------------" & NL
LBody = LBody & "Session Variables" & NL
LBody = LBody & "-----------------" & NL
For Each LName in Session.Contents
If IsArray(Session(LName)) Then
For i = LBound(Session(LName)) To UBound(Session(LName))
LBody = LBody & LName & "(" & i & ")" & " = " & Session(LName)(i) & NL
Next
Else
LBody = LBody & LName & " = " & Session.Contents(LName) & NL
End If
Next
LBody = LBody & NL
LBody = LBody & "----------------------" & NL
LBody = LBody & "Session Static Objects" & NL
LBody = LBody & "----------------------" & NL
For Each LName in Session.StaticObjects
LBody = LBody & LName & " = " & LName & NL
Next
LBody = LBody & NL
LBody = LBody & "---------------------" & NL
LBody = LBody & "Application Variables" & NL
LBody = LBody & "---------------------" & NL
For Each LName in Application.Contents
If IsArray(Application(LName)) Then
For i = LBound(Application(LName)) To UBound(Application(LName))
LBody = LBody & LName & "(" & i & ")" & " = " & Application(LName)(i) & NL
Next
Else
LBody = LBody & LName & " = " & Application.Contents(LName) & NL
End If
Next
LBody = LBody & NL
LBody = LBody & "--------------------------" & NL
LBody = LBody & "Application Static Objects" & NL
LBody = LBody & "--------------------------" & NL
For Each LName in Application.StaticObjects
LBody = LBody & LName & " = " & LName & NL
Next
LBody = LBody & NL
LBody = LBody & "----------------" & NL
LBody = LBody & "Server Variables" & NL
LBody = LBody & "----------------" & NL
For Each LName in Request.ServerVariables
LBody = LBody & LName & " - " & Request.ServerVariables(LName) & NL
Next
LBody = LBody & NL
strWebLog = ReplaceStr(LBody, NL, "<br>")
If Application("WebDebugLogType") = "File" Or Application("WebDebugLogType") = "Both" Then
WriteToFile "logs/webdebug.txt", "***** START *****" & NL & NL & LBody & NL & "***** END *****" & NL & NL & NL
End If
If Application("WebDebugLogType") = "Email" Or Application("WebDebugLogType") = "Both" Then
If Application("WebDebugLogEmail") <> "" Then
SendEmail Application("WebDebugLogEmail"), "", Application("WebDebugLogEmail"), "Web Debug Log", LBody
End If
End If
End Sub
' (SS,29/9/04) writes given text to given file name '
' if file exists it is appended to else a new file created '
' there must be modify and write access for Internet Guest account to this file or folder '
Sub WriteToFile(AFileName, LText)
Const ForAppending = 8
Application.Lock
Dim LobjOpenFile, LobjFSO, LstrPath
LstrPath = Server.MapPath(AFileName)
Set LobjFSO = Server.CreateObject("Scripting.FileSystemObject")
If LobjFSO.FileExists(LstrPath) Then
Set LobjOpenFile = LobjFSO.OpenTextFile(LstrPath, ForAppending)
Else
Set LobjOpenFile = LobjFSO.CreateTextFile(LstrPath)
End If
LobjOpenFile.Write LText
LobjOpenFile.Close
Set LobjOpenFile = Nothing
Set LobjFSO = Nothing
Application.UnLock
End Sub
' (SS,6/8/04) sends email to given address '
' (SS,27/9/04) added ABCCEmailAddress
Sub SendEmail(AEmailAddress, ABCCEmailAddress, AFromEmailAddress, ASubject, ABody)
' send the email using Dundas Mailer Control
Dim objEmail 'Mailer control
Set objEmail = Server.CreateObject("Dundas.Mailer")
objEmail.SMTPRelayServers.Add Application("MailServer")
'set Mailer control properties and collection items
objEmail.TOs.Add AEmailAddress
If ABCCEmailAddress <> "" Then objEmail.BCCs.Add ABCCEmailAddress
objEmail.FromAddress = AFromEmailAddress
objEmail.Subject = ASubject
objEmail.Body = ABody
'send email
objEmail.SendMail
'you can test for the success/failure of the operation by examining VBScript's Err object here
Set objEmail = Nothing
End Sub
' Replace in String AStr, all occurrences of AReplace with AWith '
Function ReplaceStr(AStr, AReplace, AWith)
Dim p, LStr
ReplaceStr = ""
LStr = AStr
Do While LStr <> ""
p = InStr(LStr, AReplace)
If p > 0 Then
ReplaceStr = ReplaceStr + Mid(LStr, 1, p - 1) + AWith
LStr = Mid(LStr, p + Len(AReplace), Len(LStr))
Else
ReplaceStr = ReplaceStr + LStr
LStr = ""
End if
Loop
End Function
%>