Add admin panel system alert chat broadcasts
parent
1c557b7d83
commit
51accc3575
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
if (IN_ADMIN !== true) {
|
||||
die("Error.");
|
||||
}
|
||||
if ($_GET['sub'] == 'system') {
|
||||
require 'pages/chat/system.php';
|
||||
die();
|
||||
} else {
|
||||
require 'pages/chat/log.php';
|
||||
die();
|
||||
}
|
||||
?>
|
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
if (IN_ADMIN !== true) {
|
||||
die("Error.");
|
||||
}
|
||||
|
||||
$update_success = 0;
|
||||
|
||||
|
||||
// Handle updating
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !is_empty($_POST['id'])) {
|
||||
if (!$database->has("messages", ['id' => $_POST['id']])) {
|
||||
$update_success = -1;
|
||||
} else {
|
||||
if ($_POST['action'] == "delete") {
|
||||
$database->delete("messages", ['id' => $_POST['id']]);
|
||||
$update_success = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header">Chat Log <span class="pull-right"><small><?php echo date('h:i:s a'); ?></small></span></h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($update_success == -1) {
|
||||
?>
|
||||
<div class="alert alert-dismissable alert-danger">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<i class="fa fa-times"></i> The message does not exist.
|
||||
</div>
|
||||
<?php
|
||||
} else if ($update_success == 1) {
|
||||
?>
|
||||
<div class="alert alert-dismissable alert-success">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<i class="fa fa-check"></i> Message deleted.
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="chat-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Message</th>
|
||||
<th>Time</th>
|
||||
<th>Location</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
//$msgs = $database->select("messages", "*");
|
||||
$msgs = $database->select('messages', ["[>]players" => ["uuid" => "uuid"]], ['messages.id', 'messages.uuid', 'messages.message', 'messages.time', 'players.nickname', 'messages.lat', 'messages.long'], [
|
||||
"ORDER" => "messages.time ASC",
|
||||
"LIMIT" => 500
|
||||
]);
|
||||
foreach ($msgs as $msg) {
|
||||
$time = date('Y-m-d h:i:s A', strtotime($msg['time']));
|
||||
echo "\n"
|
||||
. " <tr>\n"
|
||||
. " <td>" . (is_null($msg['nickname']) ? "SYSTEM" : $msg['nickname']) . "</td>\n"
|
||||
. " <td>" . $msg['message'] . "</td>\n"
|
||||
. " <td>" . $time . "</td>\n"
|
||||
. " <td>" . ((is_null($msg['lat']) || is_null($msg['long'])) ? "Global" : $msg['lat'] . ', ' . $msg['long']) . "</td>\n"
|
||||
. " <td>\n"
|
||||
. " <form method='POST'>"
|
||||
. " <input type='hidden' name='id' value='" . $msg['id'] . "' />\n"
|
||||
. " <input type='hidden' name='action' value='delete' />\n"
|
||||
. " <button type='submit' class='btn btn-danger' ><i class='fa fa-times'></i> Delete</button>\n"
|
||||
. " </form>\n"
|
||||
. " </td>\n"
|
||||
. " </tr>\n";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script src="js/jquery.dataTables.min.js"></script>
|
||||
<script src="js/dataTables.bootstrap.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#chat-list').dataTable({
|
||||
order: [2, "desc"]
|
||||
});
|
||||
});
|
||||
</script>
|
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
if (IN_ADMIN !== true) {
|
||||
die("Error.");
|
||||
}
|
||||
|
||||
$update_success = 0;
|
||||
|
||||
|
||||
// Handle updating
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !is_empty($_POST['msg'])) {
|
||||
// Validate input
|
||||
if (is_empty($VARS['lat']) || is_empty($VARS['long'])) {
|
||||
$database->insert('messages', ['#time' => 'NOW()', 'message' => $_POST['msg'], 'uuid' => null]);
|
||||
$update_success = 1;
|
||||
} else {
|
||||
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{2,}/', $VARS['lat'])) {
|
||||
$update_success = -1;
|
||||
$update_msg = "Latitude (lat) is in the wrong format.";
|
||||
}
|
||||
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{2,}/', $VARS['lon'])) {
|
||||
$update_success = -1;
|
||||
$update_msg = "Longitude (long) is in the wrong format.";
|
||||
}
|
||||
if ($update_success == 0) {
|
||||
$database->insert('messages', ['#time' => 'NOW()', 'message' => $_POST['msg'], 'lat' => $VARS['lat'], 'long' => $VARS['lon'], 'uuid' => null]);
|
||||
$update_success = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header">Server Alerts <span class="pull-right"><small><?php echo date('h:i:s a'); ?></small></span></h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($update_success == -1) {
|
||||
?>
|
||||
<div class="alert alert-dismissable alert-danger">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<i class="fa fa-times"></i> An error occurred: <?php echo $update_msg; ?>
|
||||
</div>
|
||||
<?php
|
||||
} else if ($update_success == 1) {
|
||||
?>
|
||||
<div class="alert alert-dismissable alert-success">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<i class="fa fa-check"></i> Action Successful.
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="panel panel-default">
|
||||
<form method="POST">
|
||||
<div class="panel-body">
|
||||
<label for="msg">Message</label>
|
||||
<input type="text" name="msg" class="form-control" required="yes" /><br />
|
||||
<label for="lat">Latitude/Longitude (optional, message will be broadcast globally if one or both are empty)</label>
|
||||
<input type="text" name="lat" class="form-control" placeholder="Latitude" /><br />
|
||||
<input type="text" name="lon" class="form-control" placeholder="Longitude" /><br />
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<input type="submit" class="btn btn-primary" value="Send Broadcast"/>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
Reference in New Issue