]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - channels/details.php
115d24289797b71bcf4afd44f32eb74c72b1a186
[irc/unrealircd/unrealircd-webpanel.git] / channels / details.php
1 <?php
2 require_once "../common.php";
3 require_once "../header.php";
4 require_once "../misc/channel-lookup-misc.php";
5
6 $title = "Channel Lookup";
7 $channel = "";
8 $channame = "";
9 $nick = NULL;
10 $channelObj = NULL;
11 do_log($_GET);
12 do_log($_POST);
13 if (isset($_GET['chan']))
14 {
15 $channel = $_GET['chan'];
16 $channelObj = $rpc->channel()->get($channel, 4);
17 if (!$channelObj && strlen($channel))
18 {
19 Message::Fail("Could not find channel: \"$channel\"");
20 } elseif (strlen($channel)) {
21
22 $channame = $channelObj->name;
23 $title .= " for \"" . $channame . "\"";
24 do_log($channelObj);
25 }
26 }
27 $topicset = false;
28 $del_ex = false;
29 $del_inv = false;
30 $del_ban = false;
31 $checkboxes = [];
32
33 $chanban_errors = [];
34 if (!empty($_POST))
35 {
36 if (isset($_POST['update_topic']) && isset($_POST['set_topic']))
37 {
38 if (isset($channelObj))
39 {
40 if (!isset($channelObj->topic) || strcmp($channelObj->topic,$_POST['set_topic'])) // if the set topic is different
41 {
42 $user = (function_exists('unreal_get_current_user') && $u = unreal_get_current_user()) ? $u->username : NULL;
43 $topicset = $rpc->channel()->set_topic($channelObj->name, $_POST['set_topic'], $user);
44 $channelObj->topic = $_POST['set_topic'];
45 }
46 }
47 }
48 $checkboxes = (isset($_POST['ban_checkboxes'])) ? $_POST['ban_checkboxes'] : [];
49 if (isset($_POST['delete_sel_ex']))
50 {
51 foreach($_POST['ce_checkboxes'] as $c)
52 $checkboxes[] = $c;
53 do_delete_chanex($channelObj, $checkboxes);
54 }
55 if (isset($_POST['delete_sel_inv']))
56 {
57 foreach($_POST['ci_checkboxes'] as $c)
58 $checkboxes[] = $c;
59 do_delete_invite($channelObj, $checkboxes);
60 }
61 else if (isset($_POST['delete_sel_ban']))
62 {
63 foreach($_POST['cb_checkboxes'] as $c)
64 $checkboxes[] = $c;
65 do_delete_chanban($channelObj, $checkboxes);
66 }
67 if (isset($_POST['add_chban']) || isset($_POST['add_chinv']) || isset($_POST['add_chex']))
68 {
69
70 if (isset($_POST['add_chban']))
71 $mode = $_POST['add_chban'];
72 else
73 $mode = (isset($_POST['add_chinv'])) ? $_POST['add_chinv'] : $_POST['add_chex'];
74
75 $nick = (strlen($_POST['ban_nick'])) ? $_POST['ban_nick'] : false;
76 $action_string = (isset($_POST['bantype_sel_action']) && strlen($_POST['bantype_sel_action'])) ? $_POST['bantype_sel_action'] : false;
77 $action = "";
78 $type_string = (strlen($_POST['bantype_sel_type'])) ? $_POST['bantype_sel_type'] : false;
79 $type = "";
80 $expiry = (strlen($_POST['bantype_sel_ex'])) ? $_POST['bantype_sel_ex'] : false;
81 $time = "";
82
83 if (!$nick)
84 $chanban_errors[] = "You did not specify a nick/mask";
85
86 if ($action_string)
87 {
88 if (strstr($action_string,"Quiet"))
89 $action = "~quiet:";
90 elseif (strstr($action_string,"Nick-change"))
91 $action = "~nickchange:";
92 elseif (strstr($action_string,"Join"))
93 $action = "~join:";
94 }
95 if ($type_string)
96 {
97 if (strstr($type_string,"Account"))
98 $type = "~account:";
99 elseif (strstr($type_string,"Channel"))
100 $type = "~channel:";
101 elseif (strstr($type_string,"Country"))
102 $type = "~country:";
103 elseif (strstr($type_string,"OperClass"))
104 $type = "~operclass:";
105 elseif (strstr($type_string,"GECOS"))
106 $type = "~realname:";
107 elseif (strstr($type_string,"Security"))
108 $type = "~security-group:";
109 elseif (strstr($type_string,"Certificate"))
110 $type = "~certfp:";
111 }
112 if ($expiry)
113 {
114 $future = strtotime($expiry);
115 $now = strtotime(date("Y-m-d h:i:s"));
116 $ts = ($future - $now) / 60;
117 $ts = (int)$ts;
118 $time = "~time:$ts:";
119 if ($ts > 9999 || $ts < 1)
120 $chanban_errors[] = "Cannot set expiry more than ".(9999 / 60)." hours (".(9999 / 1440)." days) in the future, or in the past";
121 }
122 if (empty($chanban_errors))
123 if ($rpc->channel()->set_mode($channel, "$mode", "$time$action$type$nick"))
124 Message::Success("The mode was set successfully: $mode $time$action$type$nick");
125
126 else
127 foreach($chanban_errors as $err)
128 Message::Fail($err);
129 }
130 if ((isset($_POST['kickban']) || isset($_POST['muteban'])) && current_user_can(PERMISSION_EDIT_CHANNEL_USER))
131 {
132 $mute = (isset($_POST['muteban'])) ? true : false;
133 $mutestr = ($mute) ? "~quiet:" : "";
134 $user = (!$mute) ? $_POST['kickban'] : $_POST['muteban'];
135
136 $kbuser = $rpc->user()->get($user);
137
138 if (!$kbuser)
139 Message::Fail("Could not kickban user: User does not exist");
140 else
141 {
142 $rpc->channel()->set_mode($channelObj->name, "+b", "~time:".DEFAULT_CHAN_DETAIL_QUICK_ACTION_TIME.":".$mutestr."*!*@".$kbuser->user->cloakedhost);
143 if (!$mute)
144 $rpc->channel()->kick($channelObj->name, $kbuser->name, DEFAULT_CHAN_DETAIL_QUICK_BAN_REASON);
145
146 $msgbox_str = ($mute)
147 ?
148 "User \"$kbuser->name\" has been muted for ".DEFAULT_CHAN_DETAIL_QUICK_ACTION_TIME." minutes."
149 :
150 "User \"$kbuser->name\" has been banned for ".DEFAULT_CHAN_DETAIL_QUICK_ACTION_TIME." minutes."
151 ;
152 Message::Success($msgbox_str);
153 }
154 }
155 /* Re-grab the channel because of updates */
156 $channelObj = $rpc->channel()->get($channel, 4);
157 }
158
159 ?>
160 <title><?php echo $title; ?></title>
161 <h6><?php echo $title; ?></h6>
162 <br>
163
164
165 <div class="container-xl">
166 <form method="get" action="details.php">
167 <div class="text-left input-group">
168 <input class="form-control" id="chan" name="chan" type="text" value="<?php echo $channame; ?>">
169 <div class="input-group-append">
170 <button type="submit" class="btn btn-primary">Go</button>
171 </div>
172 </div>
173 </div>
174 </form>
175 <?php if (!$channelObj)
176 return; ?>
177
178 <!-- Modal for Add Ban -->
179 <div class="modal fade" id="ban" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
180 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
181 <div class="modal-content">
182 <div class="modal-header">
183 <h5 class="modal-title" id="myModalLabel">Add New Channel Ban</h5>
184 <div type="button" class="close" data-dismiss="modal" aria-label="Close">
185 <span aria-hidden="true">&times;</span>
186 </div>
187 </div>
188 <div class="modal-body">
189 <form method="post">
190 <div class="input-group mb-3">
191 <label for="ban_nick">Mask
192 <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
193 title="The mask or other value. For example if you are matching a country in 'Ban Type' then you would put the country code as this value. Click to view more information on Extended Bans"
194 ></i></a>
195 <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
196 placeholder="nick!user@host or something else"
197 ></label>
198
199 </div>
200 <div class="input-group mb-3">
201 <label for="bantype_action">Ban Action
202 <select class="form-control" name="bantype_sel_action" id="bantype_sel">
203 <option></option>
204 <option>Quiet (Mute)</option>
205 <option>Nick-change</option>
206 <option>Join</option>
207 </select>
208 </label>
209 </div>
210 <div class="input-group mb-3">
211 <label for="bantype_sel_type">Ban Type
212 <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
213 <option></option>
214 <option>Match Account</option>
215 <option>Match Channel</option>
216 <option>Match Country</option>
217 <option>Match OperClass</option>
218 <option>Match RealName / GECOS</option>
219 <option>Match Security Group</option>
220 <option>Match Certificate Fingerprint</option>
221 </select>
222 </label>
223 </div>
224 <div class="input-group mb-3">
225 <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
226 <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
227 </label>
228 </div>
229 </div>
230 <div class="modal-footer">
231 <input type="hidden" id="server" name="add_chban" value="b"></input>
232 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
233 <button type="submit" action="post" class="btn btn-danger">Add Channel Ban</button>
234 </form>
235 </div>
236 </div>
237 </div>
238 </div>
239
240
241 <!-- Modal for Add Invite -->
242 <div class="modal fade" id="invite" tabindex="-1" role="dialog" aria-labelledby="add_invite_modal" aria-hidden="true">
243 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
244 <div class="modal-content">
245 <div class="modal-header">
246 <h5 class="modal-title" id="add_invite_modal">Add New Channel Invite</h5>
247 <div type="button" class="close" data-dismiss="modal" aria-label="Close">
248 <span aria-hidden="true">&times;</span>
249 </div>
250 </div>
251 <div class="modal-body">
252 <form method="post">
253 <div class="input-group mb-3">
254 <label for="ban_nick">Mask
255 <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
256 title="The mask or other value. For example if you are matching a country in 'Invite Type' then you would put the country code as this value. Click to view more information on Extended Bans"
257 ></i></a>
258 <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
259 placeholder="nick!user@host or something else"
260 ></label>
261
262 </div>
263 <div class="input-group mb-3">
264 <label for="bantype_sel_type">Invite Type
265 <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
266 <option></option>
267 <option>Match Account</option>
268 <option>Match Channel</option>
269 <option>Match Country</option>
270 <option>Match OperClass</option>
271 <option>Match RealName / GECOS</option>
272 <option>Match Security Group</option>
273 <option>Match Certificate Fingerprint</option>
274 </select>
275 </label>
276 </div>
277 <div class="input-group mb-3">
278 <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
279 <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
280 </label>
281 </div>
282 </div>
283 <div class="modal-footer">
284 <input type="hidden" name="add_chinv" value="I"></input>
285 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
286 <button type="submit" action="post" class="btn btn-danger">Add Invite</button>
287 </form>
288 </div>
289 </div>
290 </div>
291 </div>
292
293 <!-- Modal for Add Ban Exceptions -->
294 <div class="modal fade" id="except" tabindex="-1" role="dialog" aria-labelledby="add_except_modal" aria-hidden="true">
295 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
296 <div class="modal-content">
297 <div class="modal-header">
298 <h5 class="modal-title" id="add_except_modal">Add New Channel Ban Exception</h5>
299 <div type="button" class="close" data-dismiss="modal" aria-label="Close">
300 <span aria-hidden="true">&times;</span>
301 </div>
302 </div>
303 <div class="modal-body">
304 <form method="post">
305 <div class="input-group mb-3">
306 <label for="ban_nick">Mask
307 <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
308 title="The mask or other value. For example if you are matching a country in 'Ban Type' then you would put the country code as this value. Click to view more information on Extended Bans"
309 ></i></a>
310 <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
311 placeholder="nick!user@host or something else"
312 ></label>
313
314 </div>
315 <div class="input-group mb-3">
316 <label for="bantype_sel_type">Ban Type
317 <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
318 <option></option>
319 <option>Match Account</option>
320 <option>Match Channel</option>
321 <option>Match Country</option>
322 <option>Match OperClass</option>
323 <option>Match RealName / GECOS</option>
324 <option>Match Security Group</option>
325 <option>Match Certificate Fingerprint</option>
326 </select>
327 </label>
328 </div>
329 <div class="input-group mb-3">
330 <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
331 <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
332 </label>
333 </div>
334 </div>
335 <div class="modal-footer">
336 <input type="hidden" id="server" name="add_chex" value="e"></input>
337 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
338 <button type="submit" action="post" class="btn btn-danger">Add Exception</button>
339 </form>
340 </div>
341 </div>
342 </div>
343 </div>
344
345 <br>
346 <h6>
347 Topic:<br></h6>
348 <form method="post" action="details.php?chan=<?php echo urlencode($channelObj->name); ?>">
349 <div class="input-group">
350 <input maxlength="360" type="text" class="input-group form-control" name="set_topic" value="<?php echo (isset($channelObj->topic)) ? htmlspecialchars($channelObj->topic) : ""; ?>">
351 <div class="input-group-append"><button type="submit" name="update_topic" value="true" class="btn btn-info">Update Topic</button></div></div>
352 </form>
353 <?php
354 if ($topicset)
355 Message::Success("The topic for $channelObj->name has been updated to be: \"".htmlspecialchars($channelObj->topic)."\"");
356 ?>
357 <br>
358
359 <!-- Modal for User Action -->
360 <div class="modal fade" id="useraction" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
361 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
362 <div class="modal-content">
363 <div class="modal-header">
364 <h5 class="modal-title" id="myModalLabel">Add New Channel Ban</h5>
365 <div type="button" class="close" data-dismiss="modal" aria-label="Close">
366 <span aria-hidden="true">&times;</span>
367 </div>
368 </div>
369 <div class="modal-body">
370 <form method="post">
371 <div class="input-group mb-3">
372 <label for="ban_nick">Mask
373 <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
374 title="The mask or other value. For example if you are matching a country in 'Ban Type' then you would put the country code as this value. Click to view more information on Extended Bans"
375 ></i></a>
376 <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
377 placeholder="nick!user@host or something else"
378 ></label>
379
380 </div>
381 <div class="input-group mb-3">
382 <label for="bantype_action">Ban Action
383 <select class="form-control" name="bantype_sel_action" id="bantype_sel">
384 <option></option>
385 <option>Quiet (Mute)</option>
386 <option>Nick-change</option>
387 <option>Join</option>
388 </select>
389 </label>
390 </div>
391 <div class="input-group mb-3">
392 <label for="bantype_sel_type">Ban Type
393 <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
394 <option></option>
395 <option>Match Account</option>
396 <option>Match Channel</option>
397 <option>Match Country</option>
398 <option>Match OperClass</option>
399 <option>Match RealName / GECOS</option>
400 <option>Match Security Group</option>
401 <option>Match Certificate Fingerprint</option>
402 </select>
403 </label>
404 </div>
405 <div class="input-group mb-3">
406 <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
407 <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
408 </label>
409 </div>
410 </div>
411 <div class="modal-footer">
412 <input type="hidden" id="server" name="add_chban" value="b"></input>
413 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
414 <button type="submit" action="post" class="btn btn-danger">Add Channel Ban</button>
415 </form>
416 </div>
417 </div>
418 </div>
419 </div>
420
421 <div class="container-xxl">
422 <div class="row">
423 <div class="col-sm-4">
424 <div class="card">
425 <div class="card-body">
426 <h6 class="card-title">User List</h6>
427 <p class="card-text"><?php generate_chan_occupants_table($channelObj); ?></p>
428 </div>
429 </div>
430 </div>
431 <div class="col-sm-8">
432 <div class="card">
433 <div class="card-body">
434 <h6 class="card-title">Channel Settings</h6>
435 <ul class="nav nav-tabs" role="tablist">
436 <li class="nav-item" role="presentation"><a class="nav-link" href="#chanmodes" aria-controls="chanmodes" role="tab" data-toggle="tab">Settings / Modes</a></li>
437 <li class="nav-item" role="presentation"><a class="nav-link" href="#chanbans" aria-controls="chanbans" role="tab" data-toggle="tab">Bans</a></li>
438 <li class="nav-item" role="presentation"><a class="nav-link" href="#chaninv" aria-controls="chaninv" role="tab" data-toggle="tab">Invites</a></li>
439 <li class="nav-item" role="presentation"><a class="nav-link" href="#chanex" aria-controls="chanex" role="tab" data-toggle="tab">Excepts</a></li>
440 </ul>
441
442 <div class="tab-content">
443
444 <div role="tabpanel" class="tab-pane fade in" id="chanmodes">
445 <p class="card-text"><?php generate_html_chansettings($channelObj); ?></p>
446 </div>
447
448 <div role="tabpanel" class="tab-pane fade in" id="chanbans">
449 <p class="card-text"><?php generate_chanbans_table($channelObj); ?></p>
450 </div>
451 <div role="tabpanel" class="tab-pane fade in" id="chaninv">
452 <p class="card-text"><?php generate_chaninvites_table($channelObj); ?></p>
453 </div>
454 <div role="tabpanel" class="tab-pane fade in" id="chanex">
455 <p class="card-text"><?php generate_chanexcepts_table($channelObj); ?></p>
456 </div>
457
458 </div>
459 </div>
460 </div>
461 </div>
462 </div>
463 <script>
464 // show dat first tab
465 $('.nav-tabs a[href="#chanmodes"]').tab('show')
466 </script>
467 <?php
468 require_once("../footer.php");
469