X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/7f6973d58af186c727432abe2fccc0e4e71254c8..c06c1713af2db485d55a91073bbc5b63b6aa8c0b:/channels/details.php diff --git a/channels/details.php b/channels/details.php index b16c7ca..8cf6543 100644 --- a/channels/details.php +++ b/channels/details.php @@ -1,19 +1,23 @@ server()->get()) + IRCList::setmodes($uplink->server->features->chanmodes); $title = "Channel Lookup"; $channel = ""; $channame = ""; $nick = NULL; $channelObj = NULL; + +$can_edit = current_user_can(PERMISSION_EDIT_CHANNEL); do_log($_GET); do_log($_POST); if (isset($_GET['chan'])) { $channel = $_GET['chan']; - $channelObj = $rpc->channel()->get($channel); + $channelObj = $rpc->channel()->get($channel, 4); if (!$channelObj && strlen($channel)) { Message::Fail("Could not find channel: \"$channel\""); @@ -31,7 +35,7 @@ $del_ban = false; $checkboxes = []; $chanban_errors = []; -if (isset($_POST)) +if (!empty($_POST)) { if (isset($_POST['update_topic']) && isset($_POST['set_topic'])) { @@ -50,28 +54,30 @@ if (isset($_POST)) { foreach($_POST['ce_checkboxes'] as $c) $checkboxes[] = $c; - $del_ex = true; - chlkup_autoload_modal("excepts_modal"); + do_delete_chanex($channelObj, $checkboxes); } - else if (isset($_POST['delete_sel_inv'])) + if (isset($_POST['delete_sel_inv'])) { foreach($_POST['ci_checkboxes'] as $c) $checkboxes[] = $c; - $del_inv = true; - chlkup_autoload_modal("invites_modal"); + do_delete_invite($channelObj, $checkboxes); } else if (isset($_POST['delete_sel_ban'])) { foreach($_POST['cb_checkboxes'] as $c) $checkboxes[] = $c; - $del_ban = true; - chlkup_autoload_modal("bans_modal"); + do_delete_chanban($channelObj, $checkboxes); } - if (isset($_POST['add_chban'])) + if (isset($_POST['add_chban']) || isset($_POST['add_chinv']) || isset($_POST['add_chex'])) { - $mode = $_POST['add_chban']; + + if (isset($_POST['add_chban'])) + $mode = $_POST['add_chban']; + else + $mode = (isset($_POST['add_chinv'])) ? $_POST['add_chinv'] : $_POST['add_chex']; + $nick = (strlen($_POST['ban_nick'])) ? $_POST['ban_nick'] : false; - $action_string = (strlen($_POST['bantype_sel_action'])) ? $_POST['bantype_sel_action'] : false; + $action_string = (isset($_POST['bantype_sel_action']) && strlen($_POST['bantype_sel_action'])) ? $_POST['bantype_sel_action'] : false; $action = ""; $type_string = (strlen($_POST['bantype_sel_type'])) ? $_POST['bantype_sel_type'] : false; $type = ""; @@ -112,127 +118,314 @@ if (isset($_POST)) $future = strtotime($expiry); $now = strtotime(date("Y-m-d h:i:s")); $ts = ($future - $now) / 60; + $ts = (int)$ts; $time = "~time:$ts:"; if ($ts > 9999 || $ts < 1) $chanban_errors[] = "Cannot set expiry more than ".(9999 / 60)." hours (".(9999 / 1440)." days) in the future, or in the past"; } if (empty($chanban_errors)) - $rpc->channel()->set_mode($channel, "$mode", "$time$action$type$nick"); + if ($rpc->channel()->set_mode($channel, "$mode", "$time$action$type$nick")) + Message::Success("The mode was set successfully: $mode $time$action$type$nick"); else foreach($chanban_errors as $err) Message::Fail($err); } + if ((isset($_POST['kickban']) || isset($_POST['muteban'])) && current_user_can(PERMISSION_EDIT_CHANNEL_USER)) + { + $mute = (isset($_POST['muteban'])) ? true : false; + $mutestr = ($mute) ? "~quiet:" : ""; + $user = (!$mute) ? $_POST['kickban'] : $_POST['muteban']; + + $kbuser = $rpc->user()->get($user); + + if (!$kbuser) + Message::Fail("Could not kickban user: User does not exist"); + else + { + $rpc->channel()->set_mode($channelObj->name, "+b", "~time:".DEFAULT_CHAN_DETAIL_QUICK_ACTION_TIME.":".$mutestr."*!*@".$kbuser->user->cloakedhost); + if (!$mute) + $rpc->channel()->kick($channelObj->name, $kbuser->name, DEFAULT_CHAN_DETAIL_QUICK_BAN_REASON); + + $msgbox_str = ($mute) + ? + "User \"$kbuser->name\" has been muted for ".DEFAULT_CHAN_DETAIL_QUICK_ACTION_TIME." minutes." + : + "User \"$kbuser->name\" has been banned for ".DEFAULT_CHAN_DETAIL_QUICK_ACTION_TIME." minutes." + ; + Message::Success($msgbox_str); + } + } + + if (isset($_POST['newmodes']) && isset($_POST['paramed_modes']) && $can_edit) + { + $m = $_POST['newmodes']; + $p = $_POST['paramed_modes']; + + do_log($p,$m); + $addmodestring = "+"; + $addparamstring = ""; + $delmodestring = "-"; + $delparamstring = ""; + foreach ($m as $mode) + { + strcat($addmodestring, $mode); + if (isset($p[$mode]) && strlen($p[$mode])) + strcat($addparamstring, $p[$mode]." "); + } + + $fmodes = $channelObj->modes; + $tok = split($fmodes); + $modes = $tok[0]; + $params = rparv($fmodes); + $paramed_modes = sort_paramed_modes($modes, $params); + for ($i = 0; isset($modes[$i]) && $mode = $modes[$i]; $i++) + { + if (!strstr($addmodestring, $mode)) + { + $req = IRCList::lookup($mode)['requires']; + if ($req == "Server") + continue; + strcat($delmodestring, $mode); + $grp = get_chmode_group($mode); + if ($grp == 2) + strcat($delparamstring, $paramed_modes[$mode]." "); + } + + } + + + if ($rpc->channel()->set_mode($channel, $delmodestring.$addmodestring, $delparamstring." ".$addparamstring)) + Message::Success("Channel settings have been successfully updated"); + else + Message::Fail("Could not change channel settings: $rpc->error"); + } + /* Re-grab the channel because of updates */ + $channelObj = $rpc->channel()->get($channel, 4); } ?> <?php echo $title; ?> -

-
+
+ +
-
-
- +
+
-
- -
-

- Topic:

-
-
- "> -
-
-name has been updated to be: \"".htmlspecialchars($channelObj->topic)."\""); -?> -
-
-
- -