Skip to content

Commit f43ef83

Browse files
[BIG ONE] New features and minor bugfixes (#631)
* Fix textarea for edit modals Make the textarea only expand vertically to prevent surpassing width of modal * Change class name for edit mute modal * Change class name for edit mute modal * Change class for edit mute modal * Add soft/silent to editban/mute modals * Add soft/silent to editban/mute modals * Add punishments through WebUI Adds the possibility to create punishments in admin session. * Add soft/silent to editban/mute modals and prevent empty reasons Empty reasons are replaced with '(WebUI)' * Add soft/silent to editban/mute modals and prevent empty reasons Empty reasons are replaced with '(WebUI' * Add punishments through WebUI Adds the possibility to create punishments in admin session. * Add punishments through WebUI Adds the possibility to create punishments in admin session. * Add punishments through WebUI Adds the possibility to create punishments in admin session. * Add punishments through WebUI Adds the possibility to create punishments in admin session. * Add punishments through WebUI Adds the possibility to create punishments in admin session. * Add punishments through WebUI Adds the possibility to create punishments in admin session. * Add punishments through WebUI Adds the possibility to create punishments in admin session. * Add punishments through WebUI and set their behaviour Adds as setting to change the behaviour when creating punishments $settings['punish'] = 1; - Sets the punishments in overwrite mode. A currently active punishment would get updated with the new punishment data $settings['punish'] = 2; - Sets the punishments in delete mode. A currently active punishment would get a record created then deleted and finally a new punishment will be created $settings['punish'] = 3; - Sets the punishments in stop mode. If there is a currently active punishment, the process of creating a new one is blocked by a message saying you should wait until the current punishment expires or you remove it before creating a new one * Add Punish mode setting to Admin Panel * Add Punish mode setting to Admin Panel * Add Punish mode setting to Admin Panel and fix a bug Adds punish mode setting to admin panel Bugfix for player_kicks setting
1 parent f13f764 commit f43ef83

14 files changed

Lines changed: 548 additions & 22 deletions

File tree

actions/admin.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,19 @@
325325
<tr>
326326
<td>'.$language['admin']['viewplayer']['kicks'].'</td>
327327
<td><input type="checkbox" name="kicks"'.((isset($settings['player_kicks']) && $settings['player_kicks']) || !isset($settings['player_kicks']) ? ' checked="checked"' : '').' /></td>
328+
</tr>
329+
<tr>
330+
<td>'.$language['admin']['viewplayer']['punish'].'</td>
331+
<td>
332+
<label for="overwrite">Overwrite</label>
333+
<input type="radio" name="punish" id="overwrite" value="1"'.(($settings['punish'] == 1) ? ' checked' : '').'/>
334+
&nbsp
335+
<label for="delete">Delete</label>
336+
<input type="radio" name="punish" id="delete" value="2"'.(($settings['punish'] == 2) ? ' checked' : '').'/>
337+
&nbsp
338+
<label for="stop">Stop</label>
339+
<input type="radio" name="punish" id="stop" value="3"'.(($settings['punish'] == 3) ? ' checked' : '').'/>
340+
</td>
328341
</tr>';
329342
} ?>
330343

actions/viewplayer.php

Lines changed: 149 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,23 @@
4848
<div class="row">
4949
<div class="col-lg-3">
5050
<div class="player_information">
51-
<div><img src="<?php echo str_replace(array('%name%', '%uuid%'), array($_GET['player'], $UUID), $settings['skin']['complete']) ?>" class="skin-complete" alt="<?php echo $_GET['player'];?>"/></div>
51+
<div><img src="<?php echo str_replace(array('%name%', '%uuid%'), array($_GET['player'], $UUID), $settings['skin']['complete']) ?>" class="skin-complete" alt="<?php echo $_GET['player'];?>"/></div><br>
5252
<span id="player_name" title="UUID: <?php echo $UUID;?>"><?php echo $_GET['player'];?></span>
53-
</div>
53+
54+
<?php if ($admin) { ?>
55+
<br>
56+
<center>
57+
<a class="btn btn-danger dropdown-toggle" href="#" data-toggle="dropdown"><i class="glyphicon glyphicon-plus"> <?php echo $language['viewplayer']['punish']['punish'];?></i></a>
58+
<ul class="dropdown-menu punish">
59+
<li><?='<div class="col-lg-6"><a class="btn btn-danger pull-left" title="'.$language['viewplayer']['punish']['ban'].'" href="#addban" data-toggle="modal">'.$language['viewplayer']['punish']['ban'].'</a></div> <div class="col-lg-6"><a class="btn btn-danger pull-right" title="'.$language['viewplayer']['punish']['mute'].'" href="#addmute" data-toggle="modal">'.$language['viewplayer']['punish']['mute'].'</a></div>'; ?></li>
60+
</ul>
61+
</center>
62+
63+
64+
65+
<?php } ?>
66+
67+
</div>
5468
</div>
5569
<div class="col-lg-9" id="player_ban_info">
5670
<h4><?= $language['viewplayer']['current_server']; ?>: <?php echo $server['name']; ?></h4>
@@ -155,6 +169,65 @@
155169
'.$extra.'
156170
</div>';
157171
}
172+
173+
if ($admin) { ?>
174+
<div class="modal fade" id="addban">
175+
<div class="modal-dialog">
176+
<div class="modal-content">
177+
<form class="form-horizontal" action="" method="post">
178+
<div class="modal-header">
179+
<button type="button" class="close" data-dismiss="modal">&times;</button>
180+
<h3><?= $language['viewplayer']['punish']['add_modal-creating_ban']; ?></h3>
181+
</div>
182+
<div class="modal-body">
183+
<div class="control-group">
184+
<label class="control-label" for="yourtime"><?= $language['viewplayer']['punish']['add_modal-your_time']; ?>:</label>
185+
<div class="controls">
186+
<span class="yourtime"></span>
187+
</div>
188+
</div>
189+
<div class="control-group">
190+
<label class="control-label" for="servertime"><?= $language['viewplayer']['punish']['add_modal-server_time']; ?>:</label>
191+
<div class="controls">
192+
<span class="servertime"><?php echo date('d/m/Y H:i:s', time() + $mysqlSecs); ?></span>
193+
</div>
194+
</div>
195+
<div class="control-group">
196+
<label class="control-label" for="bandatetime"><?= $language['viewplayer']['punish']['add_modal-expires_server_time']; ?>:</label>
197+
<div class="controls">
198+
<div class="input-group date datetimepicker">
199+
<span class="input-group-btn">
200+
<button class="btn btn-danger bantype" type="button"><?= $language['viewplayer']['punish']['add_modal-permanent']; ?></button>
201+
</span>
202+
<input type="text" class="form-control required disabled" disabled="disabled" name="expires" data-format="DD/MM/YYYY HH:mm:ss" value="" id="bandatetime" />
203+
<span class="input-group-addon">
204+
<i class="glyphicon glyphicon-calendar"></i>
205+
</span>
206+
</div>
207+
</div>
208+
</div>
209+
<div class="control-group">
210+
<label class="control-label" for="silentban"><?= $language['viewplayer']['punish']['add_modal-silent']; ?>:</label>
211+
<input type="checkbox" name="silent" id="silentban" value="Silent" />
212+
</div>
213+
<label for="banreason"><?= $language['viewplayer']['punish']['add_modal-reason']; ?>:</label>
214+
<textarea id="banreason" name="reason" class="form-control" rows="4" style="resize: vertical;"></textarea>
215+
</div>
216+
<div class="modal-footer">
217+
<a href="#" class="btn" data-dismiss="modal"><?= $language['viewplayer']['punish']['add_modal-close']; ?></a>
218+
<input type="submit" class="btn btn-primary" value="<?= $language['viewplayer']['punish']['add_modal-save']; ?>" />
219+
</div>
220+
<?php if (isset($currentBans['id'])) {
221+
echo '<input type="hidden" name="id" value="'.$currentBans['id'].'" />'; } ?>
222+
<input type="hidden" name="uuid" value="<?php echo $UUID; ?>" />
223+
<input type="hidden" name="server" value="<?php echo $_GET['server']; ?>" />
224+
<input type="hidden" name="expiresTimestamp" value="" />
225+
</form>
226+
</div>
227+
</div>
228+
</div>
229+
<?php }
230+
158231
if($admin && count($currentBans) != 0) {?>
159232
<div class="modal fade" id="editban">
160233
<div class="modal-dialog">
@@ -214,8 +287,12 @@
214287
</div>
215288
</div>
216289
</div>
290+
<div class="control-group">
291+
<label class="control-label" for="silentban"><?= $language['viewplayer']['current_ban']['edit_modal-silent']; ?>:</label>
292+
<input type="checkbox" name="silent" id="silentban" value="Silent" <?php if ($currentBans['silent'] != 0) echo 'checked';?> />
293+
</div>
217294
<label for="banreason"><?= $language['viewplayer']['current_ban']['edit_modal-reason']; ?>:</label>
218-
<textarea id="banreason" name="reason" class="form-control" rows="4"><?php echo $currentBans['reason']; ?></textarea>
295+
<textarea id="banreason" name="reason" class="form-control" rows="4" style="resize: vertical;"><?php echo $currentBans['reason']; ?></textarea>
219296
</div>
220297
<div class="modal-footer">
221298
<a href="#" class="btn" data-dismiss="modal"><?= $language['viewplayer']['current_ban']['edit_modal-close']; ?></a>
@@ -321,6 +398,67 @@
321398
'.$extra.'
322399
</div>';
323400
}
401+
402+
if ($admin) { ?>
403+
<div class="modal fade" id="addmute">
404+
<div class="modal-dialog">
405+
<div class="modal-content">
406+
<form class="form-horizontal" action="" method="post">
407+
<div class="modal-header">
408+
<button type="button" class="close" data-dismiss="modal">&times;</button>
409+
<h3><?= $language['viewplayer']['punish']['add_modal-creating_mute']; ?></h3>
410+
</div>
411+
<div class="modal-body">
412+
<div class="control-group">
413+
<label class="control-label" for="yourtime"><?= $language['viewplayer']['punish']['add_modal-your_time']; ?>:</label>
414+
<div class="controls">
415+
<span class="yourtime"></span>
416+
</div>
417+
</div>
418+
<div class="control-group">
419+
<label class="control-label" for="servertime"><?= $language['viewplayer']['punish']['add_modal-server_time']; ?>:</label>
420+
<div class="controls">
421+
<span class="servertime"><?php echo date('d/m/Y H:i:s', time() + $mysqlSecs); ?></span>
422+
</div>
423+
</div>
424+
<div class="control-group">
425+
<label class="control-label" for="mutedatetime"><?= $language['viewplayer']['punish']['add_modal-expires_server_time']; ?>:</label>
426+
<div class="controls">
427+
<div class="input-group date datetimepicker">
428+
<span class="input-group-btn">
429+
<button class="btn btn-danger mutetype" type="button"><?= $language['viewplayer']['punish']['add_modal-permanent']; ?></button>
430+
</span>
431+
<input type="text" class="form-control required disabled" disabled="disabled" name="expires" data-format="DD/MM/YYYY HH:mm:ss" value="" id="mutedatetime" />
432+
<span class="input-group-addon">
433+
<i class="glyphicon glyphicon-calendar"></i>
434+
</span>
435+
</div>
436+
</div>
437+
</div>
438+
<div class="control-group">
439+
<label class="control-label" for="softmute"><?= $language['viewplayer']['punish']['add_modal-soft']; ?>:</label>
440+
<input type="checkbox" name="soft" id="softmute" value="Soft" />
441+
<label class="control-label" for="silentmute"><?= $language['viewplayer']['punish']['add_modal-silent']; ?>:</label>
442+
<input type="checkbox" name="silent" id="silentmute" value="Silent" />
443+
</div>
444+
<label for="mutereason"><?= $language['viewplayer']['punish']['add_modal-reason']; ?>:</label>
445+
<textarea id="mutereason" name="reason" class="form-control" rows="4" style="resize: vertical;"></textarea>
446+
</div>
447+
<div class="modal-footer">
448+
<a href="#" class="btn" data-dismiss="modal"><?= $language['viewplayer']['punish']['add_modal-close']; ?></a>
449+
<input type="submit" class="btn btn-primary" value="<?= $language['viewplayer']['punish']['add_modal-save']; ?>" />
450+
</div>
451+
<?php if (isset($currentMutes['id'])) {
452+
echo '<input type="hidden" name="id" value="'.$currentMutes['id'].'" />'; } ?>
453+
<input type="hidden" name="uuid" value="<?php echo $UUID; ?>" />
454+
<input type="hidden" name="server" value="<?php echo $_GET['server']; ?>" />
455+
<input type="hidden" name="expiresTimestamp" value="" />
456+
</form>
457+
</div>
458+
</div>
459+
</div>
460+
<?php }
461+
324462
if($admin && count($currentMutes) != 0) {?>
325463

326464
<div class="modal fade" id="editmute">
@@ -351,7 +489,7 @@
351489
<?php
352490
echo '
353491
<span class="input-group-btn">
354-
<button class="btn btn-danger bantype" type="button">';
492+
<button class="btn btn-danger mutetype" type="button">';
355493
if($currentMutes['expires'] == 0)
356494
echo $language['viewplayer']['current_mute']['edit_modal-permanent'];
357495
else
@@ -381,8 +519,14 @@
381519
</div>
382520
</div>
383521
</div>
522+
<div class="control-group">
523+
<label class="control-label" for="softmute"><?= $language['viewplayer']['current_mute']['edit_modal-soft']; ?>:</label>
524+
<input type="checkbox" name="soft" id="softmute" value="Soft" <?php if ($currentMutes['soft'] != 0) echo 'checked';?> />
525+
<label class="control-label" for="silentmute"><?= $language['viewplayer']['current_mute']['edit_modal-silent']; ?>:</label>
526+
<input type="checkbox" name="silent" id="silentmute" value="Silent" <?php if ($currentMutes['silent'] != 0) echo 'checked';?> />
527+
</div>
384528
<label for="mutereason"><?= $language['viewplayer']['current_mute']['edit_modal-reason']; ?>:</label>
385-
<textarea id="mutereason" name="reason" class="form-control" rows="4"><?php echo $currentMutes['reason']; ?></textarea>
529+
<textarea id="mutereason" name="reason" class="form-control" rows="4" style="resize: vertical;"><?php echo $currentMutes['reason']; ?></textarea>
386530
</div>
387531
<div class="modal-footer">
388532
<a href="#" class="btn" data-dismiss="modal"><?= $language['viewplayer']['current_mute']['edit_modal-close']; ?></a>

ajax/addban.php

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?php
2+
3+
if(!isset($_SESSION['admin']) || (isset($_SESSION['admin']) && !$_SESSION['admin']))
4+
die('Hacking attempt');
5+
else if(!isset($_GET['authid']) || (isset($_GET['authid']) && $_GET['authid'] != sha1($settings['password'])))
6+
die('Hacking attempt');
7+
else if(!isset($_POST['server']) || !is_numeric($_POST['server']))
8+
die('Hacking attempt');
9+
else if(!isset($settings['servers'][$_POST['server']]))
10+
die('Hacking attempt');
11+
else if(!isset($_POST['uuid']))
12+
die('Hacking attempt');
13+
else {
14+
15+
// Validate the timestamp
16+
if(isset($_POST['expires'])) {
17+
if(!is_numeric($_POST['expiresTimestamp']))
18+
$error = 'Invalid timestamp data';
19+
else
20+
$timestamp = $_POST['expiresTimestamp'];
21+
}
22+
else
23+
$timestamp = 0;
24+
// Set the reason
25+
if(!empty($_POST['reason']))
26+
$reason = $_POST['reason'].' (WebUI)';
27+
else
28+
$reason = '(WebUI)';
29+
30+
if(isset($_POST['silent']))
31+
$silent = 1;
32+
else
33+
$silent = 0;
34+
35+
if(!isset($error)) {
36+
// Get the server details
37+
$server = $settings['servers'][$_POST['server']];
38+
$consoleId = str_replace('-', '', $server['consoleId']);
39+
40+
$mysqlicon = connect($server);
41+
42+
if(!$mysqlicon)
43+
$error = 'Unable to connect to database';
44+
else {
45+
switch ($settings['punish']) {
46+
// Overwrite
47+
case 1:
48+
if (isset($_POST['id']) && is_numeric($_POST['id'])) {
49+
50+
$currentBan = mysqli_query($mysqlicon, "SELECT id FROM ".$server['playerBansTable']." WHERE id = '".$_POST['id']."'");
51+
52+
if(mysqli_num_rows($currentBan) != 0)
53+
54+
// Update old
55+
mysqli_query($mysqlicon, "UPDATE ".$server['playerBansTable']." SET actor_id = UNHEX('$consoleId'), reason = '$reason', updated = UNIX_TIMESTAMP(now()), expires = '$timestamp', silent = '$silent' WHERE id = '".$_POST['id']."'");
56+
}
57+
else
58+
// Or create new
59+
mysqli_query($mysqlicon, "INSERT INTO ".$server['playerBansTable']." (player_id, actor_id, reason, created, updated, expires, silent) VALUES (UNHEX('".$_POST['uuid']."'), UNHEX('$consoleId'), '$reason', UNIX_TIMESTAMP(now()), UNIX_TIMESTAMP(now()), '$timestamp', '$silent')");
60+
break;
61+
62+
// Delete
63+
case 2:
64+
if (isset($_POST['id']) && is_numeric($_POST['id'])) {
65+
66+
$currentBan = mysqli_query($mysqlicon, "SELECT id FROM ".$server['playerBansTable']." WHERE id = '".$_POST['id']."'");
67+
68+
if(mysqli_num_rows($currentBan) != 0) {
69+
70+
// Create record
71+
mysqli_query($mysqlicon, "INSERT INTO ".$server['playerBanRecordsTable']." (player_id, reason, expired, actor_id, pastActor_id, pastCreated, created, createdReason, silent) SELECT b.player_id, b.reason, b.expires, UNHEX('$consoleId'), b.actor_id, b.created, UNIX_TIMESTAMP(now()), 'WebUI', b.silent FROM ".$server['playerBansTable']." AS b WHERE b.id = '".$_POST['id']."'");
72+
// Delete it
73+
mysqli_query($mysqlicon, "DELETE FROM ".$server['playerBansTable']." WHERE id = '".$_POST['id']."'");
74+
// Now punish
75+
mysqli_query($mysqlicon, "INSERT INTO ".$server['playerBansTable']." (player_id, actor_id, reason, created, updated, expires, silent) VALUES (UNHEX('".$_POST['uuid']."'), UNHEX('$consoleId'), '$reason', UNIX_TIMESTAMP(now()), UNIX_TIMESTAMP(now()), '$timestamp', '$silent')");
76+
}
77+
}
78+
else
79+
// Or punish
80+
mysqli_query($mysqlicon, "INSERT INTO ".$server['playerBansTable']." (player_id, actor_id, reason, created, updated, expires, silent) VALUES (UNHEX('".$_POST['uuid']."'), UNHEX('$consoleId'), '$reason', UNIX_TIMESTAMP(now()), UNIX_TIMESTAMP(now()), '$timestamp', '$silent')");
81+
break;
82+
83+
// Stop
84+
case 3:
85+
if (isset($_POST['id']) && is_numeric($_POST['id'])) {
86+
87+
$currentBan = mysqli_query($mysqlicon, "SELECT id FROM ".$server['playerBansTable']." WHERE id = '".$_POST['id']."'");
88+
89+
if(mysqli_num_rows($currentBan) != 0)
90+
91+
// Throw error
92+
$error = 'There is already an active punishment of this type. Wait for it to expire or remove it before trying to add a new one!';
93+
else
94+
// Or punish
95+
mysqli_query($mysqlicon, "INSERT INTO ".$server['playerBansTable']." (player_id, actor_id, reason, created, updated, expires, silent) VALUES (UNHEX('".$_POST['uuid']."'), UNHEX('$consoleId'), '$reason', UNIX_TIMESTAMP(now()), UNIX_TIMESTAMP(now()), '$timestamp', '$silent')");
96+
}
97+
break;
98+
99+
default:
100+
$error = 'Something went wrong. Check the value of $settings[\'punish\'] in settings.php';
101+
break;
102+
}
103+
104+
// Clear the cache
105+
clearCache($_POST['server'].'/players');
106+
107+
$array['success'] = 'true';
108+
}
109+
}
110+
}
111+
mysqli_close($mysqlicon);
112+
113+
if(isset($error))
114+
$array['error'] = $error;
115+
echo json_encode($array);
116+
?>

0 commit comments

Comments
 (0)