From 35a431e396868d4915248ec3ef1f2ee8a3e84fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Fri, 8 Aug 2014 14:41:58 +0200 Subject: [PATCH] renamed 'ManiaControlDir' constant to fit naming conventions --- application/ManiaControl.php | 6 ++++-- application/core/AutoLoader.php | 6 +++--- application/core/ErrorHandler.php | 10 +++++----- application/core/Files/BackupUtil.php | 8 ++++---- application/core/Files/FileUtil.php | 6 +++--- application/core/Logger.php | 2 +- application/core/ManiaControl.php | 4 ++-- application/core/Plugins/PluginManager.php | 2 +- application/core/Update/PluginUpdateManager.php | 2 +- application/core/Update/UpdateManager.php | 6 +++--- application/core/Utils/SystemUtil.php | 4 ++-- 11 files changed, 29 insertions(+), 27 deletions(-) diff --git a/application/ManiaControl.php b/application/ManiaControl.php index a52e90a7..7af3bcf9 100644 --- a/application/ManiaControl.php +++ b/application/ManiaControl.php @@ -9,7 +9,9 @@ define('LOG_NAME_USE_DATE', true); // Use current date as suffix for log file na define('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder // Define base dir -define('ManiaControlDir', __DIR__ . DIRECTORY_SEPARATOR); +define('MANIACONTROL_PATH', __DIR__ . DIRECTORY_SEPARATOR); +/** @deprecated Use MANIACONTROL_PATH */ +define('ManiaControlDir', MANIACONTROL_PATH); // Set process settings ini_set('memory_limit', '64M'); @@ -21,7 +23,7 @@ if (!ini_get('date.timezone') && function_exists('date_default_timezone_set')) { gc_enable(); // Register AutoLoader -require_once ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'AutoLoader.php'; +require_once MANIACONTROL_PATH . 'core' . DIRECTORY_SEPARATOR . 'AutoLoader.php'; \ManiaControl\AutoLoader::register(); // Setup Logger diff --git a/application/core/AutoLoader.php b/application/core/AutoLoader.php index 305d94ba..32697d99 100644 --- a/application/core/AutoLoader.php +++ b/application/core/AutoLoader.php @@ -28,21 +28,21 @@ abstract class AutoLoader { // Core file $coreClassPath = preg_replace('/ManiaControl/', 'core', $classPath, 1); - $coreFilePath = ManiaControlDir . $coreClassPath . '.php'; + $coreFilePath = MANIACONTROL_PATH . $coreClassPath . '.php'; if (file_exists($coreFilePath)) { include_once $coreFilePath; return; } // Plugin file - $pluginFilePath = ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR . $classPath . '.php'; + $pluginFilePath = MANIACONTROL_PATH . 'plugins' . DIRECTORY_SEPARATOR . $classPath . '.php'; if (file_exists($pluginFilePath)) { include_once $pluginFilePath; return; } // Lib file - $libFilePath = ManiaControlDir . 'libs' . DIRECTORY_SEPARATOR . $classPath . '.php'; + $libFilePath = MANIACONTROL_PATH . 'libs' . DIRECTORY_SEPARATOR . $classPath . '.php'; if (file_exists($libFilePath)) { include_once $libFilePath; return; diff --git a/application/core/ErrorHandler.php b/application/core/ErrorHandler.php index 27e16906..f59691f1 100644 --- a/application/core/ErrorHandler.php +++ b/application/core/ErrorHandler.php @@ -321,7 +321,7 @@ class ErrorHandler { } /** - * Build a String from an Arguments Array + * Build a string from an arguments array * * @param array $args * @return string @@ -361,17 +361,17 @@ class ErrorHandler { } /** - * Strip the ManiaControlDir from the given Path to ensure privacy + * Strip the ManiaControl path from the given path to ensure privacy * * @param string $path * @return string */ private static function stripBaseDir($path) { - return str_replace(ManiaControlDir, '', $path); + return str_replace(MANIACONTROL_PATH, '', $path); } /** - * Get the Source Class via the Error File + * Get the source class via the error file * * @param string $errorFile * @return string @@ -380,7 +380,7 @@ class ErrorHandler { if (!$errorFile) { return null; } - $filePath = substr($errorFile, strlen(ManiaControlDir)); + $filePath = substr($errorFile, strlen(MANIACONTROL_PATH)); $filePath = str_replace('plugins' . DIRECTORY_SEPARATOR, '', $filePath); $filePath = str_replace('core' . DIRECTORY_SEPARATOR, 'ManiaControl\\', $filePath); $className = str_replace('.php', '', $filePath); diff --git a/application/core/Files/BackupUtil.php b/application/core/Files/BackupUtil.php index ac4e08d0..4a93ddc7 100644 --- a/application/core/Files/BackupUtil.php +++ b/application/core/Files/BackupUtil.php @@ -32,11 +32,11 @@ abstract class BackupUtil { } $excludes = array(); $baseFileNames = array('configs', 'core', 'plugins', 'ManiaControl.php'); - $pathInfo = pathInfo(ManiaControlDir); + $pathInfo = pathInfo(MANIACONTROL_PATH); $parentPath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR; $dirName = $pathInfo['basename']; $backupZip->addEmptyDir($dirName); - self::zipDirectory($backupZip, ManiaControlDir, strlen($parentPath), $excludes, $baseFileNames); + self::zipDirectory($backupZip, MANIACONTROL_PATH, strlen($parentPath), $excludes, $baseFileNames); return $backupZip->close(); } @@ -46,7 +46,7 @@ abstract class BackupUtil { * @return string|bool */ private static function getBackupFolder() { - $backupFolder = ManiaControlDir . 'backup' . DIRECTORY_SEPARATOR; + $backupFolder = MANIACONTROL_PATH . 'backup' . DIRECTORY_SEPARATOR; if (!is_dir($backupFolder) && !mkdir($backupFolder)) { Logger::logError("Couldn't create backup folder!"); return false; @@ -121,7 +121,7 @@ abstract class BackupUtil { Logger::logError("Couldn't create backup zip!"); return false; } - $directory = ManiaControlDir . 'plugins'; + $directory = MANIACONTROL_PATH . 'plugins'; $pathInfo = pathInfo($directory); $parentPath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR; $dirName = $pathInfo['basename']; diff --git a/application/core/Files/FileUtil.php b/application/core/Files/FileUtil.php index f96dfcdd..b539a809 100644 --- a/application/core/Files/FileUtil.php +++ b/application/core/Files/FileUtil.php @@ -31,7 +31,7 @@ abstract class FileUtil { * @return \SimpleXMLElement */ public static function loadConfig($fileName) { - $fileLocation = ManiaControlDir . 'configs' . DIRECTORY_SEPARATOR . $fileName; + $fileLocation = MANIACONTROL_PATH . 'configs' . DIRECTORY_SEPARATOR . $fileName; if (!file_exists($fileLocation)) { Logger::log("Config file doesn't exist! ({$fileName})"); return null; @@ -105,7 +105,7 @@ abstract class FileUtil { * @return string|bool */ public static function getTempFolder() { - $tempFolder = ManiaControlDir . 'temp' . DIRECTORY_SEPARATOR; + $tempFolder = MANIACONTROL_PATH . 'temp' . DIRECTORY_SEPARATOR; if (!is_dir($tempFolder) && !mkdir($tempFolder)) { trigger_error("Couldn't create the temp folder!"); return false; @@ -128,7 +128,7 @@ abstract class FileUtil { $directories = array($directories); } foreach ($directories as $directory) { - $dir = new \RecursiveDirectoryIterator(ManiaControlDir . $directory); + $dir = new \RecursiveDirectoryIterator(MANIACONTROL_PATH . $directory); foreach (new \RecursiveIteratorIterator($dir) as $fileName => $file) { if (substr($fileName, 0, 1) === '.') { continue; diff --git a/application/core/Logger.php b/application/core/Logger.php index b1c8a810..d1de199a 100644 --- a/application/core/Logger.php +++ b/application/core/Logger.php @@ -46,7 +46,7 @@ abstract class Logger { * @return string */ public static function getLogsFolder() { - $logsFolder = ManiaControlDir . 'logs' . DIRECTORY_SEPARATOR; + $logsFolder = MANIACONTROL_PATH . 'logs' . DIRECTORY_SEPARATOR; if (!is_dir($logsFolder) && !mkdir($logsFolder)) { self::logError("Couldn't create the logs folder!"); return null; diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index d45dd85b..94b6334f 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -31,8 +31,8 @@ use Maniaplanet\DedicatedServer\Connection; use Maniaplanet\DedicatedServer\Xmlrpc\AuthenticationException; use Maniaplanet\DedicatedServer\Xmlrpc\TransportException; -require_once ManiaControlDir . '/libs/Symfony/autoload.php'; -require_once ManiaControlDir . '/libs/curl-easy/autoload.php'; +require_once MANIACONTROL_PATH . '/libs/Symfony/autoload.php'; +require_once MANIACONTROL_PATH . '/libs/curl-easy/autoload.php'; /** * ManiaControl Server Controller for ManiaPlanet Server diff --git a/application/core/Plugins/PluginManager.php b/application/core/Plugins/PluginManager.php index 7342e635..b4d51916 100644 --- a/application/core/Plugins/PluginManager.php +++ b/application/core/Plugins/PluginManager.php @@ -248,7 +248,7 @@ class PluginManager { * @return string[] */ public function loadPlugins() { - $pluginsDirectory = ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR; + $pluginsDirectory = MANIACONTROL_PATH . 'plugins' . DIRECTORY_SEPARATOR; $classesBefore = get_declared_classes(); $this->loadPluginFiles($pluginsDirectory); diff --git a/application/core/Update/PluginUpdateManager.php b/application/core/Update/PluginUpdateManager.php index 8dd3258f..144f6eb6 100644 --- a/application/core/Update/PluginUpdateManager.php +++ b/application/core/Update/PluginUpdateManager.php @@ -310,7 +310,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis return; } - $zip->extractTo(ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR); + $zip->extractTo(MANIACONTROL_PATH . 'plugins' . DIRECTORY_SEPARATOR); $zip->close(); unlink($updateFileName); FileUtil::deleteTempFolder(); diff --git a/application/core/Update/UpdateManager.php b/application/core/Update/UpdateManager.php index a935a99a..f7e05074 100644 --- a/application/core/Update/UpdateManager.php +++ b/application/core/Update/UpdateManager.php @@ -255,7 +255,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener */ public function getNightlyBuildDate() { if (!$this->currentBuildDate) { - $nightlyBuildDateFile = ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'nightly_build.txt'; + $nightlyBuildDateFile = MANIACONTROL_PATH . 'core' . DIRECTORY_SEPARATOR . 'nightly_build.txt'; if (file_exists($nightlyBuildDateFile)) { $this->currentBuildDate = file_get_contents($nightlyBuildDateFile); } @@ -401,7 +401,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener return; } - $zip->extractTo(ManiaControlDir); + $zip->extractTo(MANIACONTROL_PATH); $zip->close(); unlink($updateFileName); FileUtil::deleteTempFolder(); @@ -429,7 +429,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener * @return bool */ public function setNightlyBuildDate($date) { - $nightlyBuildDateFile = ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'nightly_build.txt'; + $nightlyBuildDateFile = MANIACONTROL_PATH . 'core' . DIRECTORY_SEPARATOR . 'nightly_build.txt'; $success = (bool)file_put_contents($nightlyBuildDateFile, $date); $this->currentBuildDate = $date; return $success; diff --git a/application/core/Utils/SystemUtil.php b/application/core/Utils/SystemUtil.php index 65bdb2a6..df6b07f3 100644 --- a/application/core/Utils/SystemUtil.php +++ b/application/core/Utils/SystemUtil.php @@ -128,7 +128,7 @@ class SystemUtil { Logger::log("Can't restart ManiaControl because the function 'exec' is disabled!"); return; } - $fileName = ManiaControlDir . 'ManiaControl.sh'; + $fileName = MANIACONTROL_PATH . 'ManiaControl.sh'; if (!is_readable($fileName)) { Logger::log("Can't restart ManiaControl because the file 'ManiaControl.sh' doesn't exist or isn't readable!"); return; @@ -165,7 +165,7 @@ class SystemUtil { Logger::log("Can't restart ManiaControl because the function 'system' is disabled!"); return; } - $command = escapeshellarg(ManiaControlDir . "ManiaControl.bat"); + $command = escapeshellarg(MANIACONTROL_PATH . "ManiaControl.bat"); system($command); // TODO: windows gets stuck here as long controller is running } }