+<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,
+ 'fixedHeader': {
+ header: true,
+ headerOffset: 53
+ },
+ 'ajax': {
+ 'url': '<?php echo get_config("base_url"); ?>api/server-bans.php',
+ dataSrc: ''
+ },
+ 'columns': [
+ { 'data': 'Select', 'responsivePriority': 1 },
+ { 'data': 'Mask', 'responsivePriority': 2, 'className':'virtuallink' },
+ { 'data': 'Type', 'responsivePriority': 3 },
+ { 'data': 'Duration', 'responsivePriority': 4 },
+ { 'data': 'Reason', 'responsivePriority': 5, 'render': DataTable.render.ellipsis(50, false) },
+ { 'data': 'Set By', 'responsivePriority': 6 },
+ { 'data': 'Set On', 'responsivePriority': 7 },
+ { 'data': 'Expires', 'responsivePriority': 8 },
+ ],
+ 'pageLength':100,
+ 'order':[[1,'asc']],
+ createdRow: function(row) {
+ var td = jQuery(row).find(".truncate");
+ td.each(function(index, el) {
+ jQuery(this).attr("title", jQuery(this).html());
+ });
+ },
+ };
+ /* Only show filter pane on desktop */
+ if (window.innerWidth > 800)
+ {
+ args['dom'] = 'Pfrtip';
+ args['searchPanes'] = {
+ 'initCollapsed': 'true',
+ 'columns': [2,3,5],
+ 'dtOpts': {
+ select: { style: 'multi'},
+ order: [[ 1, "desc" ]]
+ },
+ }
+ }
+
+ data_list_table = $('#data_list').DataTable(args);
+
+ $('#data_list').on( 'click', 'td', function () {
+ edit_ban(this);
+ } );
+} );
+
+ 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_host').val($host.substring(1));
+ $('#ban_soft').prop('checked', true);
+ } else {
+ $('#ban_host').val($host);
+ $('#ban_soft').prop('checked', false);
+ }
+ $type = data['Type'].replace('Soft ','');
+ if ($type == 'Global Z-Line')
+ $type = 'gzline';
+ else if ($type == 'Z-Line')
+ $type = 'zline';
+ else if ($type == 'G-Line')
+ $type = 'gline';
+ else
+ $type = 'kline';
+ $('#ban_type').val($type);
+ if (data['Duration'] == 'permanent')
+ $('#ban_duration').val();
+ else
+ $('#ban_duration').val(data['Duration']);
+ $('#ban_reason').val(data['Reason']);
+ $('#do_del_ban').show();
+ $('#ban_add_title').html("Edit server ban");
+ $('#do_add_ban').html("Modify Ban");
+ $('#edit_existing').val($type+':'+data['Mask']);
+ $('#ban_add').modal('show');
+ }
+
+ // This is in a function because a canceled edit_rpc_server otherwise causes a prefilled effect
+ function add_ban()
+ {
+ $('#edit_existing').val("");
+ $('#ban_host').val("");
+ $('#ban_type').val("");
+ $('#ban_duration').val("");
+ $('#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'; ?>