]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - channels/details.php
Move the channel details around, make it look better
[irc/unrealircd/unrealircd-webpanel.git] / channels / details.php
CommitLineData
604aac30
VP
1<?php
2require_once "../common.php";
3require_once "../header.php";
d9a581b9 4require_once "../misc/channel-lookup-misc.php";
604aac30
VP
5
6$title = "Channel Lookup";
7$channel = "";
d9a581b9 8$channame = "";
604aac30 9$nick = NULL;
b3c83a04 10$channelObj = NULL;
604aac30 11do_log($_GET);
d9a581b9 12do_log($_POST);
604aac30
VP
13if (isset($_GET['chan']))
14{
15 $channel = $_GET['chan'];
d9a581b9
VP
16 $channelObj = $rpc->channel()->get($channel);
17 if (!$channelObj && strlen($channel))
604aac30
VP
18 {
19 Message::Fail("Could not find channel: \"$channel\"");
d9a581b9
VP
20 } elseif (strlen($channel)) {
21
22 $channame = $channelObj->name;
604aac30 23 $title .= " for \"" . $channame . "\"";
d9a581b9 24 do_log($channelObj);
604aac30
VP
25 }
26}
b3c83a04 27$topicset = false;
0b82418b
VP
28$del_ex = false;
29$del_inv = false;
30$del_ban = false;
31$checkboxes = [];
04f90856
VP
32
33$chanban_errors = [];
b3c83a04
VP
34if (isset($_POST))
35{
36 if (isset($_POST['update_topic']) && isset($_POST['set_topic']))
37 {
38 if (isset($channelObj))
39 {
0b82418b 40 if (!isset($channelObj->topic) || strcmp($channelObj->topic,$_POST['set_topic'])) // if the set topic is different
b3c83a04
VP
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 }
0b82418b
VP
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;
e92763ac 53 do_delete_chanex($channelObj, $checkboxes);
0b82418b 54 }
e92763ac 55 if (isset($_POST['delete_sel_inv']))
0b82418b
VP
56 {
57 foreach($_POST['ci_checkboxes'] as $c)
58 $checkboxes[] = $c;
e92763ac 59 do_delete_invite($channelObj, $checkboxes);
0b82418b
VP
60 }
61 else if (isset($_POST['delete_sel_ban']))
62 {
63 foreach($_POST['cb_checkboxes'] as $c)
64 $checkboxes[] = $c;
e92763ac 65 do_delete_chanban($channelObj, $checkboxes);
0b82418b 66 }
185d5d5d 67 if (isset($_POST['add_chban']) || isset($_POST['add_chinv']) || isset($_POST['add_chex']))
04f90856 68 {
185d5d5d
VP
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
04f90856 75 $nick = (strlen($_POST['ban_nick'])) ? $_POST['ban_nick'] : false;
785717b4 76 $action_string = (isset($_POST['bantype_sel_action']) && strlen($_POST['bantype_sel_action'])) ? $_POST['bantype_sel_action'] : false;
04f90856
VP
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;
7431f178 117 $ts = (int)$ts;
04f90856
VP
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))
7431f178
VP
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");
7f6973d5
VP
125
126 else
127 foreach($chanban_errors as $err)
128 Message::Fail($err);
04f90856 129 }
d2db68e3
VP
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 }
185d5d5d
VP
155 /* and finally re-grab the channel because updates lol */
156 $channelObj = $rpc->channel()->get($channel);
0b82418b 157
b3c83a04
VP
158}
159
604aac30
VP
160?>
161<title><?php echo $title; ?></title>
e92763ac 162<h6><?php echo $title; ?></h6>
604aac30 163<br>
d9a581b9 164
785717b4
VP
165
166<div class="container-xl">
167<form method="get" action="details.php">
e92763ac
VP
168 <div class="text-left input-group">
169 <input class="form-control" id="chan" name="chan" type="text" value="<?php echo $channame; ?>">
785717b4
VP
170 <div class="input-group-append">
171 <button type="submit" class="btn btn-primary">Go</button>
172 </div>
173 </div>
174</div>
175</form>
176<?php if (!$channelObj)
177 return; ?>
178
04f90856 179<!-- Modal for Add Ban -->
185d5d5d 180<div class="modal fade" id="ban" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
04f90856
VP
181 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
182 <div class="modal-content">
183 <div class="modal-header">
184 <h5 class="modal-title" id="myModalLabel">Add New Channel Ban</h5>
185 <div type="button" class="close" data-dismiss="modal" aria-label="Close">
186 <span aria-hidden="true">&times;</span>
187 </div>
188 </div>
189 <div class="modal-body">
190 <form method="post">
191 <div class="input-group mb-3">
192 <label for="ban_nick">Mask
193 <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
194 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"
195 ></i></a>
196 <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
197 placeholder="nick!user@host or something else"
198 ></label>
199
200 </div>
201 <div class="input-group mb-3">
202 <label for="bantype_action">Ban Action
203 <select class="form-control" name="bantype_sel_action" id="bantype_sel">
204 <option></option>
205 <option>Quiet (Mute)</option>
206 <option>Nick-change</option>
207 <option>Join</option>
208 </select>
209 </label>
210 </div>
211 <div class="input-group mb-3">
212 <label for="bantype_sel_type">Ban Type
213 <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
214 <option></option>
215 <option>Match Account</option>
216 <option>Match Channel</option>
217 <option>Match Country</option>
218 <option>Match OperClass</option>
219 <option>Match RealName / GECOS</option>
220 <option>Match Security Group</option>
221 <option>Match Certificate Fingerprint</option>
222 </select>
223 </label>
224 </div>
225 <div class="input-group mb-3">
226 <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
227 <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
228 </label>
229 </div>
230 </div>
231 <div class="modal-footer">
232 <input type="hidden" id="server" name="add_chban" value="b"></input>
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">Add Channel Ban</button>
235 </form>
236 </div>
237 </div>
238 </div>
239</div>
240
241
185d5d5d
VP
242<!-- Modal for Add Invite -->
243<div class="modal fade" id="invite" tabindex="-1" role="dialog" aria-labelledby="add_invite_modal" aria-hidden="true">
04f90856
VP
244 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
245 <div class="modal-content">
246 <div class="modal-header">
185d5d5d
VP
247 <h5 class="modal-title" id="add_invite_modal">Add New Channel Invite</h5>
248 <div type="button" class="close" data-dismiss="modal" aria-label="Close">
04f90856 249 <span aria-hidden="true">&times;</span>
185d5d5d 250 </div>
04f90856
VP
251 </div>
252 <div class="modal-body">
253 <form method="post">
254 <div class="input-group mb-3">
185d5d5d
VP
255 <label for="ban_nick">Mask
256 <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
257 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"
258 ></i></a>
259 <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
260 placeholder="nick!user@host or something else"
261 ></label>
262
04f90856
VP
263 </div>
264 <div class="input-group mb-3">
185d5d5d
VP
265 <label for="bantype_sel_type">Invite Type
266 <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
267 <option></option>
268 <option>Match Account</option>
269 <option>Match Channel</option>
270 <option>Match Country</option>
271 <option>Match OperClass</option>
272 <option>Match RealName / GECOS</option>
273 <option>Match Security Group</option>
274 <option>Match Certificate Fingerprint</option>
275 </select>
276 </label>
277 </div>
278 <div class="input-group mb-3">
279 <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
280 <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
281 </label>
04f90856 282 </div>
185d5d5d
VP
283 </div>
284 <div class="modal-footer">
2dd2b837 285 <input type="hidden" name="add_chinv" value="I"></input>
185d5d5d 286 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
2dd2b837 287 <button type="submit" action="post" class="btn btn-danger">Add Invite</button>
04f90856
VP
288 </form>
289 </div>
290 </div>
291 </div>
292</div>
293
185d5d5d
VP
294<!-- Modal for Add Ban Exceptions -->
295<div class="modal fade" id="except" tabindex="-1" role="dialog" aria-labelledby="add_except_modal" aria-hidden="true">
296 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
297 <div class="modal-content">
298 <div class="modal-header">
299 <h5 class="modal-title" id="add_except_modal">Add New Channel Ban Exception</h5>
300 <div type="button" class="close" data-dismiss="modal" aria-label="Close">
301 <span aria-hidden="true">&times;</span>
302 </div>
303 </div>
304 <div class="modal-body">
305 <form method="post">
306 <div class="input-group mb-3">
307 <label for="ban_nick">Mask
308 <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
309 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"
310 ></i></a>
311 <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
312 placeholder="nick!user@host or something else"
313 ></label>
314
315 </div>
316 <div class="input-group mb-3">
317 <label for="bantype_sel_type">Ban Type
318 <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
319 <option></option>
320 <option>Match Account</option>
321 <option>Match Channel</option>
322 <option>Match Country</option>
323 <option>Match OperClass</option>
324 <option>Match RealName / GECOS</option>
325 <option>Match Security Group</option>
326 <option>Match Certificate Fingerprint</option>
327 </select>
328 </label>
329 </div>
330 <div class="input-group mb-3">
331 <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
332 <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
333 </label>
334 </div>
335 </div>
336 <div class="modal-footer">
337 <input type="hidden" id="server" name="add_chex" value="e"></input>
338 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
339 <button type="submit" action="post" class="btn btn-danger">Add Exception</button>
340 </form>
341 </div>
342 </div>
343 </div>
344</div>
185d5d5d
VP
345
346<br>
e92763ac
VP
347<h6>
348 Topic:<br></h6>
185d5d5d
VP
349 <form method="post" action="details.php?chan=<?php echo urlencode($channelObj->name); ?>">
350 <div class="input-group">
351 <input maxlength="360" type="text" class="input-group form-control" name="set_topic" value="<?php echo (isset($channelObj->topic)) ? htmlspecialchars($channelObj->topic) : ""; ?>">
352 <div class="input-group-append"><button type="submit" name="update_topic" value="true" class="btn btn-info">Update Topic</button></div></div>
353 </form>
354<?php
355if ($topicset)
356 Message::Success("The topic for $channelObj->name has been updated to be: \"".htmlspecialchars($channelObj->topic)."\"");
357?>
358<br>
d2db68e3
VP
359
360<!-- Modal for User Action -->
361<div class="modal fade" id="useraction" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
362 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
363 <div class="modal-content">
364 <div class="modal-header">
365 <h5 class="modal-title" id="myModalLabel">Add New Channel Ban</h5>
366 <div type="button" class="close" data-dismiss="modal" aria-label="Close">
367 <span aria-hidden="true">&times;</span>
368 </div>
369 </div>
370 <div class="modal-body">
371 <form method="post">
372 <div class="input-group mb-3">
373 <label for="ban_nick">Mask
374 <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
375 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"
376 ></i></a>
377 <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
378 placeholder="nick!user@host or something else"
379 ></label>
380
381 </div>
382 <div class="input-group mb-3">
383 <label for="bantype_action">Ban Action
384 <select class="form-control" name="bantype_sel_action" id="bantype_sel">
385 <option></option>
386 <option>Quiet (Mute)</option>
387 <option>Nick-change</option>
388 <option>Join</option>
389 </select>
390 </label>
391 </div>
392 <div class="input-group mb-3">
393 <label for="bantype_sel_type">Ban Type
394 <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
395 <option></option>
396 <option>Match Account</option>
397 <option>Match Channel</option>
398 <option>Match Country</option>
399 <option>Match OperClass</option>
400 <option>Match RealName / GECOS</option>
401 <option>Match Security Group</option>
402 <option>Match Certificate Fingerprint</option>
403 </select>
404 </label>
405 </div>
406 <div class="input-group mb-3">
407 <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
408 <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
409 </label>
410 </div>
411 </div>
412 <div class="modal-footer">
413 <input type="hidden" id="server" name="add_chban" value="b"></input>
414 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
415 <button type="submit" action="post" class="btn btn-danger">Add Channel Ban</button>
416 </form>
417 </div>
418 </div>
419 </div>
420</div>
421
d9a581b9 422<div class="container-xxl">
d2db68e3
VP
423 <div class="row">
424 <div class="col-sm-5">
425 <div class="card">
426 <div class="card-body">
e92763ac 427 <h6 class="card-title">User List</h6>
d2db68e3
VP
428 <p class="card-text"><?php generate_chan_occupants_table($channelObj); ?></p>
429 </div>
430 </div>
431 </div>
432 <div class="col-sm-6">
433 <div class="card">
434 <div class="card-body">
e92763ac
VP
435 <h6 class="card-title">Channel Settings</h6>
436 <ul class="nav nav-tabs" role="tablist">
437 <li class="nav-item" role="presentation"><a class="nav-link" href="#chanmodes" aria-controls="chanmodes" role="tab" data-toggle="tab">Settings / Modes</a></li>
438 <li class="nav-item" role="presentation"><a class="nav-link" href="#chanbans" aria-controls="chanbans" role="tab" data-toggle="tab">Bans</a></li>
439 <li class="nav-item" role="presentation"><a class="nav-link" href="#chaninv" aria-controls="chaninv" role="tab" data-toggle="tab">Invites</a></li>
440 <li class="nav-item" role="presentation"><a class="nav-link" href="#chanex" aria-controls="chanex" role="tab" data-toggle="tab">Excepts</a></li>
441 </ul>
442
443 <div class="tab-content">
444
445 <div role="tabpanel" class="tab-pane fade in" id="chanmodes">
446 <p class="card-text"><?php generate_html_chansettings($channelObj); ?></p>
447 </div>
448
449 <div role="tabpanel" class="tab-pane fade in" id="chanbans">
450 <p class="card-text"><?php generate_chanbans_table($channelObj); ?></p>
451 </div>
452 <div role="tabpanel" class="tab-pane fade in" id="chaninv">
453 <p class="card-text"><?php generate_chaninvites_table($channelObj); ?></p>
454 </div>
455 <div role="tabpanel" class="tab-pane fade in" id="chanex">
456 <p class="card-text"><?php generate_chanexcepts_table($channelObj); ?></p>
457 </div>
458
459 </div>
d2db68e3
VP
460 </div>
461 </div>
462 </div>
604aac30 463</div>
e92763ac
VP
464<script>
465 // show dat first tab
466$('.nav-tabs a[href="#chanmodes"]').tab('show')
467</script>
604aac30 468<?php
ce9cf366 469require_once("../footer.php");
604aac30 470