2 require_once "../inc/common.php";
3 require_once "../inc/header.php";
7 require_once "../inc/connection.php";
8 if (isset($_POST['tklch']) && !empty($_POST['tklch'])) // User has asked to delete these tkls
10 if (!current_user_can(PERMISSION_SERVER_BAN_DEL
))
12 Message
::Fail("Could not delete: Permission denied");
15 foreach ($_POST['tklch'] as $key => $value) {
16 $tok = explode(",", $value);
17 $ban = base64_decode($tok[0]);
18 $type = base64_decode($tok[1]);
20 if ($type == "except")
21 $success = $rpc->serverbanexception()->delete($ban);
22 else if ($type == "qline" || $type == "local-qline")
23 $success = $rpc->nameban()->delete($ban);
25 $success = $rpc->serverban()->delete($ban, $type);
29 Message
::Success("$type has been removed for $ban");
31 Message::Fail("Unable to remove
$type on
$ban: $rpc->error
");
35 elseif (isset($_POST['tkl_add']) && !empty($_POST['tkl_add']))
37 if (!current_user_can(PERMISSION_SERVER_BAN_ADD))
39 Message::Fail("Could not add
: Permission denied
");
43 if (!($iphost = $_POST['tkl_add']))
44 Message::Fail("No mask was specified
");
45 else if (!($bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : false))
47 Message::Fail("Unable to add Server Ban
: No ban type selected
");
52 $bantype == "gline
" ||
53 $bantype == "gzline
" ||
56 ) && strpos($iphost, "@") == false
57 ) // doesn't have full mask
58 $iphost = "*@" . $iphost;
60 $soft = ($_POST['soft']) ? true : false;
63 $iphost = "%
" . $iphost;
64 /* duplicate code for now [= */
65 $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL;
66 $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL;
67 $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL;
69 if (!$banlen_d && !$banlen_h && !$banlen_w)
73 $duration .= $banlen_w;
75 $duration .= $banlen_d;
77 $duration .= $banlen_h;
79 $msg_msg = ($duration == "0" || $duration == "0w0d0h
") ? "permanently
" : "for " . rpc_convert_duration_string($duration);
80 $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason
";
81 if ($bantype == "qline
") {
82 if ($rpc->nameban()->add($iphost, $reason, $duration))
83 Message::Success("Name Ban set against \"
$iphost\": $reason");
85 Message
::Fail("Name Ban could not be set against \"$iphost\": $rpc->error");
86 } elseif ($bantype == "except") {
87 if ($rpc->serverbanexception()->add($iphost, "", $duration, $reason))
88 Message
::Success("Exception set for \"$iphost\": $reason");
90 Message::Fail("Exception could not be set \"
$iphost\": $rpc->error
");
91 } else if ($rpc->serverban()->add($iphost, $bantype, $duration, $reason)) {
92 Message::Success("Host
/ IP
: $iphost has been
$bantype" . "d $msg_msg: $reason");
94 Message::Fail("The
$bantype against \"
$iphost\" could not be added
: $rpc->error
");
98 elseif (isset($_POST['search_types']) && !empty($_POST['search_types']))
105 <h4>Server Bans Overview</h4>
106 Here are all your network bans, from K-Lines to G-Lines, it's all here.<br><br>
108 <p><button type="button
" class="btn btn
-primary
" data-toggle="modal
" data-target="#myModal" <?php echo (current_user_can(PERMISSION_SERVER_BAN_ADD)) ? "" : "disabled"; ?>>
110 </button
></p
></table
>
111 <div
class="modal fade" id
="myModal" tabindex
="-1" role
="dialog" aria
-labelledby
="confirmModalCenterTitle" aria
-hidden
="true">
112 <div
class="modal-dialog modal-dialog-centered" role
="document">
113 <div
class="modal-content">
114 <div
class="modal-header">
115 <h5
class="modal-title" id
="myModalLabel">Add
new Server Ban
</h5
>
116 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
="Close">
117 <span aria
-hidden
="true">×
;</span
>
120 <div
class="modal-body">
123 <div
class="align_label">IP
/ Host
: </div
> <input
class="curvy" type
="text" id
="tkl_add" name
="tkl_add"><br
>
124 <div
class="align_label">Ban Type
: </div
> <select
class="curvy" name
="bantype" id
="bantype">
125 <option value
=""></option
>
126 <optgroup label
="Bans">
127 <option value
="kline">Kill
Line (KLine
)</option
>
128 <option value
="gline">Global Kill
Line (GLine
)</option
>
129 <option value
="zline">Zap
Line (ZLine
)</option
>
130 <option value
="gzline">Global Zap
Line (GZLine
)</option
>
134 <div
class="align_label"><label
for="banlen_w">Duration
: </label
></div
>
135 <select
class="curvy" name
="banlen_w" id
="banlen_w">
137 for ($i = 0; $i <= 56; $i++
)
140 echo "<option value=\"0w\"></option>";
143 $w = ($i == 1) ? "week" : "weeks";
144 echo "<option value=\"$i" . "w\"
>$i $w" . "</option>";
149 <select
class="curvy" name
="banlen_d" id
="banlen_d">
151 for ($i = 0; $i <= 31; $i++
)
154 echo "<option value=\"0d\"></option>";
157 $d = ($i == 1) ? "day" : "days";
158 echo "<option value=\"$i" . "d\"
>$i $d" . "</option>";
163 <select
class="curvy" name
="banlen_h" id
="banlen_h">
165 for ($i = 0; $i <= 24; $i++
)
168 echo "<option value=\"0d\"></option>";
171 $h = ($i == 1) ? "hour" : "hours";
172 echo "<option value=\"$i" . "h\"
>$i $h" . "</option>";
177 <br
><div
class="align_label"><label
for="ban_reason">Reason
: </label
></div
>
178 <input
class="curvy input_text" type
="text" id
="ban_reason" name
="ban_reason"><br
>
179 <input
class="curvy input_text" type
="checkbox" id
="soft" name
="soft">Don
't affect logged-in users (soft)
183 <div class="modal-footer">
184 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
185 <button type="submit" action="post" class="btn btn-danger">Add Ban</button>
192 <!-- The banlist table -->
194 <!-- only in this file for now for testing -->
195 <link rel="stylesheet" href="<?php echo get_config("base_url"); ?>css/datatables.min.css" />
196 <script src="<?php echo get_config("base_url"); ?>js/datatables.min.js"></script>
197 <script src="<?php echo get_config("base_url"); ?>js/datatables-natural-sort.js"></script>
200 <table id="data_list" class="container-xxl table table-sm table-responsive caption-top table-striped">
201 <thead class="table-primary">
202 <th scope="col"><input type="checkbox" label='selectall
' onClick="toggle_tkl(this)" /></th>
203 <th scope="col">Mask</th>
204 <th scope="col">Type</th>
205 <th scope="col">Duration</th>
206 <th scope="col">Reason</th>
207 <th scope="col">Set By</th>
208 <th scope="col">Set On</th>
209 <th scope="col">Expires</th>
213 <!-- Delete button -->
214 <p><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2" <?php echo (current_user_can(PERMISSION_SERVER_BAN_DEL)) ? "" : "disabled"; ?>>
217 <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
218 <div class="modal-dialog modal-dialog-centered" role="document">
219 <div class="modal-content">
220 <div class="modal-header">
221 <h5 class="modal-title" id="myModalLabel">Confirm deletion</h5>
222 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
223 <span aria-hidden="true">×</span>
226 <div class="modal-body">
227 Are you sure you want to do this?<br>
228 This cannot be undone.
230 <div class="modal-footer">
231 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
232 <button type="submit" action="post" class="btn btn-danger">Delete</button>
237 </div></form></div></div>
240 $(document).ready( function () {
241 $('#data_list').DataTable({
243 'url': '<?php echo get_config("base_url"); ?>api/server-bans.php',
247 {
'data': 'Select' },
250 {
'data': 'Duration' },
251 {
'data': 'Reason' },
252 {
'data': 'Set By' },
253 {
'data': 'Set On' },
254 {
'data': 'Expires' },
257 { targets
: '_all', 'type': 'natural' }
264 <?php
require_once '../inc/footer.php'; ?>