-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdisplayLogs.php
208 lines (184 loc) · 7.26 KB
/
displayLogs.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
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
<?php
date_default_timezone_set('Europe/London');
$PageTitle = "Display Logs:";
$path = dirname($_SERVER['PHP_SELF']);
include 'includes/header.php';
include 'includes/config.php';
include 'includes/functions.php';
$serverToSearch = "";
$logsToSearch = "";
$searchterm = "";
$limit = 500;
echo '<form method="post" action="displayLogs.php" name="myform">';
echo ' <p style="width:100%;padding-top:5px;padding-bottom:5px">';
echo ' <b>Define Search:</b><br>';
echo ' <select name="server">';
foreach ($ServerList as $ServerToCheck)
{
$ServerDetails = explode("|", $ServerToCheck);
$servername = ucwords($ServerDetails[4]);
echo '<option value="'.$servername.'">'.$servername.'</option>';
}
echo '<option value="" selected="selected">All Servers</option>';
echo ' </select>
<select name="searchtype">
<option value="all">All Logs</option>
<option value="dodgy" selected="selected">Dodgy</option>
<option value="performance">Performance</option>
<option value="traders">Traders</option>
</select>
<select name="limit">
<option value="500" selected="selected">Last 500 Records</option>
<option value="1500">Last 1500 Records</option>
<option value="5000">Last 5000 Records</option>
<option value="10000">Last 10000 Records</option>
</select>
<input type="text" name="searchterm" size=45 id="textfield"></input>
<input type="submit">
<a href="displayLogs.php">Reset Form</a>
</p>
</form>';
if(isset($_POST['limit']))
{
$limit = $_POST['limit'];
}
if(isset($_POST['server']))
{
$serverToSearch = $_POST['server'];
}
if(isset($_POST['searchterm']))
{
$searchterm = strtolower($_POST['searchterm']);
}
if(isset($_POST['searchtype']))
{
$searchtype = $_POST['searchtype'];
if($searchtype == 'dodgy')
{
$logsToSearch = " WHERE (logname LIKE '%DUPE%' OR logname LIKE '%KICK%' OR logname LIKE '%BAN%' OR logname LIKE '%SURVEILLANCE%' OR logname LIKE '%GOD%') AND logentry like '%$searchterm%' ";
}
elseif($searchtype == 'traders')
{
$logsToSearch = " WHERE (logname LIKE '%RECYCLE%' OR logname LIKE '%TRADER%') AND logentry like '%$searchterm%' ";
}
elseif($searchtype == 'performance')
{
$logsToSearch = " WHERE (logname LIKE '%PROCESSREPORTER%' OR logname LIKE '%TRADER%') AND logentry like '%$searchterm%' ";
}
elseif($searchtype == 'all')
{
$logsToSearch = " WHERE logname NOT LIKE '%PROCESSREPORTER%' AND logentry like '%$searchterm%' ";
}
else
{
$logsToSearch = " WHERE logname NOT LIKE '%PROCESSREPORTER%' AND logentry like '%$searchterm%' ";
}
}
else
{
$logsToSearch = " WHERE (logname LIKE '%DUPE%'
OR logname LIKE '%KICK%'
OR logname LIKE '%BAN%'
OR logname LIKE '%SURVEILLANCE%'
OR logname LIKE '%GOD%')
AND logentry like '%$searchterm%'
AND time > now() - INTERVAL 6 HOUR";
}
foreach ($ServerList as $ServerToCheck)
{
$ServerDetails = explode("|", $ServerToCheck);
$dbhost = $ServerDetails[0];
$dbname = $ServerDetails[1];
$dbuser = $ServerDetails[2];
$dbpass = $ServerDetails[3];
$servername = ucwords($ServerDetails[4]);
$dbport = $ServerDetails[5];
$db_local = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport);
if(isset($serverToSearch) && $serverToSearch != '')
{
if(strtolower($servername) == strtolower($serverToSearch))
{
$sql = "SELECT *
FROM infistar_logs
$logsToSearch
ORDER BY time
ASC
LIMIT $limit";
//echo "<hr>$sql<hr>";
$result = mysqli_query($db_local, $sql);
if (mysqli_num_rows($result) > 0)
{
echo "<hr><h2>infiSTAR Logs on the $servername server</h2><hr>";
if(isset($searchterm) && $searchterm != '')
{
echo "Searching for: $searchterm<hr>";
}
echo '<table class="tftable" border="1"">
<tr>
<td style="width:150px;">logname</td>
<td style="width:800px;">logentry</td>
<td style="width:150px;">time</td>
</tr>';
while ($row = mysqli_fetch_object($result))
{
$logname = $row->logname;
$logentry = $row->logentry;
$logentry = wordwrap($logentry,200,"<br>\n",true);
$time = $row->time;
echo '<tr>'
. '<td valign=top style="width:150px;">' . $logname . '</td>'
. '<td valign=top>' . $logentry . '</td>'
. '<td valign=top style="width:150px;">' . $time . '</td>'
. '</tr>';
}
echo "</table>";
}
else
{
echo "<hr><h2>There is no log history</h2><hr>";
}
}
}
else
{
$sql = "SELECT *
FROM infistar_logs
$logsToSearch
ORDER BY time ASC
LIMIT $limit";
//echo "<hr>$sql<hr>";
$result = mysqli_query($db_local, $sql);
if (mysqli_num_rows($result) > 0)
{
echo "<hr><h2>infiSTAR Logs on the $servername server</h2><hr>";
if(isset($searchterm) && $searchterm != '')
{
echo "Searching for: $searchterm<hr>";
}
echo '<table class="tftable" border="1"">
<tr>
<td style="width:150px;">logname</td>
<td style="width:800px;">logentry</td>
<td style="width:150px;">time</td>
</tr>';
while ($row = mysqli_fetch_object($result))
{
$logname = $row->logname;
$logentry = $row->logentry;
$logentry = wordwrap($logentry,200,"<br>\n",true);
$time = $row->time;
echo '<tr>'
. '<td valign=top style="width:150px;">' . $logname . '</td>'
. '<td valign=top>' . $logentry . '</td>'
. '<td valign=top style="width:150px;">' . $time . '</td>'
. '</tr>';
}
echo "</table>";
}
else
{
echo "<hr><h2>There is no log history for $servername yet</h2><hr>";
}
}
}
?>