]>
Commit | Line | Data |
---|---|---|
33f512fa | 1 | <?php |
c06c1713 | 2 | require_once "../inc/common.php"; |
c06c1713 | 3 | require_once "../inc/header.php"; |
e38f7458 | 4 | require_once "../inc/connection.php"; |
0b546dde | 5 | require_once "../misc/ban-exceptions-misc.php"; |
54127577 VP |
6 | if (!empty($_POST)) |
7 | { | |
33f512fa | 8 | |
54127577 VP |
9 | do_log($_POST); |
10 | ||
11 | if (isset($_POST['tklch']) && !empty($_POST['tklch'])) // User has asked to delete these tkls | |
12 | { | |
88cae748 VP |
13 | if (!current_user_can(PERMISSION_BAN_EXCEPTION_DEL)) |
14 | Message::Fail("Could not delete ban exception(s): Permission denied"); | |
15 | else | |
16 | foreach ($_POST['tklch'] as $key => $value) | |
17 | { | |
18 | $tok = split($value, ","); | |
19 | $iphost = base64_decode($tok[0]); | |
20 | $success = false; | |
21 | $success = $rpc->serverbanexception()->delete($iphost); | |
54127577 VP |
22 | |
23 | ||
88cae748 VP |
24 | if ($success) |
25 | Message::Success("Ban Exception has been removed for $iphost"); | |
26 | else | |
27 | Message::Fail("Unable to remove Ban Exception on $iphost: $rpc->error"); | |
28 | } | |
54127577 VP |
29 | } |
30 | elseif (isset($_POST['tkl_add']) && !empty($_POST['tkl_add'])) | |
31 | { | |
88cae748 VP |
32 | if (!current_user_can(PERMISSION_BAN_EXCEPTION_ADD)) |
33 | Message::Fail("Could not add ban exception(s): Permission denied"); | |
34 | else | |
35 | { | |
36 | if (!($iphost = $_POST['tkl_add'])) | |
37 | Message::Fail("No mask was specified"); | |
0b546dde | 38 | |
88cae748 VP |
39 | $bantypes = isset($_POST['bantype']) ? $_POST['bantype'] : ""; |
40 | $bantypes_dup = ""; | |
41 | if (!empty($bantypes)) | |
42 | foreach ($bantypes as $bt) | |
43 | $bantypes_dup .= $bt; | |
44 | $bantypes = $bantypes_dup; | |
45 | /* duplicate code for now [= */ | |
46 | $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL; | |
47 | $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL; | |
48 | $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL; | |
49 | $duration = ""; | |
50 | if (!$banlen_d && !$banlen_h && !$banlen_w) | |
51 | $duration .= "0"; | |
52 | else { | |
53 | if ($banlen_w) | |
54 | $duration .= $banlen_w; | |
55 | if ($banlen_d) | |
56 | $duration .= $banlen_d; | |
57 | if ($banlen_h) | |
58 | $duration .= $banlen_h; | |
59 | } | |
60 | $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for " . rpc_convert_duration_string($duration); | |
61 | $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason"; | |
0b546dde | 62 | |
88cae748 VP |
63 | if (isset($_POST['soft'])) |
64 | $iphost = "%$iphost"; | |
65 | if ($rpc->serverbanexception()->add($iphost, $bantypes, $reason, (($user = unreal_get_current_user())) ? $user->username : NULL, $duration)) | |
66 | Message::Success("Ban Exception set against \"$iphost\": $reason"); | |
67 | else | |
68 | Message::Fail("Ban Exception could not be set against \"$iphost\": $rpc->error"); | |
69 | } | |
54127577 VP |
70 | |
71 | } | |
72 | elseif (isset($_POST['search_types']) && !empty($_POST['search_types'])) | |
73 | { | |
74 | ||
75 | } | |
76 | } | |
33f512fa VP |
77 | |
78 | $ban_exceptions = $rpc->serverbanexception()->getAll(); | |
79 | ||
80 | ?> | |
81 | <h4>Ban Exceptions Overview</h4> | |
82 | Here is where you can make an exception to bans, that is, to make it so that the target mask is exempt from the ban types you specify.<br> | |
83 | <br> | |
88cae748 | 84 | <p><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal" <?php echo (current_user_can(PERMISSION_BAN_EXCEPTION_ADD)) ? "" : "disabled"; ?>> |
33f512fa VP |
85 | Add entry |
86 | </button></p></table> | |
87 | <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> | |
0b546dde | 88 | <div class="modal-dialog modal-dialog-centered" role="document"> |
33f512fa VP |
89 | <div class="modal-content"> |
90 | <div class="modal-header"> | |
9e2a2ac0 | 91 | <h5 class="modal-title" id="myModalLabel">Add new Ban Exception</h5> |
33f512fa VP |
92 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
93 | <span aria-hidden="true">×</span> | |
94 | </button> | |
95 | </div> | |
96 | <div class="modal-body"> | |
97 | ||
98 | <form method="post"> | |
9e2a2ac0 | 99 | <div class="align_label">IP / Mask</div> <input class="curvy" type="text" id="tkl_add" name="tkl_add"><br> |
0b546dde | 100 | <div class="align_label">Exception Type: </div> <select multiple name="bantype[]" id="bantype" data-live-search="true"> |
9e2a2ac0 VP |
101 | <option value=""></option> |
102 | ||
103 | <option value="k">Kill Line (KLine)</option> | |
104 | <option value="G">Global Kill Line (GLine)</option> | |
105 | <option value="z">Zap Line (ZLine)</option> | |
106 | <option value="Z">Global Zap Line (GZLine)</option> | |
107 | <option value="Q">Reserve Nick Globally (QLine)</option> | |
108 | <option value="s">Shun</option> | |
109 | <option value="F">Spamfilter</option> | |
110 | <option value="b">Blacklist</option> | |
111 | <option value="c">Connect Flood</option> | |
112 | <option value="d">Handshake Flood</option> | |
113 | <option value="m">Max Per IP</option> | |
114 | <option value="r">Anti-Random</option> | |
115 | <option value="8">Anti-Mixed-UTF8</option> | |
116 | <option value="v">Versions</option> | |
117 | </select><br> | |
33f512fa VP |
118 | <div class="align_label"><label for="banlen_w">Duration: </label></div> |
119 | <select class="curvy" name="banlen_w" id="banlen_w"> | |
120 | <?php | |
121 | for ($i = 0; $i <= 56; $i++) | |
122 | { | |
123 | if (!$i) | |
124 | echo "<option value=\"0w\"></option>"; | |
125 | else | |
126 | { | |
127 | $w = ($i == 1) ? "week" : "weeks"; | |
128 | echo "<option value=\"$i" . "w\">$i $w" . "</option>"; | |
129 | } | |
130 | } | |
131 | ?> | |
132 | </select> | |
133 | <select class="curvy" name="banlen_d" id="banlen_d"> | |
134 | <?php | |
135 | for ($i = 0; $i <= 31; $i++) | |
136 | { | |
137 | if (!$i) | |
138 | echo "<option value=\"0d\"></option>"; | |
139 | else | |
140 | { | |
141 | $d = ($i == 1) ? "day" : "days"; | |
142 | echo "<option value=\"$i" . "d\">$i $d" . "</option>"; | |
143 | } | |
144 | } | |
145 | ?> | |
146 | </select> | |
147 | <select class="curvy" name="banlen_h" id="banlen_h"> | |
148 | <?php | |
149 | for ($i = 0; $i <= 24; $i++) | |
150 | { | |
151 | if (!$i) | |
152 | echo "<option value=\"0d\"></option>"; | |
153 | else | |
154 | { | |
155 | $h = ($i == 1) ? "hour" : "hours"; | |
156 | echo "<option value=\"$i" . "h\">$i $h" . "</option>"; | |
157 | } | |
158 | } | |
159 | ?> | |
160 | </select> | |
161 | <br><div class="align_label"><label for="ban_reason">Reason: </label></div> | |
0b546dde | 162 | <input class="curvy input_text" type="text" id="ban_reason" name="ban_reason"> |
33f512fa VP |
163 | |
164 | </div> | |
165 | ||
166 | <div class="modal-footer"> | |
167 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
0b546dde | 168 | <button type="submit" action="post" class="btn btn-danger">Add Ban Exception</button> |
33f512fa VP |
169 | </form> |
170 | </div> | |
171 | </div> | |
172 | </div> | |
173 | </div> | |
174 | ||
175 | <table class="container-xxl table table-sm table-responsive caption-top table-striped"> | |
176 | <thead class="table-primary"> | |
177 | <form method="post"> | |
178 | <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" /></th> | |
179 | <th scope="col">Mask</th> | |
180 | <th scope="col">Duration</th> | |
0b546dde VP |
181 | <th scope="col">Type</th> |
182 | <th scope="col">Exception Types</th> | |
33f512fa VP |
183 | <th scope="col">Reason</th> |
184 | <th scope="col">Set By</th> | |
185 | <th scope="col">Set On</th> | |
186 | <th scope="col">Expires</th> | |
187 | </thead> | |
188 | <tbody> | |
189 | <?php | |
190 | foreach($ban_exceptions as $ban_exceptions) | |
191 | { | |
192 | $set_in_config = ((isset($ban_exceptions->set_in_config) && $ban_exceptions->set_in_config) || ($ban_exceptions->set_by == "-config-")) ? true : false; | |
193 | echo "<tr scope='col'>"; | |
194 | if ($set_in_config) | |
195 | echo "<td scope=\"col\"></td>"; | |
196 | else | |
197 | echo "<td scope=\"col\"><input type=\"checkbox\" value='" . base64_encode($ban_exceptions->name).",".base64_encode($ban_exceptions->type) . "' name=\"tklch[]\"></td>"; | |
198 | echo "<td scope=\"col\">".$ban_exceptions->name."</td>"; | |
199 | echo "<td scope=\"col\">".$ban_exceptions->duration_string."</td>"; | |
0b546dde VP |
200 | echo "<td scope=\"col\"><span class=\"badge badge-pill badge-primary\">".$ban_exceptions->type."</span></td>"; |
201 | echo "<td scope=\"col\">".convert_exceptiontypes_to_badges($ban_exceptions->exception_types)."</td>"; | |
33f512fa VP |
202 | echo "<td scope=\"col\">".$ban_exceptions->reason."</td>"; |
203 | $set_by = $set_in_config ? "<span class=\"badge rounded-pill badge-secondary\">Config</span>" : show_nick_only($ban_exceptions->set_by); | |
204 | echo "<td scope=\"col\">".$set_by."</td>"; | |
205 | echo "<td scope=\"col\">".$ban_exceptions->set_at_string."</td>"; | |
206 | echo "<td scope=\"col\">".$ban_exceptions->expire_at_string."</td>"; | |
207 | echo "</tr>"; | |
208 | } | |
88cae748 | 209 | ?></tbody></table><p><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2" <?php echo (current_user_can(PERMISSION_BAN_EXCEPTION_DEL)) ? "" : "disabled"; ?>> |
33f512fa VP |
210 | Delete selected |
211 | </button></p> | |
212 | <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> | |
213 | <div class="modal-dialog modal-dialog-centered" role="document"> | |
214 | <div class="modal-content"> | |
215 | <div class="modal-header"> | |
216 | <h5 class="modal-title" id="myModalLabel">Confirm deletion</h5> | |
217 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
218 | <span aria-hidden="true">×</span> | |
219 | </button> | |
220 | </div> | |
221 | <div class="modal-body"> | |
222 | Are you sure you want to do this?<br> | |
223 | This cannot be undone. | |
224 | </div> | |
225 | <div class="modal-footer"> | |
226 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
227 | <button type="submit" action="post" class="btn btn-danger">Delete</button> | |
228 | ||
229 | </div> | |
230 | </div> | |
231 | </div> | |
232 | </div></form></div></div> | |
233 | ||
c06c1713 | 234 | <?php require_once '../inc/footer.php'; ?> |