forked from lociii/sphinxLogAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
181 lines (172 loc) · 3.53 KB
/
index.php
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
<?php
header('Content-Type: text/html; charset=utf-8');
ini_set('display_errors', true);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '128M');
// process logfile
if (isset($_GET['submit']) && is_readable($_GET['file']) && !empty($_GET['name'])) {
require dirname(__FILE__).'/lib/analyzer.php';
$sphinxAnalyzer = new sphinxLogAnalyzer();
$file = 'logs/'.base64_encode($_GET['name']).'.txt';
$result = $sphinxAnalyzer->analyze($_GET['file']);
file_put_contents($file, serialize($result));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv=content-type content="text/html; charset=UTF-8">
<title>searchd query log analyzer</title>
<style type="text/css">
body, tr, td
{
margin: 0;
padding: 0;
font-family: Verdana, Arial, Sans-Serif;
color: #000000;
}
body
{
padding-left: 40px;
margin-right: 50px;
margin-top: 10px;
}
form {
background-color: lightgreen;
padding: 10px;
}
h1
{
width: 100%;
background-color: lightblue;
font-size: 16pt;
margin-left: -40px;
padding: 3px;
padding-left: 40px;
}
h2
{
font-size: 12pt;
cursor: pointer;
}
table.result
{
width: 100%;
margin-bottom: 20px;
}
table.result tbody tr td
{
background-color: #DDDDDD;
}
table.result thead tr th
{
text-align: left;
background-color: lightblue;
}
table.resultSlow thead tr th
{
cursor: pointer;
}
table.result thead tr th.headerSortUp {
background-image: url(asc.png);
background-repeat: no-repeat;
background-position: top right;
}
table.result thead tr th.headerSortDown {
background-image: url(desc.png);
background-repeat: no-repeat;
background-position: top right;
}
table.result tbody tr td, table.result thead tr th
{
padding: 3px;
}
div.resultsets
{
margin-top: 10px;
background-color: yellow;
padding: 10px;
}
</style>
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="jquery.tablesorter.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('table.resultSlow').tablesorter({
headers: {
0: {
sorter: 'digit'
},
1: {
sorter: 'text'
},
2: {
sorter: 'text'
},
3: {
sorter: 'digit'
},
4: {
sorter: 'digit'
},
5: {
sorter: 'digit'
},
6: {
sorter: 'digit'
},
7: {
sorter: 'text'
}
},
sortList: [[0, 1]]
});
});
</script>
</head>
<body>
<form action="index.php" method="get">
<table>
<tr>
<td>
<label for="file">
Path to query log file:
</label>
</td>
<td>
<input type="text" name="file" id="file" style="width: 400px;"/>
</td>
</tr>
<tr>
<td>
<label for="name">
Label for analyzed log:
</label>
</td>
<td>
<input type="text" name="name" id="name" style="width: 400px;"/>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="submit" value="Let's go!" />
</td>
</tr>
</table>
</form>
<?php
require dirname(__FILE__).'/lib/renderer.php';
$sphinxRenderer = new sphinxLogRenderer();
// show resultsets
$sphinxRenderer->showAnalyzedLogs();
// load resultset
if (isset($_GET['md5'])) {
$result = unserialize(file_get_contents('logs/'.$_GET['md5'].'.txt'));
if (!empty($result)) {
$sphinxRenderer->showAnalyzedLogContent($result);
}
}
?>
</body>
</html>