From 40001ad0be6a81d0d06b96df6b70a4032d368fbe Mon Sep 17 00:00:00 2001 From: Ruan Date: Sun, 7 Jun 2015 17:37:46 +0200 Subject: [PATCH] Remove chat colors --- bans.php | 2 +- check.php | 2 +- includes/page.php | 13 +++++++++++++ mutes.php | 2 +- warnings.php | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bans.php b/bans.php index a948761..a215613 100644 --- a/bans.php +++ b/bans.php @@ -66,7 +66,7 @@ - + '); echo('Banned by: ' . $banner . '
'); - echo('Reason: ' . $reason . '
'); + echo('Reason: ' . clean($reason) . '
'); echo('Banned on: ' . $time . '
'); if ($row['until'] > 0) { echo('Banned until: ' . $until . '
'); diff --git a/includes/page.php b/includes/page.php index beeb6fd..c69fde0 100644 --- a/includes/page.php +++ b/includes/page.php @@ -36,4 +36,17 @@ function millis_to_date($millis) { date_default_timezone_set("UTC"); return date('F j, Y, g:i a', $millis / 1000); } + +/** + * Removes chat colors from a string. + * @param $text + */ +function clean($text) { + if (strstr($text, "\xa7") || strstr($text, "&")) { + $regex = "/(?i)(\xa7|&)[0-9A-FK-OR]/"; + return preg_replace($regex, "", $text); + } + return $text; +} + ?> diff --git a/mutes.php b/mutes.php index 0bdbe68..f61178d 100644 --- a/mutes.php +++ b/mutes.php @@ -33,7 +33,7 @@ - + - +