]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - channels/details.php
Don't call channel.get() twice for simple GET requests.
[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'];
72e61f76 16 $channelObj = $rpc->channel()->get($channel, 4);
d9a581b9 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 = [];
72e61f76 34if (!empty($_POST))
b3c83a04
VP
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 }
72e61f76
BM
155 /* Re-grab the channel because of updates */
156 $channelObj = $rpc->channel()->get($channel, 4);
b3c83a04
VP
157}
158
604aac30
VP
159?>
160<title><?php echo $title; ?></title>
e92763ac 161<h6><?php echo $title; ?></h6>
604aac30 162<br>
d9a581b9 163
785717b4
VP
164
165<div class="container-xl">
166<form method="get" action="details.php">
e92763ac
VP
167 <div class="text-left input-group">
168 <input class="form-control" id="chan" name="chan" type="text" value="<?php echo $channame; ?>">
785717b4
VP
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
04f90856 178<!-- Modal for Add Ban -->
185d5d5d 179<div class="modal fade" id="ban" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
04f90856
VP
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
185d5d5d
VP
241<!-- Modal for Add Invite -->
242<div class="modal fade" id="invite" tabindex="-1" role="dialog" aria-labelledby="add_invite_modal" aria-hidden="true">
04f90856
VP
243 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
244 <div class="modal-content">
245 <div class="modal-header">
185d5d5d
VP
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">
04f90856 248 <span aria-hidden="true">&times;</span>
185d5d5d 249 </div>
04f90856
VP
250 </div>
251 <div class="modal-body">
252 <form method="post">
253 <div class="input-group mb-3">
185d5d5d
VP
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
04f90856
VP
262 </div>
263 <div class="input-group mb-3">
185d5d5d
VP
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>
04f90856 281 </div>
185d5d5d
VP
282 </div>
283 <div class="modal-footer">
2dd2b837 284 <input type="hidden" name="add_chinv" value="I"></input>
185d5d5d 285 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
2dd2b837 286 <button type="submit" action="post" class="btn btn-danger">Add Invite</button>
04f90856
VP
287 </form>
288 </div>
289 </div>
290 </div>
291</div>
292
185d5d5d
VP
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>
185d5d5d
VP
344
345<br>
e92763ac
VP
346<h6>
347 Topic:<br></h6>
185d5d5d
VP
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
354if ($topicset)
355 Message::Success("The topic for $channelObj->name has been updated to be: \"".htmlspecialchars($channelObj->topic)."\"");
356?>
357<br>
d2db68e3
VP
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
d9a581b9 421<div class="container-xxl">
d2db68e3 422 <div class="row">
5adc2fad 423 <div class="col-sm-4">
d2db68e3
VP
424 <div class="card">
425 <div class="card-body">
e92763ac 426 <h6 class="card-title">User List</h6>
d2db68e3
VP
427 <p class="card-text"><?php generate_chan_occupants_table($channelObj); ?></p>
428 </div>
429 </div>
430 </div>
5adc2fad 431 <div class="col-sm-8">
d2db68e3
VP
432 <div class="card">
433 <div class="card-body">
e92763ac
VP
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>
d2db68e3
VP
459 </div>
460 </div>
461 </div>
604aac30 462</div>
e92763ac
VP
463<script>
464 // show dat first tab
465$('.nav-tabs a[href="#chanmodes"]').tab('show')
466</script>
604aac30 467<?php
ce9cf366 468require_once("../footer.php");
604aac30 469