-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.jsp
executable file
·272 lines (225 loc) · 8.37 KB
/
index.jsp
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<%@ page import='java.sql.*' %>
<%@ page import='javax.sql.*' %>
<%@ page import='javax.naming.*' %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<!--$URL: http://svn.visualdistortion.org/repos/projects/old_crash/index.jsp $-->
<!--$Rev: 881 $ $Date: 2004-09-09 21:37:59 -0500 (Thu, 09 Sep 2004) $-->
<html>
<head>
<link rel="stylesheet" type="text/css" href="crash.css">
<title>Adium Crash Reporter Home</title>
</head>
<body bgcolor="#ebebeb">
<div id="top" class="top">
<span class="headTitle">Adium Crash Reporter Home</span>
<table class="tabs" cellspacing="0" width="100%" >
<tr>
<td class="tabTopPadding"></td>
</tr>
<tr><td class="tabLeftPadding"> </td>
<td class="activeTab">Home</td>
<td class="tab">
<a class="hidden" href="index.html">Submit</a>
</td>
<td class="tab">
<a class="hidden" href="search.jsp">Search</a>
</td>
<td class="tabPadding">
</td>
</tr>
</table>
</div>
<div id="doctor" class="doctor">
<img src="images/doctor.png" alt="doctor">
</div>
<div id="content" class="content">
<h3>If the viewer looks fucked up, you may need to hit refresh.</h3>
<%
Context env = (Context) new InitialContext().lookup("java:comp/env/");
DataSource source = (DataSource) env.lookup("jdbc/postgresql");
Connection conn = source.getConnection();
int currentPage, crashesPerPage, totalPages, status, view, hours;
crashesPerPage = 30;
totalPages = 0;
String urlString = new String("index.jsp?");
try {
currentPage = Integer.parseInt(request.getParameter("page"));
} catch (NumberFormatException e) {
currentPage = 1;
}
try {
view = Integer.parseInt(request.getParameter("view"));
urlString += "&view=" + view;
} catch (NumberFormatException e) {
view = -1;
}
try {
hours = Integer.parseInt(request.getParameter("hours"));
urlString += "&hours=" + hours;
} catch (NumberFormatException e) {
hours = 36;
}
String orderBy = request.getParameter("orderBy");
String orderAscDesc = request.getParameter("ascDesc");
String oppAscDesc = new String("");
if(orderBy == null || orderBy.equals("")) {
orderBy = "Build";
orderAscDesc = "desc";
}
if(orderAscDesc == null || orderAscDesc.equals("")) {
orderAscDesc = "asc";
}
if(orderAscDesc.equals("asc")) {
oppAscDesc = "desc";
} else {
oppAscDesc = "asc";
}
ResultSet rset = null;
PreparedStatement pstmt = null;
ResultSetMetaData rsmd = null;
PreparedStatement stmt = null;
ResultSet results = null;
try {
String queryString = new String("select count(*) as total from crash.crash_logs where ");
if(view == -1) {
queryString += " status_id <> 3";
} else if (view ==0 ) {
queryString += " status_id <> 0";
}else {
queryString += " status_id = " + view;
}
queryString += " and crash_time > 'now'::timestamp - \'1 hour\'::interval * " + hours;
queryString += " and application = 'Adium' ";
pstmt = conn.prepareStatement(queryString);
rset = pstmt.executeQuery();
while(rset.next()) {
totalPages = rset.getInt("total") / crashesPerPage;
if(rset.getInt("total") % crashesPerPage != 0) {
totalPages++;
}
}
queryString = "select '<img src=\"images/' || name || "+
" '.png\" alt=\"' || name || '\" /> ' || " +
" '<a href=\"view.jsp?crash=' || crash_id || '\" title=\"'"+
" || case when length(crash_log) > 500 then " +
" html_entity(substr(crash_log, 250, 700)) " +
" else html_entity(crash_log) end || '\">' || " +
" coalesce(short_desc, 'empty') || '</a>' as \"Description\", "+
" coalesce('<a href=\"mailto:' || email " +
" || '\">' || email || '</a>', service_uid) as \"From\", " +
" build as \"Build\", " +
" to_char(crash_time, 'Mon DD, YYYY HH24:MI:SS') " +
" as \"Date Submitted\""+
" from crash.crash_logs, " +
" crash.status_lookup "+
" where status_lookup.status_id = crash_logs.status_id and " +
" crash_logs.status_id ";
if(view == -1) {
queryString += "<> 3";
} else if (view == 0) {
queryString += " <> 0";
} else {
queryString += " = " + view;
}
queryString += " and crash_time > 'now'::timestamp - \'1 hour\'::interval * " +
hours;
queryString += " and application = 'Adium'";
queryString += " order by \"" + orderBy + "\" " + orderAscDesc;
queryString += " offset " + ((currentPage - 1) * crashesPerPage) +
" limit " + crashesPerPage;
pstmt = conn.prepareStatement(queryString);
rset = pstmt.executeQuery();
rsmd = rset.getMetaData();
if(totalPages > 1) {
out.println("<span style=\"text-align: right\" id=\"pages\">Pages:");
if(currentPage != 1) {
out.println("<a href=\"" + urlString + "&page=" +
(currentPage -1 ) + "&orderBy=" + orderBy +
"\" class=\"lineless\"> <<</a>");
}
for(int i = 1; i <= totalPages; i++) {
if(i != currentPage) {
out.println(" <a href=\"" + urlString + "&page=" + i +
"&orderBy=" + orderBy +
"&ascDesc=" + orderAscDesc +
"\" class=\"lineless\">" + i + "</a>");
}
else out.print("<span class=\"lineless\"><b>[" + i + "]</b></span>");
if (i % 20 == 0) {
out.print("<br>");
}
}
if(currentPage != totalPages) {
out.println("<a href=\"" + urlString + "&page=" +
(currentPage + 1) + "&orderBy=" + orderBy +
"&ascDesc=" + orderAscDesc +
"\" class=\"lineless\">>></a>");
}
out.println("</span>");
}
out.println(
"<table cellspacing=\"0\" cellpadding=\"0\" class=\"contentTable\">");
out.println("<tr>");
out.println("<td class=\"header\">#</td>");
for(int i = 1; i <= rsmd.getColumnCount(); i++) {
out.println("<td class=\"header\"><a href=\"" + urlString +
"&orderBy=" +
rsmd.getColumnName(i) +
"\">" + rsmd.getColumnName(i) + "</a>");
if(orderBy.equals(rsmd.getColumnName(i))) {
out.println("<a href=\"" + urlString + "&orderBy=" +
rsmd.getColumnName(i) + "&ascDesc=" + oppAscDesc +
"\">");
out.println("<img src=\"images/sorted_by_" + orderAscDesc +
".gif\" border=\"0\" alt=\"" + orderAscDesc + "\" />");
out.println("</a>");
}
out.println("</td>");
}
out.println("</tr>");
while(rset.next()) {
out.print("<tr class=\"" + ((rset.getRow() % 2 == 0) ? "evenRow" : "oddRow") + "\">");
out.println("<td>" + (rset.getRow() +
(currentPage - 1) * crashesPerPage) +
"</td>");
for(int i = 1; i <= rsmd.getColumnCount(); i++) {
out.println("<td>" + rset.getString(i) + "</td>");
}
out.println("</tr>");
}
out.println("</table>");
out.println("<div align=\"right\">");
stmt = conn.prepareStatement("select status_id, name from crash.status_lookup");
results = stmt.executeQuery();
out.println("<form action=\"index.jsp\" method=\"POST\">");
out.println("View: <select name=\"view\">");
out.println("<option value=\"\">Choose One ...</option>");
while(results.next()) {
out.println("<option value=\"" + results.getInt("status_id") +
"\">" + results.getString("name") + "</option>");
}
out.println("<option value=\"0\">All</option>");
out.println("</select>");
out.println("View Logs from last:");
out.println("<select name=\"hours\">");
out.println("<option value=\"1\">1 hour</option>");
out.println("<option value=\"24\">1 day</option>");
out.println("<option value=\"36\">36 hours</option>");
out.println("<option value=\"72\">3 days</option>");
out.println("<option value=\"168\">1 week</option>");
out.println("<option value=\"336\">2 weeks</option>");
out.println("<option value=\"10000000\">All</option>");
out.println("</select>");
out.println("<input type=\"submit\"></form>");
out.println("</div>");
out.println("</div>");
} finally {
if(pstmt != null) {
pstmt.close();
}
conn.close();
}
%>
</body>
</html>