-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.php
302 lines (275 loc) · 9.61 KB
/
home.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
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<?php
/* BanManagement © 2012, a web interface for the Bukkit plugin BanManager
by James Mortemore of http://www.frostcast.net
is licenced under a Creative Commons
Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales.
Permissions beyond the scope of this licence
may be available at http://creativecommons.org/licenses/by-nc-sa/2.0/uk/.
Additional licence terms at https://raw.github.com/confuser/Ban-Management/master/banmanagement/licence.txt
*/
function latestBans($server, $serverID) {
// Clear old latest bans cache's
clearCache($serverID.'/latestbans', 300);
clearCache($serverID.'/mysqlTime', 300);
$result = cache("SELECT banned, banned_by, ban_reason, ban_expires_on FROM ".$server['bansTable']." ORDER BY ban_time DESC LIMIT 5", 300, $serverID.'/latestbans', $server);
if(isset($result[0]) && !is_array($result[0]) && !empty($result[0]))
$result = array($result);
$rows = count($result);
if($rows == 0)
echo '<li>None</li>';
else {
$timeDiff = cache('SELECT ('.time().' - UNIX_TIMESTAMP(now()))/3600 AS mysqlTime', 5, $serverID.'/mysqlTime', $server); // Cache it for a few seconds
$mysqlTime = $timeDiff['mysqlTime'];
$mysqlTime = ($mysqlTime > 0) ? floor($mysqlTime) : ceil ($mysqlTime);
$mysqlSecs = ($mysqlTime * 60) * 60;
foreach($result as $r) {
$expires = ($r['ban_expires_on'] + $mysqlSecs)- time();
echo '
<li class="latestban"><a href="index.php?action=viewplayer&player='.$r['banned'].'&server='.$serverID.'"><img src="https://minotar.net/avatar/'.$r['banned'].'/20" alt="'.$r['banned'].'" /> '.$r['banned'].'</a><button class="btn btn-info" rel="popover" data-html="true" data-content="'.$r['ban_reason'].'" data-original-title="'.$r['banned_by'];
if($r['ban_expires_on'] == 0)
echo ' <span class=\'label label-important\'>Never</span>';
else if($expires > 0)
echo ' <span class=\'label label-warning\'>'.secs_to_hmini($expires).'</span>';
else
echo ' <span class=\'label label-success\'>Now</span>';
echo '"><i class="icon-question-sign icon-white"></i></button></li>';
}
}
}
function latestMutes($server, $serverID) {
// Clear old latest mutes cache's
clearCache($serverID.'/latestmutes', 300);
clearCache($serverID.'/mysqlTime', 300);
$result = cache("SELECT muted, muted_by, mute_reason, mute_expires_on FROM ".$server['mutesTable']." ORDER BY mute_time DESC LIMIT 5", 300, $serverID.'/latestmutes', $server);
if(isset($result[0]) && !is_array($result[0]) && !empty($result[0]))
$result = array($result);
$rows = count($result);
if($rows == 0)
echo '<li>None</li>';
else {
$timeDiff = cache('SELECT ('.time().' - UNIX_TIMESTAMP(now()))/3600 AS mysqlTime', 5, $serverID.'/mysqlTime', $server); // Cache it for a few seconds
$mysqlTime = $timeDiff['mysqlTime'];
$mysqlTime = ($mysqlTime > 0) ? floor($mysqlTime) : ceil ($mysqlTime);
$mysqlSecs = ($mysqlTime * 60) * 60;
foreach($result as $r) {
$expires = ($r['mute_expires_on'] + $mysqlSecs)- time();
echo '<li class="latestban"><a href="index.php?action=viewplayer&player='.$r['muted'].'&server='.$serverID.'"><img src="https://minotar.net/avatar/'.$r['muted'].'/20" alt="'.$r['muted'].'" /> '.$r['muted'].'</a><button class="btn btn-info" rel="popover" data-html="true" data-content="'.$r['mute_reason'].'" data-original-title="'.$r['muted_by'];
if($r['mute_expires_on'] == 0)
echo ' <span class=\'label label-important\'>Never</span>';
else if($expires > 0)
echo ' <span class=\'label label-warning\'>'.secs_to_hmini($expires).'</span>';
else
echo ' <span class=\'label label-success\'>Now</span>';
echo '"><i class="icon-question-sign icon-white"></i></button></li>';
}
}
}
function latestWarnings($server, $serverID) {
// Clear old latest warnings cache's
clearCache($serverID.'/latestwarnings', 300);
clearCache($serverID.'/mysqlTime', 300);
$result = cache("SELECT warned, warned_by, warn_reason FROM ".$server['warningsTable']." ORDER BY warn_time DESC LIMIT 5", 300, $serverID.'/latestwarnings', $server);
if(isset($result[0]) && !is_array($result[0]) && !empty($result[0]))
$result = array($result);
$rows = count($result);
if($rows == 0)
echo '<li>None</li>';
else {
$timeDiff = cache('SELECT ('.time().' - UNIX_TIMESTAMP(now()))/3600 AS mysqlTime', 5, $serverID.'/mysqlTime', $server); // Cache it for a few seconds
$mysqlTime = $timeDiff['mysqlTime'];
$mysqlTime = ($mysqlTime > 0) ? floor($mysqlTime) : ceil ($mysqlTime);
$mysqlSecs = ($mysqlTime * 60) * 60;
foreach($result as $r) {
echo '<li class="latestban"><a href="index.php?action=viewplayer&player='.$r['warned'].'&server='.$serverID.'"><img src="https://minotar.net/avatar/'.$r['warned'].'/20" alt="'.$r['warned'].'" /> '.$r['warned'].'</a><button class="btn btn-info" rel="popover" data-html="true" data-content="'.$r['warn_reason'].'" data-original-title="'.$r['warned_by'].'"><i class="icon-question-sign icon-white"></i></button></li>';
}
}
}
?>
<div class="hero-unit">
<h1>Ban Check</h1>
<br />
<form action="index.php" method="get" class="form-horizontal" id="search">
<fieldset>
<div class="control-group">
<!-- <label class="control-label" for="servername">
<div class="btn-group" id="searchtype">
<button class="btn" id="player">Player</button>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li id="ip"><a href="#">IP</a></li>
</ul>
</div>
</label> -->
<div class="input-prepend">
<div class="btn-group">
<button id="player" class="btn dropdown-toggle" data-toggle="dropdown">
Player
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li id="ip"><a href="#">IP</a></li>
</ul>
</div>
<input type="text" name="player" class="span4 required" placeholder="Enter Player Name">
</div>
</div>
<?php
if(!empty($settings['servers']) && count($settings['servers']) > 1) {
echo '
<div class="control-group">
<label class="control-label" for="servername">Server:</label>
<div class="controls">';
$id = array_keys($settings['servers']);
$i = 0;
foreach($settings['servers'] as $server) {
echo '
<label class="radio">
<input type="radio" value="'.$id[$i].'" name="server"'.($i == 0 ? ' checked="checked"' : '').' />
'.$server['name'].'
</label>';
++$i;
}
echo '
</div>
</div>';
} else if(count($settings['servers']) == 1) {
echo '<input type="hidden" value="0" name="server" />';
}
?>
<div class="form-actions">
<input type="submit" class="btn btn-primary" value="Search" />
<input type="hidden" name="action" value="searchplayer" />
<a href="#" class="btn" id="viewall">View All</a>
</div>
</fieldset>
</form>
</div>
<?php
if(count($settings['servers']) > 1) {
if((isset($settings['latest_bans']) && $settings['latest_bans']) || !isset($settings['latest_bans'])) {
?>
<h2>Latest Bans</h2>
<?php
if(!empty($settings['servers'])) {
echo '
<div class="row">';
$id = array_keys($settings['servers']);
$i = 0;
foreach($settings['servers'] as $server) {
echo '
<div class="span4">
<h3>'.$server['name'].'</h3>
<ul class="nav nav-tabs nav-stacked">';
latestBans($server, $i);
echo '
</ul>
</div>';
++$i;
}
echo '
</div>';
} else
echo '<p>None</p>';
}
if((isset($settings['latest_mutes']) && $settings['latest_mutes'])) {
?>
<br />
<h2>Latest Mutes</h2>
<?php
if(!empty($settings['servers'])) {
echo '
<div class="row">';
$id = array_keys($settings['servers']);
$i = 0;
foreach($settings['servers'] as $server) {
echo '
<div class="span4">
<h3>'.$server['name'].'</h3>
<ul class="nav nav-tabs nav-stacked">';
latestMutes($server, $i);
echo '
</ul>
</div>';
++$i;
}
echo '
</div>';
} else
echo '<p>None</p>';
}
if((isset($settings['latest_warnings']) && $settings['latest_warnings'])) {
?>
<br />
<h2>Latest warnings</h2>
<?php
if(!empty($settings['servers'])) {
echo '
<div class="row">';
$id = array_keys($settings['servers']);
$i = 0;
foreach($settings['servers'] as $server) {
echo '
<div class="span4">
<h3>'.$server['name'].'</h3>
<ul class="nav nav-tabs nav-stacked">';
latestWarnings($server, $i);
echo '
</ul>
</div>';
++$i;
}
echo '
</div>';
} else
echo '<p>None</p>';
}
} else if(count($settings['servers']) == 1) {
$display = false;
if((isset($settings['latest_bans']) && $settings['latest_bans']) || !isset($settings['latest_bans']))
$display = true;
if((isset($settings['latest_mutes']) && $settings['latest_mutes']))
$display = true;
if((isset($settings['latest_warnings']) && $settings['latest_warnings']))
$display = true;
if($display) {
$server = $settings['servers'][0];
echo '
<h2>'.$server['name'].'</h2>
<div class="row">';
if((isset($settings['latest_bans']) && $settings['latest_bans']) || !isset($settings['latest_bans'])) {
echo '
<div class="span4">
<h3>Latest Bans</h3>
<ul class="nav nav-tabs nav-stacked">';
latestBans($server, 0);
echo '
</ul>
</div>';
}
if((isset($settings['latest_mutes']) && $settings['latest_mutes'])) {
echo '
<div class="span4">
<h3>Latest Mutes</h3>
<ul class="nav nav-tabs nav-stacked">';
latestMutes($server, 0);
echo '
</ul>
</div>';
}
if((isset($settings['latest_warnings']) && $settings['latest_warnings'])) {
echo '
<div class="span4">
<h3>Latest Warnings</h3>
<ul class="nav nav-tabs nav-stacked">';
latestWarnings($server, 0);
echo '
</ul>
</div>';
}
echo '
</div>';
}
}
?>