From: Valerie Pond Date: Wed, 5 Jul 2023 00:20:09 +0000 (+0100) Subject: Channel modes: Split up larger strings X-Git-Tag: 0.9~9 X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/commitdiff_plain/34eac98afbb1e170e5fff9646bb22cf39fc3f72d?ds=sidebyside;hp=c9e895e3b74e7b2eef6554a20a25f0ff9b9783e1 Channel modes: Split up larger strings --- diff --git a/misc/channel-lookup-misc.php b/misc/channel-lookup-misc.php index 0ec1872..101f9ec 100644 --- a/misc/channel-lookup-misc.php +++ b/misc/channel-lookup-misc.php @@ -397,16 +397,30 @@ function _do_chan_item_delete($chan, string $type, array $list, array &$errors) foreach($list as $l) { + // check if the string needs therapy + if ((strlen($n) + 1) + (strlen($str) + strlen($l)) > 150) + { + // send what we've got already and prepare for the next lot + if (!$rpc->channel()->set_mode($chan->name, htmlspecialchars("-$n"), htmlspecialchars($str))) + $errors[] = $rpc->error . " ($rpc->errno)"; + + // prepare for the next set + $n = ""; + $str = ""; + } $n .= $char; $str .= " ".$l; } + // if multiple, this will be the last one so we return here if ($rpc->channel()->set_mode($chan->name, htmlspecialchars("-$n"), htmlspecialchars($str))) { + if (!empty($errors)) + Message::Fail("One or more errors occurred:", $errors); Message::Success("Deleted successfully"); return true; } $errors[] = $rpc->error . " ($rpc->errno)"; - Message::Fail("An error occurred: $rpc->error"); + Message::Fail("An error occurred:", $errors); return false; }