diff --git a/ManiaControl.php b/ManiaControl.php index 0b4e7035..2fbfe8ae 100644 --- a/ManiaControl.php +++ b/ManiaControl.php @@ -11,7 +11,7 @@ error_reporting(E_ALL); // Run configuration -define('DEV_MODE', true); // Development mode to not send error reports etc. +define('DEV_MODE', false); // Development mode to not send error reports etc. define('LOG_NAME_USE_DATE', true); // Use current date as suffix for log file name in logs folder define('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder diff --git a/core/Admin/AdminLists.php b/core/Admin/AdminLists.php index 31d863dc..c49c9fee 100644 --- a/core/Admin/AdminLists.php +++ b/core/Admin/AdminLists.php @@ -149,9 +149,9 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage } $labelLine = new LabelLine($playerFrame); - $labelLine->addLabelEntryText($index, $posX + 5, 13); - $labelLine->addLabelEntryText($admin->nickname, $posX + 18, 52); - $labelLine->addLabelEntryText($admin->login, $posX + 70, 48); + $labelLine->addLabelEntryText($index, $posX + 5,13); + $labelLine->addLabelEntryText($admin->nickname,$posX + 18,52); + $labelLine->addLabelEntryText($admin->login,$posX + 70,48); $labelLine->render(); // Level Quad diff --git a/core/Callbacks/EchoManager.php b/core/Callbacks/EchoManager.php index 841120d2..dcd09bc1 100644 --- a/core/Callbacks/EchoManager.php +++ b/core/Callbacks/EchoManager.php @@ -123,7 +123,6 @@ class EchoManager implements CallbackListener, EchoListener, UsageInformationAbl $params = func_get_args(); $params = array_slice($params, 1, null, true); - //var_dump($params); foreach ($this->echoListenings[$callbackName] as $listening) { /** @var Listening $listening */ $listening->triggerCallbackWithParams($params); diff --git a/core/ErrorHandler.php b/core/ErrorHandler.php index 428b8522..15a98704 100644 --- a/core/ErrorHandler.php +++ b/core/ErrorHandler.php @@ -120,12 +120,14 @@ class ErrorHandler { $report['FileLine'] = self::stripBaseDir($fileLine); } + if ($sourceClass) { $report['SourceClass'] = $sourceClass; $pluginId = PluginManager::getPluginId($sourceClass); if ($pluginId > 0) { $report['PluginId'] = $pluginId; + if ($isFatalError) { $this->maniaControl->getPluginManager()->deactivatePlugin($sourceClass); $this->maniaControl->getChat()->sendError("Plugin " . $sourceClass . " has an Error -> The Plugin will be deactivated and ManiaControl restarted"); diff --git a/core/Files/FileUtil.php b/core/Files/FileUtil.php index b8d1041f..3bfd989b 100644 --- a/core/Files/FileUtil.php +++ b/core/Files/FileUtil.php @@ -4,6 +4,7 @@ namespace ManiaControl\Files; use ManiaControl\Logger; use ManiaControl\Utils\Formatter; +use ManiaControl\Utils\SystemUtil; use ManiaControl\Utils\WebReader; /** @@ -207,4 +208,23 @@ abstract class FileUtil { $extension = substr($fileName, -4); return (strtolower($extension) === '.php'); } + + + /** + * Returns the file name of a path to a PHP file + * + * @param $path + * @return string + */ + public static function getFileName($path) { + $className = ''; + $splitNameSpace = explode(DIRECTORY_SEPARATOR, $path); + if (is_array($splitNameSpace)) { + $className = end($splitNameSpace); + } + + $className = str_replace('.php', '', $className); + + return $className; + } } diff --git a/core/ManiaControl.php b/core/ManiaControl.php index f1821fa1..2ab15cc2 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -63,116 +63,95 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Public properties */ - /** @var ActionsMenu $actionsMenu - * @deprecated - * @see getActionsMenu() - */ - public $actionsMenu = null; - /** @var AuthenticationManager $authenticationManager - * @deprecated - * @see getAuthenticationManager() - */ - public $authenticationManager = null; - /** @var CallbackManager $callbackManager - * @deprecated - * @see getCallbackManager() - */ - public $callbackManager = null; - /** @var Chat $chat - * @deprecated - * @see getChat() - */ - public $chat = null; - /** @var \SimpleXMLElement $config - * @deprecated - * @see getConfig() - */ - public $config = null; - /** @var Configurator $configurator - * @deprecated - * @see getConfigurator() - */ - public $configurator = null; - /** @var Connection $client - * @deprecated - * @see getClient() - */ - public $client = null; - /** @var CommandManager $commandManager - * @deprecated - * @see getCommandManager() - */ - public $commandManager = null; - /** @var Database $database - * @deprecated - * @see getDatabase() - */ - public $database = null; - /** @var ManialinkManager $manialinkManager - * @deprecated - * @see getManialinkManager - */ - public $manialinkManager = null; - /** @var MapManager $mapManager - * @deprecated - * @see getMapManager() - */ - public $mapManager = null; - /** @var PlayerManager $playerManager - * @deprecated - * @see getPlayerManager() - */ - public $playerManager = null; - /** @var PluginManager $pluginManager - * @deprecated - * @see getPluginManager() - */ - public $pluginManager = null; - /** @var Server $server - * @deprecated - * @see getServer() - */ - public $server = null; /** @var SettingManager $settingManager - * @deprecated * @see getSettingManager() + * @deprecated use getSettingManager() */ public $settingManager = null; - /** @var StatisticManager $statisticManager - * @deprecated - * @see getStatisticManager() - */ - public $statisticManager = null; - /** @var UpdateManager $updateManager - * @deprecated - * @see getUpdateManager() - */ - public $updateManager = null; - /** @var ErrorHandler $errorHandler - * @deprecated - * @see getErrorHandler() - */ - public $errorHandler = null; - /** @var TimerManager $timerManager - * @deprecated - * @see getTimerManager() - */ - public $timerManager = null; - /** @var AsynchronousFileReader $fileReader - * @deprecated - * @see getFileReader() - */ - public $fileReader = null; - /** @var BillManager $billManager - * @deprecated - * @see getBillManager() - */ - public $billManager = null; /* * Private properties */ - private $requestQuitMessage = null; + /** @var ActionsMenu $actionsMenu + * @see getActionsMenu() + */ + private $actionsMenu = null; + /** @var AuthenticationManager $authenticationManager + * @see getAuthenticationManager() + */ + private $authenticationManager = null; + /** @var CallbackManager $callbackManager + * @see getCallbackManager() + */ + private $callbackManager = null; + /** @var Chat $chat + * @see getChat() + */ + private $chat = null; + /** @var \SimpleXMLElement $config + * @see getConfig() + */ + private $config = null; + /** @var Configurator $configurator + * @see getConfigurator() + */ + private $configurator = null; + /** @var Connection $client + * @see getClient() + */ + private $client = null; + /** @var CommandManager $commandManager + * @see getCommandManager() + */ + private $commandManager = null; + /** @var Database $database + * @see getDatabase() + */ + private $database = null; + /** @var ManialinkManager $manialinkManager + * @see getManialinkManager + */ + private $manialinkManager = null; + /** @var MapManager $mapManager + * @see getMapManager() + */ + private $mapManager = null; + /** @var PlayerManager $playerManager + * @see getPlayerManager() + */ + private $playerManager = null; + /** @var PluginManager $pluginManager + * @see getPluginManager() + */ + private $pluginManager = null; + /** @var Server $server + * @see getServer() + */ + private $server = null; + /** @var StatisticManager $statisticManager + * @see getStatisticManager() + */ + private $statisticManager = null; + /** @var UpdateManager $updateManager + * @see getUpdateManager() + */ + private $updateManager = null; + /** @var ErrorHandler $errorHandler + * @see getErrorHandler() + */ + private $errorHandler = null; + /** @var TimerManager $timerManager + * @see getTimerManager() + */ + private $timerManager = null; + /** @var AsynchronousFileReader $fileReader + * @see getFileReader() + */ + private $fileReader = null; + /** @var BillManager $billManager + * @see getBillManager() + */ + private $billManager = null; /** @var EchoManager $echoManager */ private $echoManager = null; @@ -185,6 +164,8 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, private $dedicatedServerBuildVersion = ""; + private $requestQuitMessage = null; + /** * Construct a new ManiaControl instance */ diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index 9ce12b8a..49893642 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -35,7 +35,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, const ACTION_CLOSEWIDGET = 'ManiaLinkManager.CloseWidget'; const CB_MAIN_WINDOW_CLOSED = 'ManialinkManagerCallback.MainWindowClosed'; const CB_MAIN_WINDOW_OPENED = 'ManialinkManagerCallback.MainWindowOpened'; - const MAIN_MANIALINK_Z_VALUE = 10; + const MAIN_MANIALINK_Z_VALUE = 20; /* * Public properties diff --git a/core/Maps/MapQueue.php b/core/Maps/MapQueue.php index 5f0eceb0..c1c7ccb2 100644 --- a/core/Maps/MapQueue.php +++ b/core/Maps/MapQueue.php @@ -227,7 +227,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl unset($this->queuedMaps[$map->uid]); } array_unshift($this->queuedMaps, array($player, $map, true)); - $this->maniaControl->callbackManager->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $map)); + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $map)); } } diff --git a/core/Plugins/InstallMenu.php b/core/Plugins/InstallMenu.php index 26c2dd51..0ba48a4b 100644 --- a/core/Plugins/InstallMenu.php +++ b/core/Plugins/InstallMenu.php @@ -74,7 +74,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener { $pageFrame = null; $url = ManiaControl::URL_WEBSERVICE . 'plugins'; - $response = WebReader::getUrl($url); + $response = WebReader::getUrl($url); //TODO async webrequest $dataJson = $response->getContent(); $pluginList = json_decode($dataJson); $index = 0; diff --git a/core/Plugins/PluginManager.php b/core/Plugins/PluginManager.php index 907e5381..ad2ac03f 100644 --- a/core/Plugins/PluginManager.php +++ b/core/Plugins/PluginManager.php @@ -12,6 +12,7 @@ use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Utils\ClassUtil; +use ReflectionClass; /** * Class managing Plugins @@ -119,6 +120,18 @@ class PluginManager { if (!in_array(Plugin::PLUGIN_INTERFACE, $interfaces)) { return false; } + + $reflector = new ReflectionClass($pluginClass); + $className = $pluginClass; + $splitNameSpace = explode('\\', $pluginClass); + if (is_array($splitNameSpace)) { + $className = end($splitNameSpace); + } + if (FileUtil::getFileName($reflector->getFileName()) != $className) { + Logger::logError("Plugin ClassName does not match FileName; Plugin: " . $className); + return false; + } + return true; } @@ -225,6 +238,7 @@ class PluginManager { return false; } $pluginStatement->close(); + return true; } @@ -493,4 +507,12 @@ class PluginManager { $asyncHttpRequest->getData(); } + + /** + * @internal + * @return \ManiaControl\Plugins\InstallMenu + */ + public function getPluginInstallMenu() { + return $this->pluginInstallMenu; + } } diff --git a/core/Update/PluginUpdateManager.php b/core/Update/PluginUpdateManager.php index 38b14501..93485a62 100644 --- a/core/Update/PluginUpdateManager.php +++ b/core/Update/PluginUpdateManager.php @@ -334,7 +334,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis } Logger::log($message); - $this->maniaControl->getConfigurator()->showMenu($player, InstallMenu::getTitle()); + $this->maniaControl->getConfigurator()->showMenu($player, $this->maniaControl->getPluginManager()->getPluginInstallMenu()); } } });