]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - channels/details.php
give success/error messages on edit panel user
[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;
53 $del_ex = true;
54 chlkup_autoload_modal("excepts_modal");
55 }
56 else if (isset($_POST['delete_sel_inv']))
57 {
58 foreach($_POST['ci_checkboxes'] as $c)
59 $checkboxes[] = $c;
60 $del_inv = true;
61 chlkup_autoload_modal("invites_modal");
62 }
63 else if (isset($_POST['delete_sel_ban']))
64 {
65 foreach($_POST['cb_checkboxes'] as $c)
66 $checkboxes[] = $c;
67 $del_ban = true;
68 chlkup_autoload_modal("bans_modal");
69 }
185d5d5d 70 if (isset($_POST['add_chban']) || isset($_POST['add_chinv']) || isset($_POST['add_chex']))
04f90856 71 {
185d5d5d
VP
72
73 if (isset($_POST['add_chban']))
74 $mode = $_POST['add_chban'];
75 else
76 $mode = (isset($_POST['add_chinv'])) ? $_POST['add_chinv'] : $_POST['add_chex'];
77
04f90856 78 $nick = (strlen($_POST['ban_nick'])) ? $_POST['ban_nick'] : false;
785717b4 79 $action_string = (isset($_POST['bantype_sel_action']) && strlen($_POST['bantype_sel_action'])) ? $_POST['bantype_sel_action'] : false;
04f90856
VP
80 $action = "";
81 $type_string = (strlen($_POST['bantype_sel_type'])) ? $_POST['bantype_sel_type'] : false;
82 $type = "";
83 $expiry = (strlen($_POST['bantype_sel_ex'])) ? $_POST['bantype_sel_ex'] : false;
84 $time = "";
85
86 if (!$nick)
87 $chanban_errors[] = "You did not specify a nick/mask";
88
89 if ($action_string)
90 {
91 if (strstr($action_string,"Quiet"))
92 $action = "~quiet:";
93 elseif (strstr($action_string,"Nick-change"))
94 $action = "~nickchange:";
95 elseif (strstr($action_string,"Join"))
96 $action = "~join:";
97 }
98 if ($type_string)
99 {
100 if (strstr($type_string,"Account"))
101 $type = "~account:";
102 elseif (strstr($type_string,"Channel"))
103 $type = "~channel:";
104 elseif (strstr($type_string,"Country"))
105 $type = "~country:";
106 elseif (strstr($type_string,"OperClass"))
107 $type = "~operclass:";
108 elseif (strstr($type_string,"GECOS"))
109 $type = "~realname:";
110 elseif (strstr($type_string,"Security"))
111 $type = "~security-group:";
112 elseif (strstr($type_string,"Certificate"))
113 $type = "~certfp:";
114 }
115 if ($expiry)
116 {
117 $future = strtotime($expiry);
118 $now = strtotime(date("Y-m-d h:i:s"));
119 $ts = ($future - $now) / 60;
7431f178 120 $ts = (int)$ts;
04f90856
VP
121 $time = "~time:$ts:";
122 if ($ts > 9999 || $ts < 1)
123 $chanban_errors[] = "Cannot set expiry more than ".(9999 / 60)." hours (".(9999 / 1440)." days) in the future, or in the past";
124 }
125 if (empty($chanban_errors))
7431f178
VP
126 if ($rpc->channel()->set_mode($channel, "$mode", "$time$action$type$nick"))
127 Message::Success("The mode was set successfully: $mode $time$action$type$nick");
7f6973d5
VP
128
129 else
130 foreach($chanban_errors as $err)
131 Message::Fail($err);
04f90856 132 }
185d5d5d
VP
133 /* and finally re-grab the channel because updates lol */
134 $channelObj = $rpc->channel()->get($channel);
0b82418b 135
b3c83a04
VP
136}
137
604aac30
VP
138?>
139<title><?php echo $title; ?></title>
140<h4><?php echo $title; ?></h4>
141<br>
d9a581b9 142
785717b4
VP
143
144<div class="container-xl">
145<form method="get" action="details.php">
146 <div class="input-group">
147 <input class="form-control" id="chan" name="chan" type="text" value="<?php echo $channame; ?>">
148 <div class="input-group-append">
149 <button type="submit" class="btn btn-primary">Go</button>
150 </div>
151 </div>
152</div>
153</form>
154<?php if (!$channelObj)
155 return; ?>
156
157
d9a581b9 158<!-- Modal for Channel Bans -->
185d5d5d 159<div class="modal fade" id="bans_modal" name="bans_modal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
d9a581b9
VP
160 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
161 <div class="modal-content">
162 <div class="modal-header">
163 <h5 class="modal-title" id="myModalLabel">Channel Bans</h5>
164 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
165 <span aria-hidden="true">&times;</span>
166 </button>
167 </div>
168 <div class="modal-body">
0b82418b 169 <?php if ($del_ban) do_delete_chanban($channelObj, $checkboxes); ?>
d9a581b9
VP
170 <form method="post">
171 <?php generate_chanbans_table($channelObj); ?>
172 </form>
173 </div>
174 </div>
175 </div>
176</div>
177<!-- Modal for Channel Invited -->
785717b4 178<div class="modal fade" id="invites_modal" name="#invites_modal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
d9a581b9
VP
179 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
180 <div class="modal-content">
181 <div class="modal-header">
182 <h5 class="modal-title" id="myModalLabel">Channel Invites</h5>
183 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
184 <span aria-hidden="true">&times;</span>
185 </button>
186 </div>
187 <div class="modal-body">
0b82418b 188 <?php if ($del_inv) do_delete_invite($channelObj, $checkboxes); ?>
d9a581b9
VP
189 <form method="post">
190 <?php generate_chaninvites_table($channelObj); ?>
191 </form>
192 </div>
193 </div>
194 </div>
195</div>
196
197<!-- Modal for Channel Exceptions -->
198<div class="modal fade" id="excepts_modal" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
199 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
200 <div class="modal-content">
201 <div class="modal-header">
202 <h5 class="modal-title" id="myModalLabel">Channel Exceptions</h5>
203 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
204 <span aria-hidden="true">&times;</span>
205 </button>
206 </div>
207 <div class="modal-body">
0b82418b 208 <?php if ($del_ex) do_delete_chanex($channelObj, $checkboxes); ?>
d9a581b9
VP
209 <form method="post">
210 <?php generate_chanexcepts_table($channelObj); ?>
211 </form>
212 </div>
213 </div>
214 </div>
215</div>
b3c83a04
VP
216
217
04f90856 218<!-- Modal for Add Ban -->
185d5d5d 219<div class="modal fade" id="ban" tabindex="-1" role="dialog" aria-labelledby="confirmModalCenterTitle" aria-hidden="true">
04f90856
VP
220 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
221 <div class="modal-content">
222 <div class="modal-header">
223 <h5 class="modal-title" id="myModalLabel">Add New Channel Ban</h5>
224 <div type="button" class="close" data-dismiss="modal" aria-label="Close">
225 <span aria-hidden="true">&times;</span>
226 </div>
227 </div>
228 <div class="modal-body">
229 <form method="post">
230 <div class="input-group mb-3">
231 <label for="ban_nick">Mask
232 <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
233 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"
234 ></i></a>
235 <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
236 placeholder="nick!user@host or something else"
237 ></label>
238
239 </div>
240 <div class="input-group mb-3">
241 <label for="bantype_action">Ban Action
242 <select class="form-control" name="bantype_sel_action" id="bantype_sel">
243 <option></option>
244 <option>Quiet (Mute)</option>
245 <option>Nick-change</option>
246 <option>Join</option>
247 </select>
248 </label>
249 </div>
250 <div class="input-group mb-3">
251 <label for="bantype_sel_type">Ban Type
252 <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
253 <option></option>
254 <option>Match Account</option>
255 <option>Match Channel</option>
256 <option>Match Country</option>
257 <option>Match OperClass</option>
258 <option>Match RealName / GECOS</option>
259 <option>Match Security Group</option>
260 <option>Match Certificate Fingerprint</option>
261 </select>
262 </label>
263 </div>
264 <div class="input-group mb-3">
265 <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
266 <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
267 </label>
268 </div>
269 </div>
270 <div class="modal-footer">
271 <input type="hidden" id="server" name="add_chban" value="b"></input>
272 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
273 <button type="submit" action="post" class="btn btn-danger">Add Channel Ban</button>
274 </form>
275 </div>
276 </div>
277 </div>
278</div>
279
280
185d5d5d
VP
281<!-- Modal for Add Invite -->
282<div class="modal fade" id="invite" tabindex="-1" role="dialog" aria-labelledby="add_invite_modal" aria-hidden="true">
04f90856
VP
283 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
284 <div class="modal-content">
285 <div class="modal-header">
185d5d5d
VP
286 <h5 class="modal-title" id="add_invite_modal">Add New Channel Invite</h5>
287 <div type="button" class="close" data-dismiss="modal" aria-label="Close">
04f90856 288 <span aria-hidden="true">&times;</span>
185d5d5d 289 </div>
04f90856
VP
290 </div>
291 <div class="modal-body">
292 <form method="post">
293 <div class="input-group mb-3">
185d5d5d
VP
294 <label for="ban_nick">Mask
295 <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
296 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"
297 ></i></a>
298 <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
299 placeholder="nick!user@host or something else"
300 ></label>
301
04f90856
VP
302 </div>
303 <div class="input-group mb-3">
185d5d5d
VP
304 <label for="bantype_sel_type">Invite Type
305 <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
306 <option></option>
307 <option>Match Account</option>
308 <option>Match Channel</option>
309 <option>Match Country</option>
310 <option>Match OperClass</option>
311 <option>Match RealName / GECOS</option>
312 <option>Match Security Group</option>
313 <option>Match Certificate Fingerprint</option>
314 </select>
315 </label>
316 </div>
317 <div class="input-group mb-3">
318 <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
319 <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
320 </label>
04f90856 321 </div>
185d5d5d
VP
322 </div>
323 <div class="modal-footer">
2dd2b837 324 <input type="hidden" name="add_chinv" value="I"></input>
185d5d5d 325 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
2dd2b837 326 <button type="submit" action="post" class="btn btn-danger">Add Invite</button>
04f90856
VP
327 </form>
328 </div>
329 </div>
330 </div>
331</div>
332
185d5d5d
VP
333<!-- Modal for Add Ban Exceptions -->
334<div class="modal fade" id="except" tabindex="-1" role="dialog" aria-labelledby="add_except_modal" aria-hidden="true">
335 <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
336 <div class="modal-content">
337 <div class="modal-header">
338 <h5 class="modal-title" id="add_except_modal">Add New Channel Ban Exception</h5>
339 <div type="button" class="close" data-dismiss="modal" aria-label="Close">
340 <span aria-hidden="true">&times;</span>
341 </div>
342 </div>
343 <div class="modal-body">
344 <form method="post">
345 <div class="input-group mb-3">
346 <label for="ban_nick">Mask
347 <a href="https://www.unrealircd.org/docs/Extended_bans" target="__blank"><i class="fa fa-info-circle" aria-hidden="true"
348 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"
349 ></i></a>
350 <input style="width: 170%;" name="ban_nick" id="ban_nick" class="form-control curvy" type="text"
351 placeholder="nick!user@host or something else"
352 ></label>
353
354 </div>
355 <div class="input-group mb-3">
356 <label for="bantype_sel_type">Ban Type
357 <select class="form-control" name="bantype_sel_type" id="bantype_sel_type">
358 <option></option>
359 <option>Match Account</option>
360 <option>Match Channel</option>
361 <option>Match Country</option>
362 <option>Match OperClass</option>
363 <option>Match RealName / GECOS</option>
364 <option>Match Security Group</option>
365 <option>Match Certificate Fingerprint</option>
366 </select>
367 </label>
368 </div>
369 <div class="input-group mb-3">
370 <label for="bantype_sel_ex">Expiry Date-Time <br><small>Leave blank to mean "Permanent"</small>
371 <input type="datetime-local" name="bantype_sel_ex" id="bantype_sel_ex" class="form-control">
372 </label>
373 </div>
374 </div>
375 <div class="modal-footer">
376 <input type="hidden" id="server" name="add_chex" value="e"></input>
377 <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
378 <button type="submit" action="post" class="btn btn-danger">Add Exception</button>
379 </form>
380 </div>
381 </div>
382 </div>
383</div>
185d5d5d
VP
384
385<br>
386<h3>
387 Topic:<br></h3>
388 <form method="post" action="details.php?chan=<?php echo urlencode($channelObj->name); ?>">
389 <div class="input-group">
390 <input maxlength="360" type="text" class="input-group form-control" name="set_topic" value="<?php echo (isset($channelObj->topic)) ? htmlspecialchars($channelObj->topic) : ""; ?>">
391 <div class="input-group-append"><button type="submit" name="update_topic" value="true" class="btn btn-info">Update Topic</button></div></div>
392 </form>
393<?php
394if ($topicset)
395 Message::Success("The topic for $channelObj->name has been updated to be: \"".htmlspecialchars($channelObj->topic)."\"");
396?>
397<br>
398<div class="row" style="margin-left: 0px">
399 <div class="p-1">
400 <button class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Bans</button>
401 <div class="dropdown-menu">
402 <div class="dropdown-item" data-toggle="modal" data-target="#ban">Add New</div>
403 <div class="dropdown-item" data-toggle="modal" data-target="#bans_modal">List</div>
404 </div>
405 </div>
406 <div class="p-1">
407 <button class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Invites</button>
408 <div class="dropdown-menu">
409 <div class="dropdown-item" data-toggle="modal" data-target="#invite">Add New</div>
410 <div class="dropdown-item" data-toggle="modal" data-target="#invites_modal">List</div>
411 </div>
412 </div>
413 <div class="p-1">
414 <button class="btn btn-warning dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Excepts</button>
415 <div class="dropdown-menu">
416 <div class="dropdown-item" data-toggle="modal" data-target="#except">Add New</div>
417 <div class="dropdown-item" data-toggle="modal" data-target="#excepts_modal">List</div>
418 </div>
419 </div>
420</div>
421<br>
04f90856 422
b3c83a04 423
d9a581b9
VP
424<div class="container-xxl">
425 <div class="accordion" id="accordionExample">
2405dc8e
VP
426 <div class="card">
427 <div class="card-header" id="headingOne">
428 <h2 class="mb-0">
429 <button class="btn" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
430 User List
431 </button>
432 </h2>
433 </div>
d9a581b9 434
2405dc8e
VP
435 <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
436 <div class="card-body">
437 <?php generate_chan_occupants_table($channelObj); ?>
438 </div>
439 </div>
440 </div>
441 <div class="card">
442 <div class="card-header" id="headingTwo">
443 <h2 class="mb-0">
444 <button class="btn collapsed" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
445 Collapsible Group Item #2
446 </button>
447 </h2>
448 </div>
449 <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
450 <div class="card-body">
451 Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
452 </div>
453 </div>
454 </div>
455 <div class="card">
456 <div class="card-header" id="headingThree">
457 <h2 class="mb-0">
458 <button class="btn collapsed" type="button" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
459 Collapsible Group Item #3
460 </button>
461 </h2>
462 </div>
463 <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordionExample">
464 <div class="card-body">
465 Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
466 </div>
467 </div>
d9a581b9 468 </div>
354f4b85 469 </div>
604aac30 470</div>
185d5d5d 471
604aac30 472<?php
ce9cf366 473require_once("../footer.php");
604aac30 474