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