]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - misc/strings.php
Fix setting zlines on idents, reported by Jellis
[irc/unrealircd/unrealircd-webpanel.git] / misc / strings.php
index 25cbdba5ae7f7a4b352ca2c91840ab7c73ee6334..f5d576753ee66e197be5aac0deb49d41afa7f679 100644 (file)
@@ -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);
+}