diff --git a/core/Admin/ActionsMenu.php b/core/Admin/ActionsMenu.php index ead9b954..7b6fbd90 100644 --- a/core/Admin/ActionsMenu.php +++ b/core/Admin/ActionsMenu.php @@ -10,6 +10,8 @@ use FML\Controls\Quads\Quad_Icons64x64_1; use FML\ManiaLink; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\Callbacks; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; @@ -22,7 +24,9 @@ use ManiaControl\Players\PlayerManager; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { +class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ @@ -124,8 +128,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener { $itemMarginFactorY = 1.2; // If game is shootmania lower the icons position by 20 - if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'sm' - ) { + if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'sm') { $posY -= $shootManiaOffset; } diff --git a/core/Admin/AdminLists.php b/core/Admin/AdminLists.php index e2b2df6f..d035ec3d 100644 --- a/core/Admin/AdminLists.php +++ b/core/Admin/AdminLists.php @@ -13,6 +13,8 @@ use FML\Script\Features\Paging; use FML\Script\Script; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkPageAnswerListener; @@ -25,7 +27,9 @@ use ManiaControl\Players\Player; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class AdminLists implements ManialinkPageAnswerListener, CallbackListener { +class AdminLists implements ManialinkPageAnswerListener, CallbackListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Admin/AuthCommands.php b/core/Admin/AuthCommands.php index caa9354c..49618967 100644 --- a/core/Admin/AuthCommands.php +++ b/core/Admin/AuthCommands.php @@ -3,6 +3,8 @@ namespace ManiaControl\Admin; use ManiaControl\Commands\CommandListener; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; @@ -13,7 +15,9 @@ use ManiaControl\Players\Player; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class AuthCommands implements CommandListener { +class AuthCommands implements CommandListener, UsageInformationAble { + use UsageInformationTrait; + /* * Private properties */ diff --git a/core/Admin/AuthenticationManager.php b/core/Admin/AuthenticationManager.php index 8b7094c5..343d4417 100644 --- a/core/Admin/AuthenticationManager.php +++ b/core/Admin/AuthenticationManager.php @@ -8,6 +8,8 @@ use ManiaControl\Callbacks\EchoListener; use ManiaControl\Communication\CommunicationAnswer; use ManiaControl\Communication\CommunicationListener; use ManiaControl\Communication\CommunicationMethods; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; @@ -21,7 +23,9 @@ use ManiaControl\Settings\Setting; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class AuthenticationManager implements CallbackListener, EchoListener, CommunicationListener { +class AuthenticationManager implements CallbackListener, EchoListener, CommunicationListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Bills/BillManager.php b/core/Bills/BillManager.php index 6113acaf..1bbe9d7c 100644 --- a/core/Bills/BillManager.php +++ b/core/Bills/BillManager.php @@ -4,6 +4,8 @@ namespace ManiaControl\Bills; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use Maniaplanet\DedicatedServer\InvalidArgumentException; @@ -16,7 +18,9 @@ use Maniaplanet\DedicatedServer\Structures\Bill; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class BillManager implements CallbackListener { +class BillManager implements CallbackListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Callbacks/CallbackManager.php b/core/Callbacks/CallbackManager.php index e8ac4295..023dd85f 100644 --- a/core/Callbacks/CallbackManager.php +++ b/core/Callbacks/CallbackManager.php @@ -3,6 +3,8 @@ namespace ManiaControl\Callbacks; use ManiaControl\Callbacks\Models\BaseCallback; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; /** @@ -12,7 +14,9 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class CallbackManager { +class CallbackManager implements UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Callbacks/EchoManager.php b/core/Callbacks/EchoManager.php index 49af62db..841120d2 100644 --- a/core/Callbacks/EchoManager.php +++ b/core/Callbacks/EchoManager.php @@ -3,6 +3,8 @@ namespace ManiaControl\Callbacks; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; /** @@ -12,7 +14,9 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class EchoManager implements CallbackListener, EchoListener { +class EchoManager implements CallbackListener, EchoListener, UsageInformationAble { + use UsageInformationTrait; + /* * Private properties */ diff --git a/core/Callbacks/Listening.php b/core/Callbacks/Listening.php index ab56e5ff..09f0668b 100644 --- a/core/Callbacks/Listening.php +++ b/core/Callbacks/Listening.php @@ -2,6 +2,9 @@ namespace ManiaControl\Callbacks; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; + /** * Model Class for a Basic Listening * @@ -9,12 +12,14 @@ namespace ManiaControl\Callbacks; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Listening { +class Listening implements UsageInformationAble { + use UsageInformationTrait; + /* * Public Properties */ public $listener = null; - public $method = null; + public $method = null; /** * Construct a new Timer Listening diff --git a/core/Callbacks/TimerListening.php b/core/Callbacks/TimerListening.php index 19ba27d3..539e00ae 100644 --- a/core/Callbacks/TimerListening.php +++ b/core/Callbacks/TimerListening.php @@ -2,6 +2,9 @@ namespace ManiaControl\Callbacks; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; + /** * Model Class for a Timer Listening * @@ -9,12 +12,14 @@ namespace ManiaControl\Callbacks; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class TimerListening extends Listening { +class TimerListening extends Listening implements UsageInformationAble { + use UsageInformationTrait; + /* * Public Properties */ - public $deltaTime = null; - public $oneTime = null; + public $deltaTime = null; + public $oneTime = null; public $lastTrigger = null; public $instantCall = null; @@ -31,11 +36,11 @@ class TimerListening extends Listening { parent::__construct($listener, $method); $this->deltaTime = $milliSeconds / 1000.; - $this->oneTime = (bool)$oneTime; + $this->oneTime = (bool) $oneTime; if ($this->oneTime) { - $this->lastTrigger = time(true); + $this->lastTrigger = microtime(true); //TODO verify before here was time() } - $this->instantCall = (bool)$instantCall; + $this->instantCall = (bool) $instantCall; if (!$this->instantCall) { $this->lastTrigger = microtime(true); } diff --git a/core/Callbacks/TimerManager.php b/core/Callbacks/TimerManager.php index 6abea5b1..a33984d5 100644 --- a/core/Callbacks/TimerManager.php +++ b/core/Callbacks/TimerManager.php @@ -2,6 +2,8 @@ namespace ManiaControl\Callbacks; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; /** @@ -11,7 +13,9 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class TimerManager { +class TimerManager implements UsageInformationAble { + use UsageInformationTrait; + /* * Private properties */ diff --git a/core/Chat.php b/core/Chat.php index e023df79..f50e542c 100644 --- a/core/Chat.php +++ b/core/Chat.php @@ -8,6 +8,8 @@ use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Communication\CommunicationAnswer; use ManiaControl\Communication\CommunicationListener; use ManiaControl\Communication\CommunicationMethods; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Players\Player; use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; @@ -18,7 +20,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Chat implements CallbackListener, CommunicationListener { +class Chat implements CallbackListener, CommunicationListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Commands/CommandManager.php b/core/Commands/CommandManager.php index 49ab7faf..9cb27c53 100644 --- a/core/Commands/CommandManager.php +++ b/core/Commands/CommandManager.php @@ -5,6 +5,8 @@ namespace ManiaControl\Commands; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\Listening; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; /** @@ -14,7 +16,9 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class CommandManager implements CallbackListener { +class CommandManager implements CallbackListener, UsageInformationAble { + use UsageInformationTrait; + /* * Private properties */ @@ -215,6 +219,6 @@ class CommandManager implements CallbackListener { * @return bool */ private function isCommandMessage(array $chatCallback) { - return (bool)$chatCallback[1][3]; + return (bool) $chatCallback[1][3]; } } diff --git a/core/Communication/Communication.php b/core/Communication/Communication.php index c9e228ab..76b20b33 100644 --- a/core/Communication/Communication.php +++ b/core/Communication/Communication.php @@ -4,7 +4,7 @@ namespace ManiaControl\Communication; /** * Class for Communicating with other ManiaControls - * to call @see ManiaControl\Communication\CommunicationManager\createCommunication + * to call @see \ManiaControl\Communication\CommunicationManager::createCommunication() * * @author ManiaControl Team * @copyright 2014-2017 ManiaControl Team diff --git a/core/Communication/CommunicationManager.php b/core/Communication/CommunicationManager.php index c26ab919..cf59cfe0 100644 --- a/core/Communication/CommunicationManager.php +++ b/core/Communication/CommunicationManager.php @@ -1,9 +1,12 @@ on('data', function ($data) use (&$buffer, &$connection, $password) { $buffer .= $data; - $arr = explode("\n", $buffer, 2); + $arr = explode("\n", $buffer, 2); while (count($arr) == 2 && strlen($arr[1]) >= (int) $arr[0]) { // received full message $len = (int) $arr[0]; diff --git a/core/Files/AsyncHttpRequest.php b/core/Files/AsyncHttpRequest.php index e0fd3268..0826a234 100644 --- a/core/Files/AsyncHttpRequest.php +++ b/core/Files/AsyncHttpRequest.php @@ -4,6 +4,8 @@ namespace ManiaControl\Files; use cURL\Event; use cURL\Request; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; /** @@ -13,7 +15,8 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class AsyncHttpRequest { +class AsyncHttpRequest implements UsageInformationAble { + use UsageInformationTrait; /* * Constants */ @@ -183,7 +186,7 @@ class AsyncHttpRequest { * @return $this */ public function setHeaders($headers) { - if(is_array($headers)){ + if (is_array($headers)) { $this->headers = $headers; } return $this; diff --git a/core/Files/AsynchronousFileReader.php b/core/Files/AsynchronousFileReader.php index a671df32..712077df 100644 --- a/core/Files/AsynchronousFileReader.php +++ b/core/Files/AsynchronousFileReader.php @@ -3,6 +3,8 @@ namespace ManiaControl\Files; use cURL\Request; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; /** @@ -12,7 +14,9 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class AsynchronousFileReader { +class AsynchronousFileReader implements UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Logger.php b/core/Logger.php index a915d4f0..ac9f8006 100644 --- a/core/Logger.php +++ b/core/Logger.php @@ -3,6 +3,8 @@ namespace ManiaControl; use ManiaControl\Files\FileUtil; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Utils\Formatter; /** @@ -12,7 +14,8 @@ use ManiaControl\Utils\Formatter; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class Logger { +abstract class Logger implements UsageInformationAble { + use UsageInformationTrait; /** * Setup the logging mechanism diff --git a/core/ManiaExchange/ManiaExchangeManager.php b/core/ManiaExchange/ManiaExchangeManager.php index 6743289a..d7e78d06 100644 --- a/core/ManiaExchange/ManiaExchangeManager.php +++ b/core/ManiaExchange/ManiaExchangeManager.php @@ -3,6 +3,8 @@ namespace ManiaControl\ManiaExchange; use ManiaControl\Files\AsynchronousFileReader; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Maps\Map; use ManiaControl\Maps\MapManager; @@ -14,7 +16,9 @@ use ManiaControl\Maps\MapManager; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ManiaExchangeManager { +class ManiaExchangeManager implements UsageInformationAble { + use UsageInformationTrait; + /* * Constants * @deprecated SEARCH Constants diff --git a/core/ManiaExchange/ManiaExchangeMapSearch.php b/core/ManiaExchange/ManiaExchangeMapSearch.php index a37f311c..a2ccd979 100644 --- a/core/ManiaExchange/ManiaExchangeMapSearch.php +++ b/core/ManiaExchange/ManiaExchangeMapSearch.php @@ -1,7 +1,10 @@ url = 'https://' . $this->titlePrefix . '.mania-exchange.com/tracksearch2/search?api=on'; - if($key = $this->maniaControl->getSettingManager()->getSettingValue($this, ManiaExchangeManager::SETTING_MX_KEY)){ + if ($key = $this->maniaControl->getSettingManager()->getSettingValue($this, ManiaExchangeManager::SETTING_MX_KEY)) { $this->url .= "&key=" . $key; } @@ -228,7 +233,7 @@ class ManiaExchangeMapSearch { } $mxMapList = $mxMapList->results; - + if ($mxMapList === null) { trigger_error('Cannot decode searched JSON data'); return; diff --git a/core/Manialinks/CustomUIManager.php b/core/Manialinks/CustomUIManager.php index 959ed128..5f310030 100644 --- a/core/Manialinks/CustomUIManager.php +++ b/core/Manialinks/CustomUIManager.php @@ -5,6 +5,8 @@ namespace ManiaControl\Manialinks; use FML\CustomUI; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\TimerListener; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; @@ -16,7 +18,9 @@ use ManiaControl\Players\PlayerManager; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class CustomUIManager implements CallbackListener, TimerListener { +class CustomUIManager implements CallbackListener, TimerListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Manialinks/IconManager.php b/core/Manialinks/IconManager.php index cfdea67e..2ec6e99c 100644 --- a/core/Manialinks/IconManager.php +++ b/core/Manialinks/IconManager.php @@ -7,6 +7,8 @@ use FML\Controls\Quad; use FML\ManiaLink; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\Callbacks; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; @@ -18,7 +20,9 @@ use ManiaControl\Players\PlayerManager; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class IconManager implements CallbackListener { +class IconManager implements CallbackListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index 0de72303..c90cfcfb 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -8,6 +8,8 @@ use FML\Controls\Labels\Label_Text; use FML\ManiaLink; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; @@ -23,7 +25,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener { +class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Manialinks/StyleManager.php b/core/Manialinks/StyleManager.php index bcfa9378..e936733e 100644 --- a/core/Manialinks/StyleManager.php +++ b/core/Manialinks/StyleManager.php @@ -11,6 +11,8 @@ use FML\Controls\Quads\Quad_Bgs1InRace; use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Script\Features\Paging; use FML\Script\Script; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; /** @@ -20,7 +22,9 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class StyleManager { +class StyleManager implements UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ @@ -162,8 +166,7 @@ class StyleManager { $frame->setSize($width, $height)->setZ(45); //TODO place before scoreboards //TODO remove: (just temporary fix for tm bug) - if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'tm' - ) { + if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'tm') { $frame->setSize($width, $height)->setZ(32); } diff --git a/core/Maps/Map.php b/core/Maps/Map.php index f1215e7a..28c6a8b8 100644 --- a/core/Maps/Map.php +++ b/core/Maps/Map.php @@ -4,6 +4,8 @@ namespace ManiaControl\Maps; use ManiaControl\General\Dumpable; use ManiaControl\General\DumpTrait; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaExchange\MXMapInfo; use ManiaControl\Utils\Formatter; @@ -14,8 +16,8 @@ use ManiaControl\Utils\Formatter; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Map implements Dumpable { - use DumpTrait; +class Map implements Dumpable, UsageInformationAble { + use DumpTrait, UsageInformationTrait; /* * Public properties diff --git a/core/Maps/MapActions.php b/core/Maps/MapActions.php index 8e537cad..d7c40d3a 100644 --- a/core/Maps/MapActions.php +++ b/core/Maps/MapActions.php @@ -5,6 +5,8 @@ namespace ManiaControl\Maps; use ManiaControl\Communication\CommunicationAnswer; use ManiaControl\Communication\CommunicationListener; use ManiaControl\Communication\CommunicationMethods; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException; @@ -15,7 +17,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class MapActions implements CommunicationListener { +class MapActions implements CommunicationListener, UsageInformationAble { + use UsageInformationTrait; + /* * Private properties */ diff --git a/core/Maps/MapManager.php b/core/Maps/MapManager.php index 652f345b..cf331d33 100644 --- a/core/Maps/MapManager.php +++ b/core/Maps/MapManager.php @@ -10,6 +10,8 @@ use ManiaControl\Communication\CommunicationAnswer; use ManiaControl\Communication\CommunicationListener; use ManiaControl\Communication\CommunicationMethods; use ManiaControl\Files\FileUtil; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\ManiaExchange\ManiaExchangeList; @@ -33,7 +35,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnavailableFeatureException; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class MapManager implements CallbackListener, CommunicationListener { +class MapManager implements CallbackListener, CommunicationListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ @@ -427,7 +431,7 @@ class MapManager implements CallbackListener, CommunicationListener { return; } throw $e; - } catch(FileException $e){ + } catch (FileException $e) { $this->maniaControl->getChat()->sendError("Could not write file", $login); return; } diff --git a/core/Maps/MapQueue.php b/core/Maps/MapQueue.php index 2958c218..5f0eceb0 100644 --- a/core/Maps/MapQueue.php +++ b/core/Maps/MapQueue.php @@ -6,6 +6,8 @@ use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\Callbacks; use ManiaControl\Commands\CommandListener; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; @@ -20,7 +22,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\NotInListException; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class MapQueue implements CallbackListener, CommandListener { +class MapQueue implements CallbackListener, CommandListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Players/Player.php b/core/Players/Player.php index 77767131..3460dc16 100644 --- a/core/Players/Player.php +++ b/core/Players/Player.php @@ -4,6 +4,8 @@ namespace ManiaControl\Players; use ManiaControl\General\Dumpable; use ManiaControl\General\DumpTrait; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Utils\ClassUtil; use ManiaControl\Utils\Formatter; @@ -16,8 +18,8 @@ use Maniaplanet\DedicatedServer\Structures\LadderStats; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Player implements Dumpable { - use DumpTrait; +class Player implements Dumpable, UsageInformationAble { + use DumpTrait, UsageInformationTrait; /* * Public Properties @@ -349,7 +351,7 @@ class Player implements Dumpable { } return false; } - + /** * Var_Dump the Players Cache */ diff --git a/core/Players/PlayerActions.php b/core/Players/PlayerActions.php index b6e9f5cb..98af0152 100644 --- a/core/Players/PlayerActions.php +++ b/core/Players/PlayerActions.php @@ -12,6 +12,8 @@ use ManiaControl\Callbacks\EchoListener; use ManiaControl\Communication\CommunicationAnswer; use ManiaControl\Communication\CommunicationListener; use ManiaControl\Communication\CommunicationMethods; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkManager; @@ -30,7 +32,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class PlayerActions implements EchoListener, CommunicationListener { +class PlayerActions implements EchoListener, CommunicationListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Players/PlayerDataManager.php b/core/Players/PlayerDataManager.php index 4673c29b..cff16b90 100644 --- a/core/Players/PlayerDataManager.php +++ b/core/Players/PlayerDataManager.php @@ -3,6 +3,8 @@ namespace ManiaControl\Players; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Utils\ClassUtil; @@ -13,7 +15,9 @@ use ManiaControl\Utils\ClassUtil; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class PlayerDataManager { +class PlayerDataManager implements UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ @@ -31,8 +35,8 @@ class PlayerDataManager { */ /** @var ManiaControl $maniaControl */ private $maniaControl = null; - private $metaData = array(); - private $storedData = array(); + private $metaData = array(); + private $storedData = array(); /** * Construct a new player manager instance @@ -318,7 +322,7 @@ class PlayerDataManager { private function getMetaDataId($className, $statName) { if (isset($this->metaData[$className . $statName])) { $stat = $this->metaData[$className . $statName]; - return (int)$stat->dataId; + return (int) $stat->dataId; } return null; } @@ -332,16 +336,16 @@ class PlayerDataManager { */ private function castSetting($type, $value) { if ($type === self::TYPE_INT) { - return (int)$value; + return (int) $value; } if ($type === self::TYPE_REAL) { - return (float)$value; + return (float) $value; } if ($type === self::TYPE_BOOL) { - return (bool)$value; + return (bool) $value; } if ($type === self::TYPE_STRING) { - return (string)$value; + return (string) $value; } if ($type === self::TYPE_ARRAY) { return explode(self::ARRAY_DELIMITER, $value); diff --git a/core/Players/PlayerManager.php b/core/Players/PlayerManager.php index 82277dde..f8ab429d 100644 --- a/core/Players/PlayerManager.php +++ b/core/Players/PlayerManager.php @@ -10,6 +10,8 @@ use ManiaControl\Callbacks\TimerListener; use ManiaControl\Communication\CommunicationAnswer; use ManiaControl\Communication\CommunicationListener; use ManiaControl\Communication\CommunicationMethods; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Statistics\StatisticManager; @@ -23,7 +25,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class PlayerManager implements CallbackListener, TimerListener, CommunicationListener { +class PlayerManager implements CallbackListener, TimerListener, CommunicationListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Script/ModeScriptEventManager.php b/core/Script/ModeScriptEventManager.php index 3644c685..898d541f 100644 --- a/core/Script/ModeScriptEventManager.php +++ b/core/Script/ModeScriptEventManager.php @@ -6,11 +6,16 @@ * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ + namespace ManiaControl\Script; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; -class ModeScriptEventManager { +class ModeScriptEventManager implements UsageInformationAble { + use UsageInformationTrait; + const API_VERSION = "2.0.0"; /** @var ManiaControl $maniaControl */ @@ -49,19 +54,20 @@ class ModeScriptEventManager { * @param string $responseId * Triggers a Callback List Callback */ - public function getCallbacksList($responseId = "DefaultResponseId"){ + public function getCallbacksList($responseId = "DefaultResponseId") { $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetCallbacksList', array($responseId)); } /** * Sets the Api Version + * * @param string $version */ - public function setApiVersion($version = self::API_VERSION){ + public function setApiVersion($version = self::API_VERSION) { $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.SetApiVersion', array($version)); } - public function getAllApiVersions($responseId = "DefaultResponseId"){ + public function getAllApiVersions($responseId = "DefaultResponseId") { $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetAllApiVersions', array($responseId)); } } \ No newline at end of file diff --git a/core/Script/ScriptManager.php b/core/Script/ScriptManager.php index a069943a..9619d66f 100644 --- a/core/Script/ScriptManager.php +++ b/core/Script/ScriptManager.php @@ -2,6 +2,8 @@ namespace ManiaControl\Script; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; use ManiaControl\ManiaControl; use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; @@ -13,7 +15,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ScriptManager { +class ScriptManager implements UsageInformationAble { + use UsageInformationTrait; + /* * Private properties */ diff --git a/core/Server/Directory.php b/core/Server/Directory.php index bdb3cc59..29a48b4b 100644 --- a/core/Server/Directory.php +++ b/core/Server/Directory.php @@ -5,6 +5,8 @@ namespace ManiaControl\Server; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Files\FileUtil; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; /** @@ -14,7 +16,9 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Directory implements CallbackListener { +class Directory implements CallbackListener, UsageInformationAble { + use UsageInformationTrait; + /* * Private properties */ diff --git a/core/Server/RankingManager.php b/core/Server/RankingManager.php index 8ff4f22a..de6123b3 100644 --- a/core/Server/RankingManager.php +++ b/core/Server/RankingManager.php @@ -5,6 +5,8 @@ namespace ManiaControl\Server; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\Callbacks; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Maps\Map; use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; @@ -16,7 +18,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class RankingManager implements CallbackListener { +class RankingManager implements CallbackListener, UsageInformationAble { + use UsageInformationTrait; + /* * Private properties */ diff --git a/core/Server/Server.php b/core/Server/Server.php index ad628f17..eddbaf5a 100644 --- a/core/Server/Server.php +++ b/core/Server/Server.php @@ -5,6 +5,8 @@ namespace ManiaControl\Server; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\Callbacks; use ManiaControl\Commands\CommandListener; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; @@ -19,7 +21,9 @@ use Maniaplanet\DedicatedServer\Xmlrpc\Exception; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Server implements CallbackListener, CommandListener { +class Server implements CallbackListener, CommandListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Server/VoteRatiosMenu.php b/core/Server/VoteRatiosMenu.php index 7c85698c..2d0a8ffc 100644 --- a/core/Server/VoteRatiosMenu.php +++ b/core/Server/VoteRatiosMenu.php @@ -118,7 +118,7 @@ class VoteRatiosMenu implements CallbackListener, ConfiguratorMenu, TimerListene } /** - * @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData() + * @see \ManiaControl\Configurator\ConfiguratorMenu::saveConfigData() */ public function saveConfigData(array $configData, Player $player) { if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_VOTE_RATIOS) diff --git a/core/Settings/Setting.php b/core/Settings/Setting.php index b56c3749..4677933d 100644 --- a/core/Settings/Setting.php +++ b/core/Settings/Setting.php @@ -2,6 +2,8 @@ namespace ManiaControl\Settings; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Utils\ClassUtil; /** @@ -11,7 +13,9 @@ use ManiaControl\Utils\ClassUtil; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Setting { +class Setting implements UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ @@ -26,13 +30,13 @@ class Setting { /* * Public properties */ - public $index = null; - public $class = null; - public $setting = null; - public $type = null; - public $value = null; - public $default = null; - public $set = null; + public $index = null; + public $class = null; + public $setting = null; + public $type = null; + public $value = null; + public $default = null; + public $set = null; public $fetchTime = null; /** @@ -54,7 +58,7 @@ class Setting { } else { // Created by Values $this->class = ClassUtil::getClass($object); - $this->setting = (string)$settingName; + $this->setting = (string) $settingName; $this->type = self::getValueType($defaultValue); if ($this->type === self::TYPE_SET) { // Save Set and use first Value as Default @@ -79,16 +83,16 @@ class Setting { $type = self::getValueType($value); } if ($type === self::TYPE_INT) { - return (int)$value; + return (int) $value; } if ($type === self::TYPE_REAL) { - return (float)$value; + return (float) $value; } if ($type === self::TYPE_BOOL) { - return (bool)$value; + return (bool) $value; } if ($type === self::TYPE_STRING) { - return (string)$value; + return (string) $value; } if ($type === self::TYPE_SET) { return explode(self::VALUE_DELIMITER, $value); diff --git a/core/Settings/SettingManager.php b/core/Settings/SettingManager.php index ba53cbd2..3aa63552 100644 --- a/core/Settings/SettingManager.php +++ b/core/Settings/SettingManager.php @@ -4,6 +4,8 @@ namespace ManiaControl\Settings; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\Callbacks; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Plugins\PluginManager; use ManiaControl\Utils\ClassUtil; @@ -15,7 +17,9 @@ use ManiaControl\Utils\ClassUtil; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class SettingManager implements CallbackListener { +class SettingManager implements CallbackListener, UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Statistics/StatisticManager.php b/core/Statistics/StatisticManager.php index e2759a57..034c41f6 100644 --- a/core/Statistics/StatisticManager.php +++ b/core/Statistics/StatisticManager.php @@ -2,6 +2,8 @@ namespace ManiaControl\Statistics; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; @@ -12,7 +14,9 @@ use ManiaControl\Players\Player; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class StatisticManager { +class StatisticManager implements UsageInformationAble { + use UsageInformationTrait; + /* * Constants */ diff --git a/core/Utils/ColorUtil.php b/core/Utils/ColorUtil.php index 5e607f6f..d6e8d458 100644 --- a/core/Utils/ColorUtil.php +++ b/core/Utils/ColorUtil.php @@ -2,6 +2,9 @@ namespace ManiaControl\Utils; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; + /** * Utility Class offering Methods to convert and use ManiaPlanet Colors * @@ -9,7 +12,8 @@ namespace ManiaControl\Utils; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class ColorUtil { +abstract class ColorUtil implements UsageInformationAble { + use UsageInformationTrait; /** * Convert the given float value to a color code from red to green @@ -47,9 +51,9 @@ abstract class ColorUtil { $value = 1.; } $value *= 15.; - $value = (int)round($value); + $value = (int) round($value); if ($value < 10) { - return (string)$value; + return (string) $value; } $codes = array(10 => 'a', 11 => 'b', 12 => 'c', 13 => 'd', 14 => 'e', 15 => 'f'); return $codes[$value]; diff --git a/core/Utils/CommandLineHelper.php b/core/Utils/CommandLineHelper.php index c0bc0eb1..ded80d00 100644 --- a/core/Utils/CommandLineHelper.php +++ b/core/Utils/CommandLineHelper.php @@ -2,6 +2,9 @@ namespace ManiaControl\Utils; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; + /** * Command Line Helper Class * @@ -9,7 +12,8 @@ namespace ManiaControl\Utils; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class CommandLineHelper { +class CommandLineHelper implements UsageInformationAble { + use UsageInformationTrait; /** * Get the command line parameter value with the given name @@ -18,7 +22,7 @@ class CommandLineHelper { * @return string */ public static function getParameter($paramName) { - $paramName = (string)$paramName; + $paramName = (string) $paramName; $params = self::getAllParameters(); foreach ($params as $param) { $parts = explode('=', $param, 2); @@ -40,6 +44,6 @@ class CommandLineHelper { */ public static function getAllParameters() { global $argv; - return (array)$argv; + return (array) $argv; } } diff --git a/core/Utils/Formatter.php b/core/Utils/Formatter.php index a5e70f62..35d36d4a 100644 --- a/core/Utils/Formatter.php +++ b/core/Utils/Formatter.php @@ -2,6 +2,8 @@ namespace ManiaControl\Utils; +use ManiaControl\General\UsageInformationAble; +use ManiaControl\General\UsageInformationTrait; use ManiaControl\Logger; /** @@ -11,7 +13,8 @@ use ManiaControl\Logger; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -abstract class Formatter { +abstract class Formatter implements UsageInformationAble { + use UsageInformationTrait; /** * Return the given Text with Escaping around it @@ -31,47 +34,42 @@ abstract class Formatter { */ public static function formatTime($time) { // TODO: use gmdate() - $time = (int)$time; + $time = (int) $time; $milliseconds = $time % 1000; $seconds = floor($time / 1000); $minutes = floor($seconds / 60); $hours = floor($minutes / 60); - $minutes -= $hours * 60; - $seconds -= $hours * 60 + $minutes * 60; - $format = ($hours > 0 ? $hours . ':' : ''); - $format .= ($hours > 0 && $minutes < 10 ? '0' : '') . $minutes . ':'; - $format .= ($seconds < 10 ? '0' : '') . $seconds . ':'; - $format .= ($milliseconds < 100 ? '0' : '') . ($milliseconds < 10 ? '0' : '') . $milliseconds; + $minutes -= $hours * 60; + $seconds -= $hours * 60 + $minutes * 60; + $format = ($hours > 0 ? $hours . ':' : ''); + $format .= ($hours > 0 && $minutes < 10 ? '0' : '') . $minutes . ':'; + $format .= ($seconds < 10 ? '0' : '') . $seconds . ':'; + $format .= ($milliseconds < 100 ? '0' : '') . ($milliseconds < 10 ? '0' : '') . $milliseconds; return $format; } /** * Format an elapsed time String (2 days ago...) by a given timestamp * - * @param int $time Input time + * @param int $time Input time * @param boolean $short Short version * @return string Formatted elapsed time string */ public static function timeElapsedString($time, $short = false) { $elapsedTime = time() - $time; - $second = $short ? 'sec.' : 'second'; - $minute = $short ? 'min.' : 'minute'; - $hour = $short ? 'h' : 'hour'; - $day = $short ? 'd' : 'day'; - $month = $short ? 'm' : 'month'; - $year = $short ? 'y' : 'year'; + $second = $short ? 'sec.' : 'second'; + $minute = $short ? 'min.' : 'minute'; + $hour = $short ? 'h' : 'hour'; + $day = $short ? 'd' : 'day'; + $month = $short ? 'm' : 'month'; + $year = $short ? 'y' : 'year'; if ($elapsedTime < 1) { return $short ? '0 sec.' : '0 seconds'; } - $calculateSeconds = array(12 * 30 * 24 * 60 * 60 => $year, - 30 * 24 * 60 * 60 => $month, - 24 * 60 * 60 => $day, - 60 * 60 => $hour, - 60 => $minute, - 1 => $second); + $calculateSeconds = array(12 * 30 * 24 * 60 * 60 => $year, 30 * 24 * 60 * 60 => $month, 24 * 60 * 60 => $day, 60 * 60 => $hour, 60 => $minute, 1 => $second); foreach ($calculateSeconds as $secs => $str) { $d = $elapsedTime / $secs; @@ -159,10 +157,35 @@ abstract class Formatter { * @return string */ public static function mapCountry($country) { - $nations = array('Afghanistan' => 'AFG', 'Albania' => 'ALB', 'Algeria' => 'ALG', 'Andorra' => 'AND', 'Angola' => 'ANG', 'Argentina' => 'ARG', 'Armenia' => 'ARM', 'Aruba' => 'ARU', 'Australia' => 'AUS', 'Austria' => 'AUT', 'Azerbaijan' => 'AZE', 'Bahamas' => 'BAH', 'Bahrain' => 'BRN', 'Bangladesh' => 'BAN', 'Barbados' => 'BAR', 'Belarus' => 'BLR', 'Belgium' => 'BEL', 'Belize' => 'BIZ', 'Benin' => 'BEN', 'Bermuda' => 'BER', 'Bhutan' => 'BHU', 'Bolivia' => 'BOL', 'Bosnia&Herzegovina' => 'BIH', 'Botswana' => 'BOT', 'Brazil' => 'BRA', 'Brunei' => 'BRU', 'Bulgaria' => 'BUL', 'Burkina Faso' => 'BUR', 'Burundi' => 'BDI', 'Cambodia' => 'CAM', 'Cameroon' => 'CAR', // actually CMR - 'Canada' => 'CAN', 'Cape Verde' => 'CPV', 'Central African Republic' => 'CAF', 'Chad' => 'CHA', 'Chile' => 'CHI', 'China' => 'CHN', 'Chinese Taipei' => 'TPE', 'Colombia' => 'COL', 'Congo' => 'CGO', 'Costa Rica' => 'CRC', 'Croatia' => 'CRO', 'Cuba' => 'CUB', 'Cyprus' => 'CYP', 'Czech Republic' => 'CZE', 'Czech republic' => 'CZE', 'DR Congo' => 'COD', 'Denmark' => 'DEN', 'Djibouti' => 'DJI', 'Dominica' => 'DMA', 'Dominican Republic' => 'DOM', 'Ecuador' => 'ECU', 'Egypt' => 'EGY', 'El Salvador' => 'ESA', 'Eritrea' => 'ERI', 'Estonia' => 'EST', 'Ethiopia' => 'ETH', 'Fiji' => 'FIJ', 'Finland' => 'FIN', 'France' => 'FRA', 'Gabon' => 'GAB', 'Gambia' => 'GAM', 'Georgia' => 'GEO', 'Germany' => 'GER', 'Ghana' => 'GHA', 'Greece' => 'GRE', 'Grenada' => 'GRN', 'Guam' => 'GUM', 'Guatemala' => 'GUA', 'Guinea' => 'GUI', 'Guinea-Bissau' => 'GBS', 'Guyana' => 'GUY', 'Haiti' => 'HAI', 'Honduras' => 'HON', 'Hong Kong' => 'HKG', 'Hungary' => 'HUN', 'Iceland' => 'ISL', 'India' => 'IND', 'Indonesia' => 'INA', 'Iran' => 'IRI', 'Iraq' => 'IRQ', 'Ireland' => 'IRL', 'Israel' => 'ISR', 'Italy' => 'ITA', 'Ivory Coast' => 'CIV', 'Jamaica' => 'JAM', 'Japan' => 'JPN', 'Jordan' => 'JOR', 'Kazakhstan' => 'KAZ', 'Kenya' => 'KEN', 'Kiribati' => 'KIR', 'Korea' => 'KOR', 'Kuwait' => 'KUW', 'Kyrgyzstan' => 'KGZ', 'Laos' => 'LAO', 'Latvia' => 'LAT', 'Lebanon' => 'LIB', 'Lesotho' => 'LES', 'Liberia' => 'LBR', 'Libya' => 'LBA', 'Liechtenstein' => 'LIE', 'Lithuania' => 'LTU', 'Luxembourg' => 'LUX', 'Macedonia' => 'MKD', 'Malawi' => 'MAW', 'Malaysia' => 'MAS', 'Mali' => 'MLI', 'Malta' => 'MLT', 'Mauritania' => 'MTN', 'Mauritius' => 'MRI', 'Mexico' => 'MEX', 'Moldova' => 'MDA', 'Monaco' => 'MON', 'Mongolia' => 'MGL', 'Montenegro' => 'MNE', 'Morocco' => 'MAR', 'Mozambique' => 'MOZ', 'Myanmar' => 'MYA', 'Namibia' => 'NAM', 'Nauru' => 'NRU', 'Nepal' => 'NEP', 'Netherlands' => 'NED', 'New Zealand' => 'NZL', 'Nicaragua' => 'NCA', 'Niger' => 'NIG', 'Nigeria' => 'NGR', 'Norway' => 'NOR', 'Oman' => 'OMA', 'Other Countries' => 'OTH', 'Pakistan' => 'PAK', 'Palau' => 'PLW', 'Palestine' => 'PLE', 'Panama' => 'PAN', 'Paraguay' => 'PAR', 'Peru' => 'PER', 'Philippines' => 'PHI', 'Poland' => 'POL', 'Portugal' => 'POR', 'Puerto Rico' => 'PUR', 'Qatar' => 'QAT', 'Romania' => 'ROM', // actually ROU - 'Russia' => 'RUS', 'Rwanda' => 'RWA', 'Samoa' => 'SAM', 'San Marino' => 'SMR', 'Saudi Arabia' => 'KSA', 'Senegal' => 'SEN', 'Serbia' => 'SCG', // actually SRB - 'Sierra Leone' => 'SLE', 'Singapore' => 'SIN', 'Slovakia' => 'SVK', 'Slovenia' => 'SLO', 'Somalia' => 'SOM', 'South Africa' => 'RSA', 'Spain' => 'ESP', 'Sri Lanka' => 'SRI', 'Sudan' => 'SUD', 'Suriname' => 'SUR', 'Swaziland' => 'SWZ', 'Sweden' => 'SWE', 'Switzerland' => 'SUI', 'Syria' => 'SYR', 'Taiwan' => 'TWN', 'Tajikistan' => 'TJK', 'Tanzania' => 'TAN', 'Thailand' => 'THA', 'Togo' => 'TOG', 'Tonga' => 'TGA', 'Trinidad and Tobago' => 'TRI', 'Tunisia' => 'TUN', 'Turkey' => 'TUR', 'Turkmenistan' => 'TKM', 'Tuvalu' => 'TUV', 'Uganda' => 'UGA', 'Ukraine' => 'UKR', 'United Arab Emirates' => 'UAE', 'United Kingdom' => 'GBR', 'United States of America' => 'USA', 'Uruguay' => 'URU', 'Uzbekistan' => 'UZB', 'Vanuatu' => 'VAN', 'Venezuela' => 'VEN', 'Vietnam' => 'VIE', 'Yemen' => 'YEM', 'Zambia' => 'ZAM', 'Zimbabwe' => 'ZIM'); + $nations = array('Afghanistan' => 'AFG', 'Albania' => 'ALB', 'Algeria' => 'ALG', 'Andorra' => 'AND', 'Angola' => 'ANG', 'Argentina' => 'ARG', 'Armenia' => 'ARM', 'Aruba' => 'ARU', + 'Australia' => 'AUS', 'Austria' => 'AUT', 'Azerbaijan' => 'AZE', 'Bahamas' => 'BAH', 'Bahrain' => 'BRN', 'Bangladesh' => 'BAN', 'Barbados' => 'BAR', + 'Belarus' => 'BLR', 'Belgium' => 'BEL', 'Belize' => 'BIZ', 'Benin' => 'BEN', 'Bermuda' => 'BER', 'Bhutan' => 'BHU', 'Bolivia' => 'BOL', + 'Bosnia&Herzegovina' => 'BIH', 'Botswana' => 'BOT', 'Brazil' => 'BRA', 'Brunei' => 'BRU', 'Bulgaria' => 'BUL', 'Burkina Faso' => 'BUR', 'Burundi' => 'BDI', + 'Cambodia' => 'CAM', 'Cameroon' => 'CAR', // actually CMR + 'Canada' => 'CAN', 'Cape Verde' => 'CPV', 'Central African Republic' => 'CAF', 'Chad' => 'CHA', 'Chile' => 'CHI', 'China' => 'CHN', + 'Chinese Taipei' => 'TPE', 'Colombia' => 'COL', 'Congo' => 'CGO', 'Costa Rica' => 'CRC', 'Croatia' => 'CRO', 'Cuba' => 'CUB', 'Cyprus' => 'CYP', + 'Czech Republic' => 'CZE', 'Czech republic' => 'CZE', 'DR Congo' => 'COD', 'Denmark' => 'DEN', 'Djibouti' => 'DJI', 'Dominica' => 'DMA', + 'Dominican Republic' => 'DOM', 'Ecuador' => 'ECU', 'Egypt' => 'EGY', 'El Salvador' => 'ESA', 'Eritrea' => 'ERI', 'Estonia' => 'EST', 'Ethiopia' => 'ETH', + 'Fiji' => 'FIJ', 'Finland' => 'FIN', 'France' => 'FRA', 'Gabon' => 'GAB', 'Gambia' => 'GAM', 'Georgia' => 'GEO', 'Germany' => 'GER', 'Ghana' => 'GHA', + 'Greece' => 'GRE', 'Grenada' => 'GRN', 'Guam' => 'GUM', 'Guatemala' => 'GUA', 'Guinea' => 'GUI', 'Guinea-Bissau' => 'GBS', 'Guyana' => 'GUY', + 'Haiti' => 'HAI', 'Honduras' => 'HON', 'Hong Kong' => 'HKG', 'Hungary' => 'HUN', 'Iceland' => 'ISL', 'India' => 'IND', 'Indonesia' => 'INA', + 'Iran' => 'IRI', 'Iraq' => 'IRQ', 'Ireland' => 'IRL', 'Israel' => 'ISR', 'Italy' => 'ITA', 'Ivory Coast' => 'CIV', 'Jamaica' => 'JAM', 'Japan' => 'JPN', + 'Jordan' => 'JOR', 'Kazakhstan' => 'KAZ', 'Kenya' => 'KEN', 'Kiribati' => 'KIR', 'Korea' => 'KOR', 'Kuwait' => 'KUW', 'Kyrgyzstan' => 'KGZ', 'Laos' => 'LAO', + 'Latvia' => 'LAT', 'Lebanon' => 'LIB', 'Lesotho' => 'LES', 'Liberia' => 'LBR', 'Libya' => 'LBA', 'Liechtenstein' => 'LIE', 'Lithuania' => 'LTU', + 'Luxembourg' => 'LUX', 'Macedonia' => 'MKD', 'Malawi' => 'MAW', 'Malaysia' => 'MAS', 'Mali' => 'MLI', 'Malta' => 'MLT', 'Mauritania' => 'MTN', + 'Mauritius' => 'MRI', 'Mexico' => 'MEX', 'Moldova' => 'MDA', 'Monaco' => 'MON', 'Mongolia' => 'MGL', 'Montenegro' => 'MNE', 'Morocco' => 'MAR', + 'Mozambique' => 'MOZ', 'Myanmar' => 'MYA', 'Namibia' => 'NAM', 'Nauru' => 'NRU', 'Nepal' => 'NEP', 'Netherlands' => 'NED', 'New Zealand' => 'NZL', + 'Nicaragua' => 'NCA', 'Niger' => 'NIG', 'Nigeria' => 'NGR', 'Norway' => 'NOR', 'Oman' => 'OMA', 'Other Countries' => 'OTH', 'Pakistan' => 'PAK', + 'Palau' => 'PLW', 'Palestine' => 'PLE', 'Panama' => 'PAN', 'Paraguay' => 'PAR', 'Peru' => 'PER', 'Philippines' => 'PHI', 'Poland' => 'POL', + 'Portugal' => 'POR', 'Puerto Rico' => 'PUR', 'Qatar' => 'QAT', 'Romania' => 'ROM', // actually ROU + 'Russia' => 'RUS', 'Rwanda' => 'RWA', 'Samoa' => 'SAM', 'San Marino' => 'SMR', 'Saudi Arabia' => 'KSA', 'Senegal' => 'SEN', 'Serbia' => 'SCG', + // actually SRB + 'Sierra Leone' => 'SLE', 'Singapore' => 'SIN', 'Slovakia' => 'SVK', 'Slovenia' => 'SLO', 'Somalia' => 'SOM', 'South Africa' => 'RSA', 'Spain' => 'ESP', + 'Sri Lanka' => 'SRI', 'Sudan' => 'SUD', 'Suriname' => 'SUR', 'Swaziland' => 'SWZ', 'Sweden' => 'SWE', 'Switzerland' => 'SUI', 'Syria' => 'SYR', + 'Taiwan' => 'TWN', 'Tajikistan' => 'TJK', 'Tanzania' => 'TAN', 'Thailand' => 'THA', 'Togo' => 'TOG', 'Tonga' => 'TGA', 'Trinidad and Tobago' => 'TRI', + 'Tunisia' => 'TUN', 'Turkey' => 'TUR', 'Turkmenistan' => 'TKM', 'Tuvalu' => 'TUV', 'Uganda' => 'UGA', 'Ukraine' => 'UKR', 'United Arab Emirates' => 'UAE', + 'United Kingdom' => 'GBR', 'United States of America' => 'USA', 'Uruguay' => 'URU', 'Uzbekistan' => 'UZB', 'Vanuatu' => 'VAN', 'Venezuela' => 'VEN', + 'Vietnam' => 'VIE', 'Yemen' => 'YEM', 'Zambia' => 'ZAM', 'Zimbabwe' => 'ZIM'); if (array_key_exists($country, $nations)) { return $nations[$country]; } diff --git a/core/Utils/WebReader.php b/core/Utils/WebReader.php index 5ca98395..89eb2d47 100644 --- a/core/Utils/WebReader.php +++ b/core/Utils/WebReader.php @@ -9,6 +9,7 @@ use ManiaControl\ManiaControl; /** * Reader Utility Class for efficient Web Requests * + * @see \ManiaControl\Files\AsyncHttpRequest For Asynchron Requests * @author ManiaControl Team * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 @@ -51,12 +52,12 @@ abstract class WebReader { protected static function newRequest($url) { $request = new Request($url); $options = $request->getOptions(); - $options->set(CURLOPT_TIMEOUT, 5) // timeout - ->set(CURLOPT_HEADER, false) // don't display response header - ->set(CURLOPT_CRLF, true) // linux line feed - ->set(CURLOPT_ENCODING, '') // accept encoding - ->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION) // user-agent - ->set(CURLOPT_RETURNTRANSFER, true) // return instead of output content + $options->set(CURLOPT_TIMEOUT, 5)// timeout + ->set(CURLOPT_HEADER, false)// don't display response header + ->set(CURLOPT_CRLF, true)// linux line feed + ->set(CURLOPT_ENCODING, '')// accept encoding + ->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION)// user-agent + ->set(CURLOPT_RETURNTRANSFER, true)// return instead of output content ->set(CURLOPT_AUTOREFERER, true); // follow redirects return $request; }