diff --git a/application/core/Database/Database.php b/application/core/Database/Database.php index 0a2c3e32..c37b0244 100644 --- a/application/core/Database/Database.php +++ b/application/core/Database/Database.php @@ -66,35 +66,35 @@ class Database implements TimerListener { private function loadConfig() { $databaseElements = $this->maniaControl->getConfig()->xpath('database'); if (!$databaseElements) { - trigger_error('No Database configured!', E_USER_ERROR); + Logger::logError('No Database configured!', E_USER_ERROR); } $databaseElement = $databaseElements[0]; // Host $hostElements = $databaseElement->xpath('host'); if (!$hostElements) { - trigger_error("Invalid database configuration (Host).", E_USER_ERROR); + Logger::logError("Invalid database configuration (Host).", E_USER_ERROR); } $host = (string)$hostElements[0]; // Port $portElements = $databaseElement->xpath('port'); if (!$portElements) { - trigger_error("Invalid database configuration (Port).", E_USER_ERROR); + Logger::logError("Invalid database configuration (Port).", E_USER_ERROR); } $port = (string)$portElements[0]; // User $userElements = $databaseElement->xpath('user'); if (!$userElements) { - trigger_error("Invalid database configuration (User).", E_USER_ERROR); + Logger::logError("Invalid database configuration (User).", E_USER_ERROR); } $user = (string)$userElements[0]; // Pass $passElements = $databaseElement->xpath('pass'); if (!$passElements) { - trigger_error("Invalid database configuration (Pass).", E_USER_ERROR); + Logger::logError("Invalid database configuration (Pass).", E_USER_ERROR); } $pass = (string)$passElements[0]; @@ -104,7 +104,7 @@ class Database implements TimerListener { $nameElements = $databaseElement->xpath('db_name'); } if (!$nameElements) { - trigger_error("Invalid database configuration (Name).", E_USER_ERROR); + Logger::logError("Invalid database configuration (Name).", E_USER_ERROR); } $name = (string)$nameElements[0]; @@ -157,7 +157,7 @@ class Database implements TimerListener { $showQuery = 'SHOW TABLES;'; $result = $this->getMysqli()->query($showQuery); if ($error = $this->getMysqli()->error) { - trigger_error($error); + Logger::logError($error); return false; } $count = $result->num_rows; @@ -179,7 +179,7 @@ class Database implements TimerListener { $optimizeQuery .= ';'; $this->getMysqli()->query($optimizeQuery); if ($error = $this->getMysqli()->error) { - trigger_error($error); + Logger::logError($error); return false; } return true; diff --git a/application/core/Files/BackupUtil.php b/application/core/Files/BackupUtil.php index 784113a9..ac4e08d0 100644 --- a/application/core/Files/BackupUtil.php +++ b/application/core/Files/BackupUtil.php @@ -2,6 +2,7 @@ namespace ManiaControl\Files; +use ManiaControl\Logger; use ManiaControl\ManiaControl; /** @@ -26,7 +27,7 @@ abstract class BackupUtil { $backupFileName = $backupFolder . 'backup_' . ManiaControl::VERSION . '_' . date('y-m-d_H-i') . '_' . time() . '.zip'; $backupZip = new \ZipArchive(); if ($backupZip->open($backupFileName, \ZipArchive::CREATE) !== true) { - trigger_error("Couldn't create backup zip!"); + Logger::logError("Couldn't create backup zip!"); return false; } $excludes = array(); @@ -47,11 +48,11 @@ abstract class BackupUtil { private static function getBackupFolder() { $backupFolder = ManiaControlDir . 'backup' . DIRECTORY_SEPARATOR; if (!is_dir($backupFolder) && !mkdir($backupFolder)) { - trigger_error("Couldn't create backup folder!"); + Logger::logError("Couldn't create backup folder!"); return false; } if (!is_writeable($backupFolder)) { - trigger_error("ManiaControl doesn't have the necessary write rights for the backup folder!"); + Logger::logError("ManiaControl doesn't have the necessary write rights for the backup folder!"); return false; } return $backupFolder; @@ -71,7 +72,7 @@ abstract class BackupUtil { array $baseFileNames = array()) { $folderHandle = opendir($folderName); if (!is_resource($folderHandle)) { - trigger_error("Couldn't open folder '{$folderName}' for backup!"); + Logger::logError("Couldn't open folder '{$folderName}' for backup!"); return false; } $useBaseFileNames = !empty($baseFileNames); @@ -117,7 +118,7 @@ abstract class BackupUtil { $backupFileName = $backupFolder . 'backup_plugins_' . ManiaControl::VERSION . date('y-m-d_H-i') . '_' . time() . '.zip'; $backupZip = new \ZipArchive(); if ($backupZip->open($backupFileName, \ZipArchive::CREATE) !== true) { - trigger_error("Couldn't create backup zip!"); + Logger::logError("Couldn't create backup zip!"); return false; } $directory = ManiaControlDir . 'plugins'; diff --git a/application/core/Logger.php b/application/core/Logger.php index 90dea095..78f38103 100644 --- a/application/core/Logger.php +++ b/application/core/Logger.php @@ -47,11 +47,11 @@ abstract class Logger { public static function getLogsFolder() { $logsFolder = ManiaControlDir . 'logs' . DIRECTORY_SEPARATOR; if (!is_dir($logsFolder) && !mkdir($logsFolder)) { - trigger_error("Couldn't create the logs folder!"); + self::logError("Couldn't create the logs folder!"); return false; } if (!is_writeable($logsFolder)) { - trigger_error("ManiaControl doesn't have the necessary write rights for the logs folder!"); + self::logError("ManiaControl doesn't have the necessary write rights for the logs folder!"); return false; } return $logsFolder; diff --git a/application/core/Maps/MapManager.php b/application/core/Maps/MapManager.php index 22dd4e06..e7748e91 100644 --- a/application/core/Maps/MapManager.php +++ b/application/core/Maps/MapManager.php @@ -223,8 +223,7 @@ class MapManager implements CallbackListener { $this->updateMapTimestamp($uid); if (!isset($uid) || !isset($this->maps[$uid])) { - trigger_error("Error while updating Map, unknown UID: " . $uid); - $this->maniaControl->getChat()->sendError("Error while updating Map.", $admin); + $this->maniaControl->getChat()->sendError("Error updating Map: Unknown UID '{$uid}'!", $admin); return; } @@ -385,8 +384,7 @@ class MapManager implements CallbackListener { if ($this->maniaControl->getServer()->checkAccess($mapDir)) { // Create download directory if necessary if (!is_dir($downloadDirectory) && !mkdir($downloadDirectory) || !is_writable($downloadDirectory)) { - trigger_error("ManiaControl doesn't have to rights to save maps in '{$downloadDirectory}'."); - $this->maniaControl->getChat()->sendError("ManiaControl doesn't have the rights to save maps.", $login); + $this->maniaControl->getChat()->sendError("ManiaControl doesn't have to rights to save maps in '{$downloadDirectory}'.", $login); return; } @@ -586,9 +584,7 @@ class MapManager implements CallbackListener { $mapArray = array(); foreach ($shuffledMaps as $map) { - /** - * @var Map $map - */ + /** @var Map $map */ $mapArray[] = $map->fileName; } @@ -668,7 +664,7 @@ class MapManager implements CallbackListener { try { $this->maniaControl->getClient()->chooseNextMapList($mapArray); } catch (Exception $e) { - trigger_error("Error while restructuring the Maplist. " . $e->getMessage()); + trigger_error("Error restructuring the Maplist. " . $e->getMessage()); return false; } return true; diff --git a/application/core/Plugins/PluginManager.php b/application/core/Plugins/PluginManager.php index f0af8abf..f0b79de3 100644 --- a/application/core/Plugins/PluginManager.php +++ b/application/core/Plugins/PluginManager.php @@ -5,6 +5,7 @@ namespace ManiaControl\Plugins; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Commands\CommandListener; +use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkPageAnswerListener; @@ -288,7 +289,7 @@ class PluginManager { } $success = include_once $filePath; if (!$success) { - trigger_error("Error loading File '{$filePath}'!"); + Logger::logError("Couldn't load file '{$filePath}'!"); } continue; } diff --git a/application/core/Update/PluginUpdateManager.php b/application/core/Update/PluginUpdateManager.php index fb72758d..b340d9bd 100644 --- a/application/core/Update/PluginUpdateManager.php +++ b/application/core/Update/PluginUpdateManager.php @@ -8,6 +8,7 @@ use ManiaControl\Callbacks\TimerListener; use ManiaControl\Commands\CommandListener; use ManiaControl\Files\BackupUtil; use ManiaControl\Files\FileUtil; +use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use ManiaControl\Plugins\InstallMenu; @@ -268,7 +269,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis if ($player) { $this->maniaControl->getChat()->sendError($message, $player); } - trigger_error($message); + Logger::logError($message); return; } @@ -279,7 +280,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis if ($player) { $this->maniaControl->getChat()->sendError($message, $player); } - trigger_error($message); + Logger::logError($message); return; } diff --git a/application/core/Utils/Formatter.php b/application/core/Utils/Formatter.php index 9d736c82..71edf107 100644 --- a/application/core/Utils/Formatter.php +++ b/application/core/Utils/Formatter.php @@ -2,6 +2,8 @@ namespace ManiaControl\Utils; +use ManiaControl\Logger; + /** * Class offering Methods to format Texts and Values * @@ -153,7 +155,7 @@ abstract class Formatter { return $nations[$country]; } if ($country) { - trigger_error("Couldn't map Country: '{$country}'!"); + Logger::logWarning("Couldn't map Country: '{$country}'!"); } return 'OTH'; } diff --git a/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index 342551dd..c35a2021 100644 --- a/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -15,6 +15,7 @@ use ManiaControl\Callbacks\Models\RecordCallback; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Commands\CommandListener; use ManiaControl\Files\AsynchronousFileReader; +use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Players\Player; @@ -399,7 +400,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene private function getGameModeString() { $gameMode = $this->maniaControl->getServer()->getGameMode(); if ($gameMode === null) { - trigger_error("Couldn't retrieve game mode."); + Logger::logError("Couldn't retrieve game mode."); return null; } switch ($gameMode) { @@ -753,7 +754,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene // Called method response if (!$methodResponse[0]) { - trigger_error("Records Plugin: Submitting dedimania records failed."); + Logger::logError("Records Plugin: Submitting dedimania records failed."); } if (self::DEDIMANIA_DEBUG) { diff --git a/application/plugins/MCTeam/LocalRecordsPlugin.php b/application/plugins/MCTeam/LocalRecordsPlugin.php index cb5ab50a..d0e432d5 100644 --- a/application/plugins/MCTeam/LocalRecordsPlugin.php +++ b/application/plugins/MCTeam/LocalRecordsPlugin.php @@ -15,6 +15,7 @@ use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\Models\RecordCallback; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Commands\CommandListener; +use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Maps\Map; @@ -223,7 +224,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList $records = $this->getLocalRecords($map); if (!is_array($records)) { - trigger_error("Couldn't fetch player records."); + Logger::logError("Couldn't fetch player records."); return null; }