]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - tkl.php
Add "User Lookup" page with cleaner info
[irc/unrealircd/unrealircd-webpanel.git] / tkl.php
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";
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 elseif ($bantype == "except")
73 {
74 if ($rpc->exception()->add($iphost, "", $duration, $reason))
75 Message::Success("Exception set for \"$iphost\": $reason");
76 else
77 Message::Fail("Exception could not be set \"$iphost\": $rpc->error");
78 }
79 else if ($rpc->serverban()->add($iphost, $bantype, $duration, $reason))
80 {
81 Message::Success("Host / IP: $iphost has been $bantype" . "d $msg_msg: $reason");
82 }
83 else
84 Message::Fail("The $bantype against \"$iphost\" could not be added: $rpc->error");
85 }
86 }
87
88 $tkl = $rpc->serverban()->getAll();
89 foreach ($rpc->exception()->getAll() as $v)
90 $tkl[] = $v;
91 foreach ($rpc->nameban()->getAll() as $v)
92 $tkl[] = $v;
93 ?>
94 <h4>Server Bans Overview</h4><br>
95 <p><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
96 Add entry
97 </button></p></table>
98 <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
99 <div class="modal-dialog modal-dialog-centered" role="document">
100 <div class="modal-content">
101 <div class="modal-header">
102 <h5 class="modal-title" id="myModalLabel">Add new Server Ban</h5>
103 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
104 <span aria-hidden="true">&times;</span>
105 </button>
106 </div>
107 <div class="modal-body">
108
109 <form action="tkl.php" method="post">
110 <div class="align_label">IP / Host: </div> <input class="curvy" type="text" id="tkl_add" name="tkl_add"><br>
111 <div class="align_label">Ban Type: </div> <select class="curvy" name="bantype" id="bantype">
112 <option value=""></option>
113 <optgroup label="Bans">
114 <option value="kline">Kill Line (KLine)</option>
115 <option value="gline">Global Kill Line (GLine)</option>
116 <option value="zline">Zap Line (ZLine)</option>
117 <option value="gzline">Global Zap Line (GZLine)</option>
118
119 </optgroup>
120 <optgroup label="Restrictions">
121 <option value="local-qline">Reserve Nick Locally(QLine)</option>
122 <option value="qline">Reserve Nick Globally (QLine)</option>
123 <option value="shun">Shun</option>
124
125 </optgroup>
126 <optgroup label="Settings">
127 <option value="except">Global Exception (ELine)</option>
128 <option value="local-exception">Local Exception (ELine)</option>
129 </optgroup>
130 </select><br>
131 <div class="align_label"><label for="banlen_w">Duration: </label></div>
132 <select class="curvy" name="banlen_w" id="banlen_w">
133 <?php
134 for ($i = 0; $i <= 56; $i++)
135 {
136 if (!$i)
137 echo "<option value=\"0w\"></option>";
138 else
139 {
140 $w = ($i == 1) ? "week" : "weeks";
141 echo "<option value=\"$i" . "w\">$i $w" . "</option>";
142 }
143 }
144 ?>
145 </select>
146 <select class="curvy" name="banlen_d" id="banlen_d">
147 <?php
148 for ($i = 0; $i <= 31; $i++)
149 {
150 if (!$i)
151 echo "<option value=\"0d\"></option>";
152 else
153 {
154 $d = ($i == 1) ? "day" : "days";
155 echo "<option value=\"$i" . "d\">$i $d" . "</option>";
156 }
157 }
158 ?>
159 </select>
160 <select class="curvy" name="banlen_h" id="banlen_h">
161 <?php
162 for ($i = 0; $i <= 24; $i++)
163 {
164 if (!$i)
165 echo "<option value=\"0d\"></option>";
166 else
167 {
168 $h = ($i == 1) ? "hour" : "hours";
169 echo "<option value=\"$i" . "h\">$i $h" . "</option>";
170 }
171 }
172 ?>
173 </select>
174 <br><div class="align_label"><label for="ban_reason">Reason: </label></div>
175 <input class="curvy input_text" type="text" id="ban_reason" name="ban_reason"><br>
176 <input class="curvy input_text" type="checkbox" id="soft" name="soft">Don't affect logged-in users (soft)
177
178 </div>
179
180 <div class="modal-footer">
181 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
182 <button type="submit" action="post" class="btn btn-danger">Add Ban</button>
183 </form>
184 </div>
185 </div>
186 </div>
187 </div>
188
189 <table class="table table-responsive caption-top table-striped">
190 <thead class="table-primary">
191 <form action="tkl.php" method="post">
192 <th><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" />Select all</th>
193 <th>Mask</th>
194 <th>Type</th>
195 <th>Set By</th>
196 <th>Set On</th>
197 <th>Expires</th>
198 <th>Duration</th>
199 <th>Reason</th>
200 </thead>
201
202 <?php
203 foreach($tkl as $tkl)
204 {
205 echo "<tr>";
206 echo "<td><input type=\"checkbox\" value='" . base64_encode($tkl->name).",".base64_encode($tkl->type) . "' name=\"tklch[]\"></td>";
207 echo "<td>".$tkl->name."</td>";
208 echo "<td>".$tkl->type_string."</td>";
209 $set_by = ($tkl->set_by == "-config-") ? "<span class=\"badge-pill badge-secondary\">Config</span>" : $tkl->set_by;
210 echo "<td>".$set_by."</td>";
211 echo "<td>".$tkl->set_at_string."</td>";
212 echo "<td>".$tkl->expire_at_string."</td>";
213 echo "<td>".$tkl->duration_string."</td>";
214 echo "<td>".$tkl->reason."</td>";
215 }
216 ?></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">&times;</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'; ?>