X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/blobdiff_plain/4b48b46f55bb6a03a29d0d0db04b3076c1eaae8f..67bff06aa6fd4d7d3a9aefc2919307326fa6d755:/misc/strings.php diff --git a/misc/strings.php b/misc/strings.php index 25cbdba..f5d5767 100644 --- a/misc/strings.php +++ b/misc/strings.php @@ -192,4 +192,19 @@ function rparv($string) if ($string) return $string; return false; -} \ No newline at end of file +} + +/* Taken from https://www.aviran.org/stripremove-irc-client-control-characters/ + * We may want to re-base it off our UnrealIRCd's one though. + */ +function StripControlCharacters($text) +{ + $controlCodes = array( + '/(\x03(?:\d{1,2}(?:,\d{1,2})?)?)/', // Color code + '/\x02/', // Bold + '/\x0F/', // Escaped + '/\x16/', // Italic + '/\x1F/' // Underline + ); + return preg_replace($controlCodes,'',$text); +}