?>
<h4>Server Bans Overview</h4>
Here are all your network bans, from K-Lines to G-Lines, it's all here.<br><br>
-
+Click on an entry to edit it.
<!-- Top add button -->
<p><div class="btn btn-primary" onclick="add_ban()" <?php echo (current_user_can(PERMISSION_SERVER_BAN_ADD)) ? "" : "disabled"; ?>>
Add Ban</div></p></table>
<!-- Add/edit ban -->
<div class="modal fade" id="ban_add" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
- <form method="post">
+ <form id="ban_add_form" method="post">
<input name="edit_existing" type="hidden" id="edit_existing" value="">
<div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body">
<div class="form-group">
- <label for="ban_host">IP / Host</label>
+ <label for="ban_host" id="iphost_label">IP / Host</label>
<input name="ban_host" type="text" class="form-control" id="ban_host" aria-describedby="ban_host_help" value="" required>
<small id="ban_host_help" class="form-text text-muted">IP or host on which the ban is applied.</small>
</div>
<!-- The banlist table -->
<form method="post">
<table id="data_list" class="table-striped display responsive nowrap" style="width:100%">
- <thead>
+ <thead class="table-primary">
<th scope="col"><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" /></th>
<th scope="col">Mask</th>
<th scope="col">Type</th>
</div></form></div></div>
<script>
+let form = document.getElementById("ban_add_form");
+let submitban =document.getElementById("do_add_ban");
+form.addEventListener("submit", (e) => {
+ let bantype = document.getElementById("ban_type");
+ let banhost = document.getElementById("ban_host");
+ if ((bantype.value === "zline" || bantype.value === "gzline") && banhost.value.includes("@"))
+ {
+ e.preventDefault();
+ document.getElementById("iphost_label").innerHTML = `IP / Host <span class="card alert-danger" style="color:red">Value for G/Z-Lines MUST be a host or IP.</span>`;
+ }
+});
+
+let data_list_table = null;
+
$(document).ready( function () {
args = {
'responsive': true,
},
'columns': [
{ 'data': 'Select', 'responsivePriority': 1 },
- { 'data': 'Mask', 'responsivePriority': 2 },
+ { 'data': 'Mask', 'responsivePriority': 2, 'className':'virtuallink' },
{ 'data': 'Type', 'responsivePriority': 3 },
{ 'data': 'Duration', 'responsivePriority': 4 },
{ 'data': 'Reason', 'responsivePriority': 5, 'render': DataTable.render.ellipsis(50, false) },
}
}
- var data_list_table = $('#data_list').DataTable(args);
+ data_list_table = $('#data_list').DataTable(args);
$('#data_list').on( 'click', 'td', function () {
- var data = data_list_table.row(this).data();
- edit_ban(data);
+ edit_ban(this);
} );
} );
- function edit_ban(data)
+ function edit_ban(e)
{
+ /* The first column is the 'Select' column */
+ if (data_list_table.cell(e).index().column == 0)
+ return;
+ /* For all the other columns we try to popup and edit screen */
+ var data = data_list_table.row(e).data();
$host = data['Mask'];
if ($host.startsWith('%'))
{
$('#ban_reason').val("");
$('#ban_soft').prop('checked', false);
$('#do_del_ban').hide();
+ $('#ban_add_title').html("Add server ban");
+ $('#do_add_ban').html("Add Ban");
$('#ban_add').modal('show');
}
-
+
</script>
<?php require_once '../inc/footer.php'; ?>