From 7e5054b58a9deac40dd1ea34a2c2e5e6fcac78ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sat, 3 May 2014 21:37:28 +0200 Subject: [PATCH] improved directory separator --- application/ManiaControl.php | 16 ++++++++-------- application/core/Files/BackupUtil.php | 12 ++++++------ application/core/ManiaControl.php | 4 ++-- application/core/Maps/MapCommands.php | 4 ++-- application/core/Maps/MapManager.php | 4 ++-- application/core/Plugins/PluginManager.php | 4 ++-- application/core/Server/Server.php | 2 +- application/core/Update/PluginUpdateManager.php | 2 +- application/core/Update/UpdateManager.php | 6 +++--- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/application/ManiaControl.php b/application/ManiaControl.php index cba5fa71..198a314f 100644 --- a/application/ManiaControl.php +++ b/application/ManiaControl.php @@ -6,7 +6,7 @@ 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__); +define('ManiaControlDir', __DIR__ . DIRECTORY_SEPARATOR); // Define fatal error level define('E_FATAL', E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_USER_ERROR); @@ -18,7 +18,7 @@ if (function_exists('date_default_timezone_get') && function_exists('date_defaul } // Build log file name -$logFileName = ManiaControlDir . '/logs/'; +$logFileName = ManiaControlDir . 'logs' . DIRECTORY_SEPARATOR; if (!is_dir($logFileName)) { mkdir($logFileName); } @@ -34,7 +34,7 @@ define('LOG_FILE', $logFileName); // Delete old current log file if (LOG_WRITE_CURRENT_FILE) { - $currentLogFileName = ManiaControlDir . '/' . LOG_WRITE_CURRENT_FILE; + $currentLogFileName = ManiaControlDir . LOG_WRITE_CURRENT_FILE; if (file_exists($currentLogFileName) && is_writable($currentLogFileName)) { unlink($currentLogFileName); } @@ -73,18 +73,18 @@ if (extension_loaded('curl')) { * @param bool $eol */ function logMessage($message, $eol = true) { - $date = date("d.M y H:i:s"); + $date = date('d.M y H:i:s'); $message = $date . ' ' . $message; if ($eol) { $message .= PHP_EOL; } if (defined('LOG_CURRENT_FILE')) { if (!file_put_contents(LOG_CURRENT_FILE, $message, FILE_APPEND)) { - echo "Logfile not Write-able, please check your file Permissions"; + echo 'Logfile not write-able, please check the File Permissions!'; } } if (!file_put_contents(LOG_FILE, $message, FILE_APPEND)) { - echo "Logfile not Write-able, please check your file Permissions"; + echo 'Logfile not write-able, please check the File Permissions!'; } echo $message; } @@ -95,14 +95,14 @@ spl_autoload_register(function ($className) { // Core file $classDirectoryPath = preg_replace('/ManiaControl/', 'core', $classPath, 1); - $filePath = ManiaControlDir . DIRECTORY_SEPARATOR . $classDirectoryPath . '.php'; + $filePath = ManiaControlDir . $classDirectoryPath . '.php'; if (file_exists($filePath)) { require_once $filePath; return; } // Plugin file - $filePath = ManiaControlDir . DIRECTORY_SEPARATOR . 'plugins/' . $classPath . '.php'; + $filePath = ManiaControlDir . 'plugins'.DIRECTORY_SEPARATOR . $classPath . '.php'; if (file_exists($filePath)) { require_once $filePath; return; diff --git a/application/core/Files/BackupUtil.php b/application/core/Files/BackupUtil.php index 04e9d2be..1fba8fc1 100644 --- a/application/core/Files/BackupUtil.php +++ b/application/core/Files/BackupUtil.php @@ -15,7 +15,7 @@ abstract class BackupUtil { /* * Constants */ - const FOLDER_NAME_BACKUP = '/backup/'; + const FOLDER_NAME_BACKUP = 'backup/'; /** * Perform a Full Backup of ManiaControl @@ -32,7 +32,7 @@ abstract class BackupUtil { } $excludes = array('.', '..', 'backup', 'logs', 'ManiaControl.log'); $pathInfo = pathInfo(ManiaControlDir); - $parentPath = $pathInfo['dirname'] . '/'; + $parentPath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR; $dirName = $pathInfo['basename']; $backupZip->addEmptyDir($dirName); self::zipDirectory($backupZip, ManiaControlDir, strlen($parentPath), $excludes); @@ -72,7 +72,7 @@ abstract class BackupUtil { if (in_array($file, $excludes)) { continue; } - $filePath = $folderName . '/' . $file; + $filePath = $folderName . DIRECTORY_SEPARATOR . $file; $localPath = substr($filePath, $prefixLength); if (is_file($filePath)) { $zipArchive->addFile($filePath, $localPath); @@ -102,11 +102,11 @@ abstract class BackupUtil { return false; } $excludes = array('.', '..'); - $pathInfo = pathInfo(ManiaControlDir . '/plugins'); - $parentPath = $pathInfo['dirname'] . '/'; + $pathInfo = pathInfo(ManiaControlDir . 'plugins'); + $parentPath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR; $dirName = $pathInfo['basename']; $backupZip->addEmptyDir($dirName); - self::zipDirectory($backupZip, ManiaControlDir . '/plugins', strlen($parentPath), $excludes); + self::zipDirectory($backupZip, ManiaControlDir . 'plugins', strlen($parentPath), $excludes); $backupZip->close(); return true; } diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 7234fea0..56515f9e 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -223,10 +223,10 @@ class ManiaControl implements CommandListener, TimerListener { // Execute start script in background // TODO: restart the .php script itself ($_SERVER['scriptname'] or something + $argv) if ($this->getOS(self::OS_UNIX)) { - $command = 'sh ' . escapeshellarg(ManiaControlDir . '/ManiaControl.sh') . ' > /dev/null &'; + $command = 'sh ' . escapeshellarg(ManiaControlDir . 'ManiaControl.sh') . ' > /dev/null &'; exec($command); } else { - $command = escapeshellarg(ManiaControlDir . "\ManiaControl.bat"); + $command = escapeshellarg(ManiaControlDir . "ManiaControl.bat"); system($command); // TODO, windows stucks here as long controller is running } exit(); diff --git a/application/core/Maps/MapCommands.php b/application/core/Maps/MapCommands.php index 70285ff4..ab7ccc77 100644 --- a/application/core/Maps/MapCommands.php +++ b/application/core/Maps/MapCommands.php @@ -264,7 +264,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $maplist = 'maplist.txt'; } - $maplist = 'MatchSettings/' . $maplist; + $maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist; try { $this->maniaControl->client->saveMatchSettings($maplist); @@ -299,7 +299,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $maplist = 'maplist.txt'; } - $maplist = 'MatchSettings/' . $maplist; + $maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist; try { $this->maniaControl->client->loadMatchSettings($maplist); diff --git a/application/core/Maps/MapManager.php b/application/core/Maps/MapManager.php index e6496296..f16b6795 100644 --- a/application/core/Maps/MapManager.php +++ b/application/core/Maps/MapManager.php @@ -284,9 +284,9 @@ class MapManager implements CallbackListener { $fileName = FileUtil::getClearedFileName($fileName); $downloadFolderName = $this->maniaControl->settingManager->getSetting($this, 'MapDownloadDirectory', 'MX'); - $relativeMapFileName = $downloadFolderName . '/' . $fileName; + $relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName; $mapDir = $this->maniaControl->client->getMapsDirectory(); - $downloadDirectory = $mapDir . '/' . $downloadFolderName . '/'; + $downloadDirectory = $mapDir . DIRECTORY_SEPARATOR . $downloadFolderName . DIRECTORY_SEPARATOR; $fullMapFileName = $downloadDirectory . $fileName; // Check if it can get written locally diff --git a/application/core/Plugins/PluginManager.php b/application/core/Plugins/PluginManager.php index 1a71c8e5..d12d37be 100644 --- a/application/core/Plugins/PluginManager.php +++ b/application/core/Plugins/PluginManager.php @@ -203,7 +203,7 @@ class PluginManager { * @return array */ public function loadPlugins() { - $pluginsDirectory = ManiaControlDir . '/plugins/'; + $pluginsDirectory = ManiaControlDir . 'plugins'. DIRECTORY_SEPARATOR; $classesBefore = get_declared_classes(); $this->loadPluginFiles($pluginsDirectory); @@ -259,7 +259,7 @@ class PluginManager { $dirPath = $directory . $pluginFile; if (is_dir($dirPath)) { - $this->loadPluginFiles($dirPath . '/'); + $this->loadPluginFiles($dirPath . DIRECTORY_SEPARATOR); continue; } } diff --git a/application/core/Server/Server.php b/application/core/Server/Server.php index 61036c37..001c4e92 100644 --- a/application/core/Server/Server.php +++ b/application/core/Server/Server.php @@ -257,7 +257,7 @@ class Server implements CallbackListener { if (!$dataDirectory) { return null; } - return "{$dataDirectory}Maps/"; + return "{$dataDirectory}Maps".DIRECTORY_SEPARATOR; } /** diff --git a/application/core/Update/PluginUpdateManager.php b/application/core/Update/PluginUpdateManager.php index 2b2f62ee..629a971e 100644 --- a/application/core/Update/PluginUpdateManager.php +++ b/application/core/Update/PluginUpdateManager.php @@ -284,7 +284,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis return; } - $zip->extractTo(ManiaControlDir . '/plugins/'); + $zip->extractTo(ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR); $zip->close(); unlink($updateFileName); FileUtil::removeTempFolder(); diff --git a/application/core/Update/UpdateManager.php b/application/core/Update/UpdateManager.php index bbecb460..785a6def 100644 --- a/application/core/Update/UpdateManager.php +++ b/application/core/Update/UpdateManager.php @@ -214,7 +214,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener */ public function getNightlyBuildDate() { if (!$this->currentBuildDate) { - $nightlyBuildDateFile = ManiaControlDir . '/core/nightly_build.txt'; + $nightlyBuildDateFile = ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'nightly_build.txt'; if (file_exists($nightlyBuildDateFile)) { $this->currentBuildDate = file_get_contents($nightlyBuildDateFile); } @@ -282,7 +282,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener $this->maniaControl->log("Starting Update to Version v{$this->coreUpdateData->version}..."); - $directories = array('/core/', '/plugins/'); + $directories = array('core', 'plugins'); if (!FileUtil::checkWritePermissions($directories)) { $message = 'Update not possible: Incorrect File System Permissions!'; if ($player) { @@ -362,7 +362,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener * @return bool */ private function setNightlyBuildDate($date) { - $nightlyBuildDateFile = ManiaControlDir . '/core/nightly_build.txt'; + $nightlyBuildDateFile = ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'nightly_build.txt'; $success = (bool)file_put_contents($nightlyBuildDateFile, $date); $this->currentBuildDate = $date; return $success;