-
Notifications
You must be signed in to change notification settings - Fork 1
/
500.asp
124 lines (112 loc) · 5.21 KB
/
500.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<%option explicit%>
<!DOCTYPE html>
<%
'Generate Table
Function GenerateTable(obj, table)
Dim var, varItem, htmTable
htmTable = "<table id='info"& table &"'>"
htmTable = htmTable & "<tr><th colspan='2'>"& table &" Variables ("& obj.Count &")</th></tr>"
For Each var in obj
If IsArray(obj(var)) Then
For varItem = LBound(obj(var)) to UBound(obj(var))
htmTable = htmTable & "<tr>"
htmTable = htmTable & "<th>" & var & " " & varItem & "</th>"
htmTable = htmTable & "<td>" & obj(var)(varItem) & "</td>"
htmTable = htmTable & "</tr>"
Next
Else
htmTable = htmTable & "<tr>"
htmTable = htmTable & "<th>" & var & "</th>"
htmTable = htmTable & "<td>" & obj(var) & "</td>"
htmTable = htmTable & "</tr>"
End If
Next
htmTable = htmTable & "</table>"
GenerateTable = htmTable
End Function
'Get Error
Dim objASPError
Set objASPError = Server.GetLastError
'Reset Response
If Response.Buffer Then
Response.Clear
Response.Status = "500 Internal Server Error"
Response.ContentType = "text/html"
Response.Expires = 0
End If
'CSS
dim style : style = "<style type='text/css'>"
style = style & "table { width: 800px;} "
style = style & "#debugInfo th{ text-align:left; background-color:palegoldenrod; }"
style = style & "#debugInfo td{ background-color:lightgoldenrodyellow; }"
style = style & "#infoSession tr:first-child th{ text-align:center;bpadding:2px;background-color:dodgerblue; }"
style = style & "#infoSession th{ text-align:left; background-color:cyan;}"
style = style & "#infoSession td{ background-color:lightcyan; }"
style = style & "#infoApplication tr:first-child th{ text-align:center;padding:2px;background-color:tomato; }"
style = style & "#infoApplication th{ text-align:left; background-color:lightcoral; }"
style = style & "#infoApplication td{ background-color:pink; }"
style = style & "#infoServer tr:first-child th{ text-align:center;padding:2px;background-color:mediumseagreen; }"
style = style & "#infoServer th{ text-align:left; background-color:limegreen;}"
style = style & "#infoServer td{ background-color:palegreen; }"
style = style & "</style>"
' Error Message
Dim errMsg : errMsg = ""
errMsg = errMsg &"<p>"
errMsg = errMsg & objASPError.Category & "(0x" & hex(objASPError.Number) & ")<br />"
errMsg = errMsg & objASPError.Description & "<br />"
errMsg = errMsg & objASPError.File & ", line " & objASPError.Line & "<br />"
errMsg = errMsg & objASPError.Source & "<br />"
errMsg = errMsg & "</p>"
'Debug Info
Dim debugInfo : debugInfo = ""
debugInfo = debugInfo & "<table id='debugInfo'>"
debugInfo = debugInfo & "<tr> <th colspan='2' style='text-align:center;background-color:gold;padding:2px;'>Debug Information</th> </tr>"
debugInfo = debugInfo & "<tr> <th>User</th> <td>"& Request.serverVariables("AUTH_USER") &"</td> </tr>"
debugInfo = debugInfo & "<tr> <th>Time</th> <td>"& Now() &"</td> </tr>"
debugInfo = debugInfo & "<tr> <th>Page</th> <td>"& Request.ServerVariables("SCRIPT_NAME") &"</td> </tr>"
debugInfo = debugInfo & "<tr> <th>User IP</th> <td>"& Request.ServerVariables("REMOTE_HOST") & " (" & Request.ServerVariables("REMOTE_ADDR") &")</td> </tr>"
debugInfo = debugInfo & "<tr> <th>Browser</th> <td>"& Request.ServerVariables("HTTP_USER_AGENT") &"</td> </tr>"
debugInfo = debugInfo & "<tr> <th>Server</th> <td>"& Request.ServerVariables("SERVER_NAME") & " (" & Request.ServerVariables("LOCAL_ADDR") &")</td> </tr>"
debugInfo = debugInfo & "<tr> <th>Referer</th> <td>"& Request.ServerVariables("HTTP_REFERER") & "</td> </tr>"
debugInfo = debugInfo & "<tr> <th>POST</th> <td>"& Request.Form &"</td> </tr>"
debugInfo = debugInfo & "</table>"
'Session Variables
dim sessionTable
sessionTable = GenerateTable(Session.Contents, "Session")
'Application Variables
dim appTable
appTable = GenerateTable(Application.Contents, "Application")
'Server Variables
dim serverTable
serverTable = GenerateTable(Request.ServerVariables, "Server")
' Compile Error Information
dim errorDump
errorDump = errMsg & debugInfo & sessionTable & appTable & serverTable
'Send Email
dim tech : tech = CreateObject("WScript.Network").UserName = "ITGuy"
If NOT tech Then
Dim oMessage : Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.site.com"
oMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMessage.Configuration.Fields.Update
oMessage.To = "[email protected]"
oMessage.From = "[email protected]"
oMessage.Subject = "Error - " & objASPError.Category
oMessage.htmlBody = style & errorDump
oMessage.Send
End If
%>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%=Application("Name")%> Error</title>
<% If tech Then Response.Write style%>
</head>
<body>
Sorry! The system encountered an error. An email has been sent to IT. If you have any concerns or questions please send an email to <a href="mailto:[email protected]">[email protected]</a> or call x5555.
<div style="<% If NOT tech Then Response.Write "display:none;" %>">
<%=errorDump%>
</div>
</body>
</html>