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