-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
357 lines (349 loc) · 14 KB
/
admin.php
File metadata and controls
357 lines (349 loc) · 14 KB
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
<?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
*/
if (!defined('INTERNAL'))
die("Don't call me directly!");
if(empty($settings['password']) || $settings['password'] == 'password')
errors('You have not set a password. For your security, it\'s required that you set one.');
else if(isset($_SESSION['failed_attempts']) && $_SESSION['failed_attempts'] > 4) {
die(errors('You have reached the maximum number of attempts. Please try again in 30 minutes.'));
if($_SESSION['failed_attempt'] < time())
unset($_SESSION['failed_attempts']);
} else if(!isset($_SESSION['admin']) && !isset($_POST['password'])) {
?><form action="" method="post" class="well form-inline">
<h3>Admin Control Panel <small>— If you forgot your password please refer to settings.php to change it.</small></h3>
<div class="row">
<div class="col-lg-6">
<?php
if(!empty($errors)){
foreach ($errors as $error) {
echo $error;
}
}
?>
<div class="input-group">
<input type="password" class="form-control" name="password" placeholder="Password">
<span class="input-group-btn">
<button class="btn btn-info" type="submit">Sign In</button>
</span>
</div>
</div>
</div>
</form><?php
} else if(isset($_POST['password']) && !isset($_SESSION['admin'])) {
if(htmlspecialchars_decode($_POST['password'], ENT_QUOTES) != $settings['password']) {
//set how long we want them to have to wait after 5 wrong attempts
$time = 1800; //make them wait 30 mins
if(isset($_SESSION['failed_attempts']))
++$_SESSION['failed_attempts'];
else
$_SESSION['failed_attempts'] = 1;
$_SESSION['failed_attempt'] = time() + $time;
redirect('index.php?action=admin');
} else {
$_SESSION['admin'] = true;
redirect('index.php?action=admin');
}
} else if(isset($_SESSION['admin']) && $_SESSION['admin']) {
?>
<table class="table table-striped table-bordered" id="servers">
<thead>
<tr>
<th>Server Name</th>
<th>Options</th>
</tr>
</thead>
<tbody><?php
if(empty($settings['servers']))
echo '<tr id="noservers"><td colspan="2">No Servers Defined</td></tr>';
else {
$id = array_keys($settings['servers']);
$i = 0;
$count = count($settings['servers']) - 1;
foreach($settings['servers'] as $server) {
echo '
<tr>
<td>'.$server['name'].'</td>
<td>
<a href="#" class="btn btn-danger deleteServer" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-trash"></span></a>';
if($count > 0) {
if($i == 0)
echo '
<a href="#" class="btn reorderServer" data-order="down" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-arrow-down"></span></a>';
else if($i == $count)
echo '
<a href="#" class="btn reorderServer" data-order="up" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-arrow-up"></span></a>';
else {
echo '
<a href="#" class="btn reorderServer" data-order="up" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-arrow-up"></span></a>
<a href="#" class="btn reorderServer" data-order="down" data-serverid="'.$id[$i].'"><span class="glyphicon glyphicon-arrow-down"></span></a>';
}
}
echo '
</td>
</tr>';
++$i;
}
}
?>
</tbody>
<tfoot>
<tr>
<td colspan="2">
<?php
if(!is_writable('settings.php')) {
echo '<a class="btn btn-primary btn-large disabled" href="#addserver" title="Settings file not writable">Add Server</a>';
} else
echo '<a class="btn btn-primary btn-large" href="#addserver" data-toggle="modal">Add Server</a>';
?>
</td>
</tr>
</tfoot>
</table>
<div class="modal fade" id="addserver">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" action="" method="post">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Add Server</h3>
</div>
<div class="modal-body">
<div class="container">
<div class="form-group">
<label class="control-label" for="servername">Server Name:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="servername" id="servername">
</div>
</div>
<div class="form-group">
<label class="control-label" for="host">MySQL Host:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="host" id="host">
</div>
</div>
<div class="form-group">
<label class="control-label" for="database">MySQL Database:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="database" id="database">
</div>
</div>
<div class="form-group">
<label class="control-label" for="username">MySQL Username:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="username" id="usernme">
</div>
</div>
<div class="form-group">
<label class="control-label" for="password">MySQL Password:</label>
<div class="controls">
<input type="password" class="form-control fixedWidth" name="password" id="password">
</div>
</div>
<div class="form-group">
<label class="control-label" for="banstable">Bans Table:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="banstable" id="banstable" value="bm_bans">
</div>
</div>
<div class="form-group">
<label class="control-label" for="recordtable">Bans Record Table:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="recordtable" id="recordtable" value="bm_ban_records">
</div>
</div>
<div class="form-group">
<label class="control-label" for="iptable">IP Bans Table:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="iptable" id="iptable" value="bm_ip_bans">
</div>
</div>
<div class="form-group">
<label class="control-label" for="iprecordtable">IP Record Table:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="iprecordtable" id="iprecordtable" value="bm_ip_records">
</div>
</div>
<div class="form-group">
<label class="control-label" for="mutestable">Mutes Table:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="mutestable" id="mutestable" value="bm_mutes">
</div>
</div>
<div class="form-group">
<label class="control-label" for="mutesrecordtable">Mutes Record Table:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="mutesrecordtable" id="mutesrecordtable" value="bm_mutes_records">
</div>
</div>
<div class="form-group">
<label class="control-label" for="kickstable">Kicks Table:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="kickstable" id="kickstable" value="bm_kicks">
</div>
</div>
<div class="form-group">
<label class="control-label" for="warningstable">Warnings Table:</label>
<div class="controls">
<input type="text" class="form-control required fixedWidth" name="warningstable" id="warningstable" value="bm_warnings">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
<input type="submit" class="btn btn-primary" value="Save" />
</div>
</form>
</div>
</div>
</div>
<br />
<br />
<h3>Homepage Settings <small>You may find more settings in settings.php</small></h3>
<form class="form-horizontal settings" action="" method="post">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Option</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php
if(!is_writable('settings.php')) {
echo '
<tr>
<td colspan="2">settings.php can not be written to</td>
</tr>';
} else {
echo '
<tr>
<td>iFrame Protection (Recommended)</td>
<td><input type="hidden" name="type" value="mainsettings" /><input type="checkbox" name="iframe"'.((isset($settings['iframe_protection']) && $settings['iframe_protection']) || !isset($settings['iframe_protection']) ? ' checked="checked"' : '').' /></td>
</tr>
<tr>
<td>UTF8</td>
<td><input type="checkbox" name="utf8"'.(isset($settings['utf8']) && $settings['utf8'] ? ' checked="checked"' : '').' /></td>
</tr>
<tr>
<td>Footer</td>
<td><input type="text" class="form-control" name="footer" value="'.$settings['footer'].'" /></td>
</tr>
<tr>
<td>Latest Bans</td>
<td><input type="checkbox" name="latestbans"'.((isset($settings['latest_bans']) && $settings['latest_bans']) || !isset($settings['latest_bans']) ? ' checked="checked"' : '').' /></td>
</tr>
<tr>
<td>Latest Mutes</td>
<td><input type="checkbox" name="latestmutes"'.(isset($settings['latest_mutes']) && $settings['latest_mutes'] ? ' checked="checked"' : '').' /></td>
</tr>
<tr>
<td>Latest Warnings</td>
<td><input type="checkbox" name="latestwarnings"'.(isset($settings['latest_warnings']) && $settings['latest_warnings'] ? ' checked="checked"' : '').' /></td>
</tr>
<tr>
<td>HTML Before Buttons</td>
<td><input type="text" class="form-control" name="buttons_before" value="'.(isset($settings['submit_buttons_before_html']) ? $settings['submit_buttons_before_html'] : '').'" /></td>
</tr>
<tr>
<td>HTML After Buttons</td>
<td><input type="text" class="form-control" name="buttons_after" value="'.(isset($settings['submit_buttons_after_html']) ? $settings['submit_buttons_after_html'] : '').'" /></td>
</tr>';
} ?>
</tbody>
<tfoot>
<tr>
<td colspan="2">
<?php
if(!is_writable('settings.php')) {
echo '<input type="submit" class="btn btn-primary btn-large disabled" disabled="disabled" value="Save" />';
} else {
echo '<input type="submit" class="btn btn-primary btn-large" value="Save" />';
} ?>
</td>
</tr>
</tfoot>
</table>
</form>
<br />
<br />
<h3>View Player Settings</h3>
<form class="form-horizontal settings" action="" method="post">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Visible</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<?php
if(!is_writable('settings.php')) {
echo '
<tr>
<td colspan="2">settings.php can not be written to</td>
</tr>';
} else {
echo '
<tr>
<td>Current Ban</td>
<td><input type="hidden" name="type" value="viewplayer" /><input type="checkbox" name="ban"'.((isset($settings['player_current_ban']) && $settings['player_current_ban']) || !isset($settings['player_current_ban']) ? ' checked="checked"' : '').' /></td>
</tr>
<tr>
<td>Current Ban HTML Extra</td>
<td><input type="input" class="form-control" name="banextra"'.(isset($settings['player_current_ban_extra_html']) ? ' value="'.$settings['player_current_ban_extra_html'].'"' : '').' /></td>
</tr>
<tr>
<td>Current Mute</td>
<td><input type="checkbox" name="mute"'.((isset($settings['player_current_mute']) && $settings['player_current_mute']) || !isset($settings['player_current_mute']) ? ' checked="checked"' : '').' /></td>
</tr>
<tr>
<td>Current Mute HTML Extra</td>
<td><input type="input" class="form-control" name="muteextra"'.(isset($settings['player_current_mute_extra_html']) ? ' value="'.$settings['player_current_mute_extra_html'].'"' : '').' /></td>
</tr>
<tr>
<td>Previous Bans</td>
<td><input type="checkbox" name="prevbans"'.((isset($settings['player_previous_bans']) && $settings['player_previous_bans']) || !isset($settings['player_previous_bans']) ? ' checked="checked"' : '').' /></td>
</tr>
<tr>
<td>Previous Mutes</td>
<td><input type="checkbox" name="prevmutes"'.((isset($settings['player_previous_mutes']) && $settings['player_previous_mutes']) || !isset($settings['player_previous_mutes']) ? ' checked="checked"' : '').' /></td>
</tr>
<tr>
<td>Warnings</td>
<td><input type="checkbox" name="warnings"'.((isset($settings['player_warnings']) && $settings['player_warnings']) || !isset($settings['player_warnings']) ? ' checked="checked"' : '').' /></td>
</tr>
<tr>
<td>Kicks</td>
<td><input type="checkbox" name="kicks"'.((isset($settings['player_kicks']) && $settings['player_kicks']) || !isset($settings['player_kicks']) ? ' checked="checked"' : '').' /></td>
</tr>';
} ?>
</tbody>
<tfoot>
<tr>
<td colspan="2">
<?php
if(!is_writable('settings.php')) {
echo '<input type="submit" class="btn btn-primary btn-large disabled" disabled="disabled" value="Save" />';
} else {
echo '<input type="submit" class="btn btn-primary btn-large" value="Save" />';
} ?>
</td>
</tr>
</tfoot>
</table>
</form>
<br />
<br />
<h3>Miscellaneous</h3>
<a href="index.php?action=deletecache&authid=<?php echo sha1($settings['password']); ?>" class="btn btn-primary">Clear Cache</a>
<?php
}
?>