2 require_once "../inc/common.php";
3 require_once "../inc/header.php";
4 require_once "../inc/connection.php";
11 if (isset($_POST['tklch']) && !empty($_POST['tklch'])) // User has asked to delete these tkls
13 if (!current_user_can(PERMISSION_NAME_BAN_DEL
))
14 Message
::Fail("Could not delete name ban(s): Permission denied");
16 foreach ($_POST['tklch'] as $key => $value)
18 $tok = base64_decode($value);
20 $success = $rpc->nameban()->delete($tok);
24 Message
::Success("Name Ban has been removed for $tok");
26 Message::Fail("Unable to remove Name Ban on
$tok: $rpc->error
");
29 elseif (isset($_POST['tkl_add']) && !empty($_POST['tkl_add']))
31 if (!current_user_can(PERMISSION_NAME_BAN_ADD))
32 Message::Fail("Could not add name
ban(s
): Permission denied
");
35 if (!($iphost = $_POST['tkl_add']))
36 Message::Fail("No mask was specified
");
38 /* duplicate code for now [= */
39 $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL;
40 $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL;
41 $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL;
43 if (!$banlen_d && !$banlen_h && !$banlen_w)
47 $duration .= $banlen_w;
49 $duration .= $banlen_d;
51 $duration .= $banlen_h;
53 $msg_msg = ($duration == "0" || $duration == "0w0d0h
") ? "permanently
" : "for " . rpc_convert_duration_string($duration);
54 $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason
";
56 if ($rpc->nameban()->add($iphost, $reason, $duration))
57 Message::Success("Name Ban set against \"
$iphost\": $reason");
59 Message
::Fail("Name Ban could not be set against \"$iphost\": $rpc->error");
62 elseif (isset($_POST['search_types']) && !empty($_POST['search_types']))
69 $name_bans = $rpc->nameban()->getAll();
72 <h4
>Name Bans Overview
</h4
>
73 Here you can essentially forbid the
use of a nick
or channel name
. This is useful to reserve services nicks so they cannot be used by normal users
.<br
>
74 You can also forbid the
use of channel names
. This is useful in such cases where an admin might need to close a channel
for reasons relating to their own policy
.<br
>
76 <p
><button type
="button" class="btn btn-primary" data
-toggle
="modal" data
-target
="#myModal" <?php
echo (current_user_can(PERMISSION_NAME_BAN_ADD
)) ? "" : "disabled"; ?>>
79 <div
class="modal fade" id
="myModal" tabindex
="-1" role
="dialog" aria
-labelledby
="confirmModalCenterTitle" aria
-hidden
="true">
80 <div
class="modal-dialog modal-dialog-centered" role
="document">
81 <div
class="modal-content">
82 <div
class="modal-header">
83 <h5
class="modal-title" id
="myModalLabel">Add
new Name Ban
</h5
>
84 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
="Close">
85 <span aria
-hidden
="true">×
;</span
>
88 <div
class="modal-body">
91 <div
class="align_label">Nick
/ Channel
</div
> <input
class="curvy" type
="text" id
="tkl_add" name
="tkl_add"><br
>
93 <div
class="align_label"><label
for="banlen_w">Duration
: </label
></div
>
94 <select
class="curvy" name
="banlen_w" id
="banlen_w">
96 for ($i = 0; $i <= 56; $i++
)
99 echo "<option value=\"0w\"></option>";
102 $w = ($i == 1) ? "week" : "weeks";
103 echo "<option value=\"$i" . "w\"
>$i $w" . "</option>";
108 <select
class="curvy" name
="banlen_d" id
="banlen_d">
110 for ($i = 0; $i <= 31; $i++
)
113 echo "<option value=\"0d\"></option>";
116 $d = ($i == 1) ? "day" : "days";
117 echo "<option value=\"$i" . "d\"
>$i $d" . "</option>";
122 <select
class="curvy" name
="banlen_h" id
="banlen_h">
124 for ($i = 0; $i <= 24; $i++
)
127 echo "<option value=\"0d\"></option>";
130 $h = ($i == 1) ? "hour" : "hours";
131 echo "<option value=\"$i" . "h\"
>$i $h" . "</option>";
136 <br
><div
class="align_label"><label
for="ban_reason">Reason
: </label
></div
>
137 <input
class="curvy input_text" type
="text" id
="ban_reason" name
="ban_reason"><br
>
141 <div
class="modal-footer">
142 <button id
="CloseButton" type
="button" class="btn btn-secondary" data
-dismiss
="modal">Cancel
</button
>
143 <button type
="submit" action
="post" class="btn btn-danger">Add Ban
</button
>
150 <table
class="container-xxl table table-sm table-responsive caption-top table-striped">
151 <thead
class="table-primary">
152 <form method
="post" action
="name-bans.php">
153 <th scope
="col"><input type
="checkbox" label
='selectall' onClick
="toggle_tkl(this)" /></th
>
154 <th scope
="col">Mask
</th
>
155 <th scope
="col">Duration
</th
>
156 <th scope
="col">Reason
</th
>
157 <th scope
="col">Set By
</th
>
158 <th scope
="col">Set On
</th
>
159 <th scope
="col">Expires
</th
>
163 foreach($name_bans as $name_bans)
165 $set_in_config = ((isset($name_bans->set_in_config
) && $name_bans->set_in_config
) || ($name_bans->set_by
== "-config-")) ? true : false;
166 echo "<tr scope='col'>";
168 echo "<td scope=\"col\"></td>";
170 echo "<td scope=\"col\"><input type=\"checkbox\" value='" . base64_encode($name_bans->name
)."' name=\"tklch[]\"></td>";
171 echo "<td scope=\"col\">".$name_bans->name
."</td>";
172 echo "<td scope=\"col\">".$name_bans->duration_string
."</td>";
173 echo "<td scope=\"col\">".$name_bans->reason
."</td>";
174 $set_by = $set_in_config ? "<span class=\"badge rounded-pill badge-secondary\">Config</span>" : show_nick_only($name_bans->set_by
);
175 echo "<td scope=\"col\">".$set_by."</td>";
176 echo "<td scope=\"col\">".$name_bans->set_at_string
."</td>";
177 echo "<td scope=\"col\">".$name_bans->expire_at_string
."</td>";
180 ?></tbody
></table
><p
><button type
="button" class="btn btn-danger" data
-toggle
="modal" data
-target
="#myModal2" <?php
echo (current_user_can(PERMISSION_NAME_BAN_DEL
)) ? "" : "disabled"; ?>>
183 <div
class="modal fade" id
="myModal2" tabindex
="-1" role
="dialog" aria
-labelledby
="confirmModalCenterTitle" aria
-hidden
="true">
184 <div
class="modal-dialog modal-dialog-centered" role
="document">
185 <div
class="modal-content">
186 <div
class="modal-header">
187 <h5
class="modal-title" id
="myModalLabel">Confirm deletion
</h5
>
188 <button type
="button" class="close" data
-dismiss
="modal" aria
-label
="Close">
189 <span aria
-hidden
="true">×
;</span
>
192 <div
class="modal-body">
193 Are you sure you want to
do this
?<br
>
194 This cannot be undone
.
196 <div
class="modal-footer">
197 <button id
="CloseButton" type
="button" class="btn btn-secondary" data
-dismiss
="modal">Cancel
</button
>
198 <button type
="submit" action
="post" class="btn btn-danger">Delete
</button
>
203 </div
></form
></div
></div
>
205 <?php
require_once '../inc/footer.php'; ?>