]>
Commit | Line | Data |
---|---|---|
fe2a6f27 VP |
1 | <?php |
2 | require_once "common.php"; | |
3 | ||
4 | require_once "header.php"; | |
5 | ||
6 | if (!empty($_POST)) | |
7 | { | |
8 | ||
9 | do_log($_POST); | |
10 | ||
e0c259fc | 11 | if (isset($_POST['tklch']) && !empty($_POST['tklch'])) // User has asked to delete these tkls |
fe2a6f27 VP |
12 | { |
13 | foreach ($_POST as $key => $value) { | |
14 | foreach ($value as $tok) { | |
15 | $tok = explode(",", $tok); | |
16 | $ban = base64_decode($tok[0]); | |
17 | $type = base64_decode($tok[1]); | |
c52ccf69 VP |
18 | $success = false; |
19 | if ($type == "except") | |
5057cc4b | 20 | $success = $rpc->serverbanexception()->delete($ban); |
c52ccf69 VP |
21 | else if ($type == "qline" || $type == "local-qline") |
22 | $success = $rpc->nameban()->delete($ban); | |
23 | else | |
24 | $success = $rpc->serverban()->delete($ban, $type); | |
25 | ||
26 | ||
27 | if ($success) | |
fe2a6f27 VP |
28 | Message::Success("$type has been removed for $ban"); |
29 | else | |
30 | Message::Fail("Unable to remove $type on $ban: $rpc->error"); | |
31 | } | |
32 | } | |
33 | } | |
e0c259fc | 34 | elseif (isset($_POST['tkl_add']) && !empty($_POST['tkl_add'])) |
fe2a6f27 | 35 | { |
e0c259fc VP |
36 | if (!($iphost = $_POST['tkl_add'])) |
37 | Message::Fail("No mask was specified"); | |
38 | else if (!($bantype = (isset($_POST['bantype'])) ? $_POST['bantype'] : false)) | |
39 | { | |
40 | Message::Fail("Unable to add Server Ban: No ban type selected"); | |
41 | } else /* It did */{ | |
fe2a6f27 | 42 | |
e0c259fc VP |
43 | if ( |
44 | ( | |
45 | $bantype == "gline" || | |
46 | $bantype == "gzline" || | |
47 | $bantype == "shun" || | |
48 | $bantype == "eline" | |
49 | ) && strpos($iphost, "@") == false | |
50 | ) // doesn't have full mask | |
51 | $iphost = "*@" . $iphost; | |
fe2a6f27 | 52 | |
e0c259fc VP |
53 | $soft = ($_POST['soft']) ? true : false; |
54 | ||
55 | if ($soft) | |
56 | $iphost = "%" . $iphost; | |
57 | /* duplicate code for now [= */ | |
58 | $banlen_w = (isset($_POST['banlen_w'])) ? $_POST['banlen_w'] : NULL; | |
59 | $banlen_d = (isset($_POST['banlen_d'])) ? $_POST['banlen_d'] : NULL; | |
60 | $banlen_h = (isset($_POST['banlen_h'])) ? $_POST['banlen_h'] : NULL; | |
61 | $duration = ""; | |
62 | if (!$banlen_d && !$banlen_h && !$banlen_w) | |
63 | $duration .= "0"; | |
64 | else { | |
65 | if ($banlen_w) | |
66 | $duration .= $banlen_w; | |
67 | if ($banlen_d) | |
68 | $duration .= $banlen_d; | |
69 | if ($banlen_h) | |
70 | $duration .= $banlen_h; | |
71 | } | |
72 | $msg_msg = ($duration == "0" || $duration == "0w0d0h") ? "permanently" : "for " . rpc_convert_duration_string($duration); | |
73 | $reason = (isset($_POST['ban_reason'])) ? $_POST['ban_reason'] : "No reason"; | |
74 | if ($bantype == "qline") { | |
75 | if ($rpc->nameban()->add($iphost, $reason, $duration)) | |
76 | Message::Success("Name Ban set against \"$iphost\": $reason"); | |
77 | else | |
78 | Message::Fail("Name Ban could not be set against \"$iphost\": $rpc->error"); | |
79 | } elseif ($bantype == "except") { | |
80 | if ($rpc->serverbanexception()->add($iphost, "", $duration, $reason)) | |
81 | Message::Success("Exception set for \"$iphost\": $reason"); | |
82 | else | |
83 | Message::Fail("Exception could not be set \"$iphost\": $rpc->error"); | |
84 | } else if ($rpc->serverban()->add($iphost, $bantype, $duration, $reason)) { | |
85 | Message::Success("Host / IP: $iphost has been $bantype" . "d $msg_msg: $reason"); | |
86 | } else | |
87 | Message::Fail("The $bantype against \"$iphost\" could not be added: $rpc->error"); | |
fe2a6f27 | 88 | } |
e0c259fc VP |
89 | } |
90 | elseif (isset($_POST['search_types']) && !empty($_POST['search_types'])) | |
91 | { | |
92 | ||
fe2a6f27 VP |
93 | } |
94 | } | |
95 | ||
96 | $tkl = $rpc->serverban()->getAll(); | |
62d4ea03 VP |
97 | foreach ($rpc->nameban()->getAll() as $v) |
98 | $tkl[] = $v; | |
5057cc4b | 99 | foreach ($rpc->serverbanexception()->getAll() as $v) |
e2b8fb61 | 100 | $tkl[] = $v; |
fe2a6f27 | 101 | ?> |
0d846731 VP |
102 | <h4>Server Bans Overview</h4><br> |
103 | <p><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> | |
104 | Add entry | |
105 | </button></p></table> | |
106 | <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> | |
107 | <div class="modal-dialog modal-dialog-centered" role="document"> | |
108 | <div class="modal-content"> | |
109 | <div class="modal-header"> | |
71ef1a7f | 110 | <h5 class="modal-title" id="myModalLabel">Add new Server Ban</h5> |
0d846731 VP |
111 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
112 | <span aria-hidden="true">×</span> | |
113 | </button> | |
114 | </div> | |
115 | <div class="modal-body"> | |
fe2a6f27 | 116 | |
0c12196e | 117 | <form method="post"> |
0d846731 VP |
118 | <div class="align_label">IP / Host: </div> <input class="curvy" type="text" id="tkl_add" name="tkl_add"><br> |
119 | <div class="align_label">Ban Type: </div> <select class="curvy" name="bantype" id="bantype"> | |
fe2a6f27 VP |
120 | <option value=""></option> |
121 | <optgroup label="Bans"> | |
122 | <option value="kline">Kill Line (KLine)</option> | |
123 | <option value="gline">Global Kill Line (GLine)</option> | |
124 | <option value="zline">Zap Line (ZLine)</option> | |
125 | <option value="gzline">Global Zap Line (GZLine)</option> | |
126 | ||
127 | </optgroup> | |
128 | <optgroup label="Restrictions"> | |
129 | <option value="local-qline">Reserve Nick Locally(QLine)</option> | |
130 | <option value="qline">Reserve Nick Globally (QLine)</option> | |
131 | <option value="shun">Shun</option> | |
132 | ||
133 | </optgroup> | |
134 | <optgroup label="Settings"> | |
135 | <option value="except">Global Exception (ELine)</option> | |
136 | <option value="local-exception">Local Exception (ELine)</option> | |
137 | </optgroup> | |
138 | </select><br> | |
139 | <div class="align_label"><label for="banlen_w">Duration: </label></div> | |
0d846731 | 140 | <select class="curvy" name="banlen_w" id="banlen_w"> |
fe2a6f27 VP |
141 | <?php |
142 | for ($i = 0; $i <= 56; $i++) | |
143 | { | |
144 | if (!$i) | |
145 | echo "<option value=\"0w\"></option>"; | |
146 | else | |
147 | { | |
148 | $w = ($i == 1) ? "week" : "weeks"; | |
149 | echo "<option value=\"$i" . "w\">$i $w" . "</option>"; | |
150 | } | |
151 | } | |
152 | ?> | |
153 | </select> | |
0d846731 | 154 | <select class="curvy" name="banlen_d" id="banlen_d"> |
fe2a6f27 VP |
155 | <?php |
156 | for ($i = 0; $i <= 31; $i++) | |
157 | { | |
158 | if (!$i) | |
159 | echo "<option value=\"0d\"></option>"; | |
160 | else | |
161 | { | |
162 | $d = ($i == 1) ? "day" : "days"; | |
163 | echo "<option value=\"$i" . "d\">$i $d" . "</option>"; | |
164 | } | |
165 | } | |
166 | ?> | |
167 | </select> | |
0d846731 | 168 | <select class="curvy" name="banlen_h" id="banlen_h"> |
fe2a6f27 VP |
169 | <?php |
170 | for ($i = 0; $i <= 24; $i++) | |
171 | { | |
172 | if (!$i) | |
173 | echo "<option value=\"0d\"></option>"; | |
174 | else | |
175 | { | |
176 | $h = ($i == 1) ? "hour" : "hours"; | |
177 | echo "<option value=\"$i" . "h\">$i $h" . "</option>"; | |
178 | } | |
179 | } | |
180 | ?> | |
181 | </select> | |
182 | <br><div class="align_label"><label for="ban_reason">Reason: </label></div> | |
0d846731 VP |
183 | <input class="curvy input_text" type="text" id="ban_reason" name="ban_reason"><br> |
184 | <input class="curvy input_text" type="checkbox" id="soft" name="soft">Don't affect logged-in users (soft) | |
185 | ||
186 | </div> | |
187 | ||
188 | <div class="modal-footer"> | |
189 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
190 | <button type="submit" action="post" class="btn btn-danger">Add Ban</button> | |
191 | </form> | |
192 | </div> | |
193 | </div> | |
fe2a6f27 | 194 | </div> |
0d846731 VP |
195 | </div> |
196 | ||
f41baac8 | 197 | <table class="container-xxl table table-sm table-responsive caption-top table-striped"> |
d1d9caa9 | 198 | <thead class="table-primary"> |
0c12196e | 199 | <form method="post"> |
f41baac8 VP |
200 | <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" /></th> |
201 | <th scope="col">Mask</th> | |
202 | <th scope="col">Type</th> | |
203 | <th scope="col">Duration</th> | |
204 | <th scope="col">Reason</th> | |
205 | <th scope="col">Set By</th> | |
206 | <th scope="col">Set On</th> | |
207 | <th scope="col">Expires</th> | |
0d846731 | 208 | </thead> |
f41baac8 | 209 | <tbody> |
fe2a6f27 VP |
210 | <?php |
211 | foreach($tkl as $tkl) | |
212 | { | |
67e3edd0 | 213 | $set_in_config = ((isset($tkl->set_in_config) && $tkl->set_in_config) || ($tkl->set_by == "-config-")) ? true : false; |
f41baac8 | 214 | echo "<tr scope='col'>"; |
67e3edd0 | 215 | if ($set_in_config) |
f41baac8 | 216 | echo "<td scope=\"col\"></td>"; |
67e3edd0 | 217 | else |
f41baac8 VP |
218 | echo "<td scope=\"col\"><input type=\"checkbox\" value='" . base64_encode($tkl->name).",".base64_encode($tkl->type) . "' name=\"tklch[]\"></td>"; |
219 | echo "<td scope=\"col\">".$tkl->name."</td>"; | |
220 | echo "<td scope=\"col\">".$tkl->type_string."</td>"; | |
221 | echo "<td scope=\"col\">".$tkl->duration_string."</td>"; | |
222 | echo "<td scope=\"col\">".$tkl->reason."</td>"; | |
9307bb12 | 223 | $set_by = $set_in_config ? "<span class=\"badge rounded-pill badge-secondary\">Config</span>" : show_nick_only($tkl->set_by); |
f41baac8 VP |
224 | echo "<td scope=\"col\">".$set_by."</td>"; |
225 | echo "<td scope=\"col\">".$tkl->set_at_string."</td>"; | |
226 | echo "<td scope=\"col\">".$tkl->expire_at_string."</td>"; | |
227 | echo "</tr>"; | |
fe2a6f27 | 228 | } |
f41baac8 | 229 | ?></tbody></table><p><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2"> |
c88945a1 VP |
230 | Delete selected |
231 | </button></p> | |
232 | <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> | |
233 | <div class="modal-dialog modal-dialog-centered" role="document"> | |
234 | <div class="modal-content"> | |
235 | <div class="modal-header"> | |
e3f034ee | 236 | <h5 class="modal-title" id="myModalLabel">Confirm deletion</h5> |
c88945a1 VP |
237 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
238 | <span aria-hidden="true">×</span> | |
239 | </button> | |
240 | </div> | |
241 | <div class="modal-body"> | |
242 | Are you sure you want to do this?<br> | |
243 | This cannot be undone. | |
244 | </div> | |
245 | <div class="modal-footer"> | |
e3f034ee | 246 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> |
c88945a1 VP |
247 | <button type="submit" action="post" class="btn btn-danger">Delete</button> |
248 | ||
249 | </div> | |
250 | </div> | |
251 | </div> | |
252 | </div></form></div></div> | |
fe2a6f27 VP |
253 | |
254 | <?php require_once 'footer.php'; ?> |