]>
Commit | Line | Data |
---|---|---|
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 | ||
11 | if (isset($_POST['tklch']) && !empty($_POST['tklch'])) // User has asked to delete these tkls | |
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]); | |
18 | $success = false; | |
19 | if ($type == "except") | |
20 | $success = $rpc->serverbanexception()->delete($ban); | |
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) | |
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 | } | |
34 | elseif (isset($_POST['tkl_add']) && !empty($_POST['tkl_add'])) | |
35 | { | |
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 */{ | |
42 | ||
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; | |
52 | ||
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"); | |
88 | } | |
89 | } | |
90 | elseif (isset($_POST['search_types']) && !empty($_POST['search_types'])) | |
91 | { | |
92 | ||
93 | } | |
94 | } | |
95 | ||
96 | $tkl = $rpc->serverban()->getAll(); | |
97 | ?> | |
98 | <h4>Server Bans Overview</h4> | |
99 | Here are all your network bans, from K-Lines to G-Lines, it's all here.<br><br> | |
100 | <p><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> | |
101 | Add entry | |
102 | </button></p></table> | |
103 | <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> | |
104 | <div class="modal-dialog modal-dialog-centered" role="document"> | |
105 | <div class="modal-content"> | |
106 | <div class="modal-header"> | |
107 | <h5 class="modal-title" id="myModalLabel">Add new Server Ban</h5> | |
108 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
109 | <span aria-hidden="true">×</span> | |
110 | </button> | |
111 | </div> | |
112 | <div class="modal-body"> | |
113 | ||
114 | <form method="post"> | |
115 | <div class="align_label">IP / Host: </div> <input class="curvy" type="text" id="tkl_add" name="tkl_add"><br> | |
116 | <div class="align_label">Ban Type: </div> <select class="curvy" name="bantype" id="bantype"> | |
117 | <option value=""></option> | |
118 | <optgroup label="Bans"> | |
119 | <option value="kline">Kill Line (KLine)</option> | |
120 | <option value="gline">Global Kill Line (GLine)</option> | |
121 | <option value="zline">Zap Line (ZLine)</option> | |
122 | <option value="gzline">Global Zap Line (GZLine)</option> | |
123 | ||
124 | </optgroup> | |
125 | </select><br> | |
126 | <div class="align_label"><label for="banlen_w">Duration: </label></div> | |
127 | <select class="curvy" name="banlen_w" id="banlen_w"> | |
128 | <?php | |
129 | for ($i = 0; $i <= 56; $i++) | |
130 | { | |
131 | if (!$i) | |
132 | echo "<option value=\"0w\"></option>"; | |
133 | else | |
134 | { | |
135 | $w = ($i == 1) ? "week" : "weeks"; | |
136 | echo "<option value=\"$i" . "w\">$i $w" . "</option>"; | |
137 | } | |
138 | } | |
139 | ?> | |
140 | </select> | |
141 | <select class="curvy" name="banlen_d" id="banlen_d"> | |
142 | <?php | |
143 | for ($i = 0; $i <= 31; $i++) | |
144 | { | |
145 | if (!$i) | |
146 | echo "<option value=\"0d\"></option>"; | |
147 | else | |
148 | { | |
149 | $d = ($i == 1) ? "day" : "days"; | |
150 | echo "<option value=\"$i" . "d\">$i $d" . "</option>"; | |
151 | } | |
152 | } | |
153 | ?> | |
154 | </select> | |
155 | <select class="curvy" name="banlen_h" id="banlen_h"> | |
156 | <?php | |
157 | for ($i = 0; $i <= 24; $i++) | |
158 | { | |
159 | if (!$i) | |
160 | echo "<option value=\"0d\"></option>"; | |
161 | else | |
162 | { | |
163 | $h = ($i == 1) ? "hour" : "hours"; | |
164 | echo "<option value=\"$i" . "h\">$i $h" . "</option>"; | |
165 | } | |
166 | } | |
167 | ?> | |
168 | </select> | |
169 | <br><div class="align_label"><label for="ban_reason">Reason: </label></div> | |
170 | <input class="curvy input_text" type="text" id="ban_reason" name="ban_reason"><br> | |
171 | <input class="curvy input_text" type="checkbox" id="soft" name="soft">Don't affect logged-in users (soft) | |
172 | ||
173 | </div> | |
174 | ||
175 | <div class="modal-footer"> | |
176 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
177 | <button type="submit" action="post" class="btn btn-danger">Add Ban</button> | |
178 | </form> | |
179 | </div> | |
180 | </div> | |
181 | </div> | |
182 | </div> | |
183 | ||
184 | <table class="container-xxl table table-sm table-responsive caption-top table-striped"> | |
185 | <thead class="table-primary"> | |
186 | <form method="post"> | |
187 | <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" /></th> | |
188 | <th scope="col">Mask</th> | |
189 | <th scope="col">Type</th> | |
190 | <th scope="col">Duration</th> | |
191 | <th scope="col">Reason</th> | |
192 | <th scope="col">Set By</th> | |
193 | <th scope="col">Set On</th> | |
194 | <th scope="col">Expires</th> | |
195 | </thead> | |
196 | <tbody> | |
197 | <?php | |
198 | foreach($tkl as $tkl) | |
199 | { | |
200 | $set_in_config = ((isset($tkl->set_in_config) && $tkl->set_in_config) || ($tkl->set_by == "-config-")) ? true : false; | |
201 | echo "<tr scope='col'>"; | |
202 | if ($set_in_config) | |
203 | echo "<td scope=\"col\"></td>"; | |
204 | else | |
205 | echo "<td scope=\"col\"><input type=\"checkbox\" value='" . base64_encode($tkl->name).",".base64_encode($tkl->type) . "' name=\"tklch[]\"></td>"; | |
206 | echo "<td scope=\"col\">".$tkl->name."</td>"; | |
207 | echo "<td scope=\"col\">".$tkl->type_string."</td>"; | |
208 | echo "<td scope=\"col\">".$tkl->duration_string."</td>"; | |
209 | echo "<td scope=\"col\">".$tkl->reason."</td>"; | |
210 | $set_by = $set_in_config ? "<span class=\"badge rounded-pill badge-secondary\">Config</span>" : show_nick_only($tkl->set_by); | |
211 | echo "<td scope=\"col\">".$set_by."</td>"; | |
212 | echo "<td scope=\"col\">".$tkl->set_at_string."</td>"; | |
213 | echo "<td scope=\"col\">".$tkl->expire_at_string."</td>"; | |
214 | echo "</tr>"; | |
215 | } | |
216 | ?></tbody></table><p><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2"> | |
217 | Delete selected | |
218 | </button></p> | |
219 | <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true"> | |
220 | <div class="modal-dialog modal-dialog-centered" role="document"> | |
221 | <div class="modal-content"> | |
222 | <div class="modal-header"> | |
223 | <h5 class="modal-title" id="myModalLabel">Confirm deletion</h5> | |
224 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |
225 | <span aria-hidden="true">×</span> | |
226 | </button> | |
227 | </div> | |
228 | <div class="modal-body"> | |
229 | Are you sure you want to do this?<br> | |
230 | This cannot be undone. | |
231 | </div> | |
232 | <div class="modal-footer"> | |
233 | <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> | |
234 | <button type="submit" action="post" class="btn btn-danger">Delete</button> | |
235 | ||
236 | </div> | |
237 | </div> | |
238 | </div> | |
239 | </div></form></div></div> | |
240 | ||
241 | <?php require_once '../footer.php'; ?> |