From 4bdf9d558a0a32c0be4bf51a1b6ea4790706773d Mon Sep 17 00:00:00 2001 From: kremsy Date: Tue, 24 Dec 2013 13:27:59 +0100 Subject: [PATCH] clean nickname of players --- application/core/Formatter.php | 11 ++++++++++- application/core/Players/Player.php | 3 ++- application/core/Players/PlayerList.php | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/application/core/Formatter.php b/application/core/Formatter.php index 2c823d1a..7735b92a 100644 --- a/application/core/Formatter.php +++ b/application/core/Formatter.php @@ -52,6 +52,15 @@ abstract class Formatter { return date("Y-m-d H:i:s", $seconds); } + /** + * Strip all codes except colors from the string + */ + public static function stripCodesWithoutColors($string) { + $string = preg_replace('/(?pid = $rpcInfos['PlayerId']; $this->login = $rpcInfos['Login']; - $this->nickname = $rpcInfos['NickName']; + $this->nickname = Formatter::stripCodesWithoutColors($rpcInfos['NickName']); $this->path = $rpcInfos['Path']; $this->language = $rpcInfos['Language']; $this->avatar = $rpcInfos['Avatar']['FileName']; diff --git a/application/core/Players/PlayerList.php b/application/core/Players/PlayerList.php index 03120ba2..1d1e5574 100644 --- a/application/core/Players/PlayerList.php +++ b/application/core/Players/PlayerList.php @@ -18,6 +18,7 @@ use FML\Script\Tooltips; use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; +use ManiaControl\Formatter; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkPageAnswerListener; @@ -135,6 +136,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener { $i = 1; $y -= 10; foreach($players as $listPlayer){ + //$path = substr($listPlayer->path, 6); //$path = $listPlayer->getCountry() . " - " . $listPlayer->getProvince(); $path = $listPlayer->getProvince();