renamed 'ManiaControlDir' constant to fit naming conventions

This commit is contained in:
Steffen Schröder 2014-08-08 14:41:58 +02:00
parent 96d3f1eaba
commit 35a431e396
11 changed files with 29 additions and 27 deletions

View File

@ -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('LOG_NAME_USE_PID', true); // Use current process id as suffix for log file name in logs folder
// Define base dir // 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 // Set process settings
ini_set('memory_limit', '64M'); ini_set('memory_limit', '64M');
@ -21,7 +23,7 @@ if (!ini_get('date.timezone') && function_exists('date_default_timezone_set')) {
gc_enable(); gc_enable();
// Register AutoLoader // Register AutoLoader
require_once ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'AutoLoader.php'; require_once MANIACONTROL_PATH . 'core' . DIRECTORY_SEPARATOR . 'AutoLoader.php';
\ManiaControl\AutoLoader::register(); \ManiaControl\AutoLoader::register();
// Setup Logger // Setup Logger

View File

@ -28,21 +28,21 @@ abstract class AutoLoader {
// Core file // Core file
$coreClassPath = preg_replace('/ManiaControl/', 'core', $classPath, 1); $coreClassPath = preg_replace('/ManiaControl/', 'core', $classPath, 1);
$coreFilePath = ManiaControlDir . $coreClassPath . '.php'; $coreFilePath = MANIACONTROL_PATH . $coreClassPath . '.php';
if (file_exists($coreFilePath)) { if (file_exists($coreFilePath)) {
include_once $coreFilePath; include_once $coreFilePath;
return; return;
} }
// Plugin file // Plugin file
$pluginFilePath = ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR . $classPath . '.php'; $pluginFilePath = MANIACONTROL_PATH . 'plugins' . DIRECTORY_SEPARATOR . $classPath . '.php';
if (file_exists($pluginFilePath)) { if (file_exists($pluginFilePath)) {
include_once $pluginFilePath; include_once $pluginFilePath;
return; return;
} }
// Lib file // Lib file
$libFilePath = ManiaControlDir . 'libs' . DIRECTORY_SEPARATOR . $classPath . '.php'; $libFilePath = MANIACONTROL_PATH . 'libs' . DIRECTORY_SEPARATOR . $classPath . '.php';
if (file_exists($libFilePath)) { if (file_exists($libFilePath)) {
include_once $libFilePath; include_once $libFilePath;
return; return;

View File

@ -321,7 +321,7 @@ class ErrorHandler {
} }
/** /**
* Build a String from an Arguments Array * Build a string from an arguments array
* *
* @param array $args * @param array $args
* @return string * @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 * @param string $path
* @return string * @return string
*/ */
private static function stripBaseDir($path) { 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 * @param string $errorFile
* @return string * @return string
@ -380,7 +380,7 @@ class ErrorHandler {
if (!$errorFile) { if (!$errorFile) {
return null; return null;
} }
$filePath = substr($errorFile, strlen(ManiaControlDir)); $filePath = substr($errorFile, strlen(MANIACONTROL_PATH));
$filePath = str_replace('plugins' . DIRECTORY_SEPARATOR, '', $filePath); $filePath = str_replace('plugins' . DIRECTORY_SEPARATOR, '', $filePath);
$filePath = str_replace('core' . DIRECTORY_SEPARATOR, 'ManiaControl\\', $filePath); $filePath = str_replace('core' . DIRECTORY_SEPARATOR, 'ManiaControl\\', $filePath);
$className = str_replace('.php', '', $filePath); $className = str_replace('.php', '', $filePath);

View File

@ -32,11 +32,11 @@ abstract class BackupUtil {
} }
$excludes = array(); $excludes = array();
$baseFileNames = array('configs', 'core', 'plugins', 'ManiaControl.php'); $baseFileNames = array('configs', 'core', 'plugins', 'ManiaControl.php');
$pathInfo = pathInfo(ManiaControlDir); $pathInfo = pathInfo(MANIACONTROL_PATH);
$parentPath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR; $parentPath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR;
$dirName = $pathInfo['basename']; $dirName = $pathInfo['basename'];
$backupZip->addEmptyDir($dirName); $backupZip->addEmptyDir($dirName);
self::zipDirectory($backupZip, ManiaControlDir, strlen($parentPath), $excludes, $baseFileNames); self::zipDirectory($backupZip, MANIACONTROL_PATH, strlen($parentPath), $excludes, $baseFileNames);
return $backupZip->close(); return $backupZip->close();
} }
@ -46,7 +46,7 @@ abstract class BackupUtil {
* @return string|bool * @return string|bool
*/ */
private static function getBackupFolder() { private static function getBackupFolder() {
$backupFolder = ManiaControlDir . 'backup' . DIRECTORY_SEPARATOR; $backupFolder = MANIACONTROL_PATH . 'backup' . DIRECTORY_SEPARATOR;
if (!is_dir($backupFolder) && !mkdir($backupFolder)) { if (!is_dir($backupFolder) && !mkdir($backupFolder)) {
Logger::logError("Couldn't create backup folder!"); Logger::logError("Couldn't create backup folder!");
return false; return false;
@ -121,7 +121,7 @@ abstract class BackupUtil {
Logger::logError("Couldn't create backup zip!"); Logger::logError("Couldn't create backup zip!");
return false; return false;
} }
$directory = ManiaControlDir . 'plugins'; $directory = MANIACONTROL_PATH . 'plugins';
$pathInfo = pathInfo($directory); $pathInfo = pathInfo($directory);
$parentPath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR; $parentPath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR;
$dirName = $pathInfo['basename']; $dirName = $pathInfo['basename'];

View File

@ -31,7 +31,7 @@ abstract class FileUtil {
* @return \SimpleXMLElement * @return \SimpleXMLElement
*/ */
public static function loadConfig($fileName) { public static function loadConfig($fileName) {
$fileLocation = ManiaControlDir . 'configs' . DIRECTORY_SEPARATOR . $fileName; $fileLocation = MANIACONTROL_PATH . 'configs' . DIRECTORY_SEPARATOR . $fileName;
if (!file_exists($fileLocation)) { if (!file_exists($fileLocation)) {
Logger::log("Config file doesn't exist! ({$fileName})"); Logger::log("Config file doesn't exist! ({$fileName})");
return null; return null;
@ -105,7 +105,7 @@ abstract class FileUtil {
* @return string|bool * @return string|bool
*/ */
public static function getTempFolder() { public static function getTempFolder() {
$tempFolder = ManiaControlDir . 'temp' . DIRECTORY_SEPARATOR; $tempFolder = MANIACONTROL_PATH . 'temp' . DIRECTORY_SEPARATOR;
if (!is_dir($tempFolder) && !mkdir($tempFolder)) { if (!is_dir($tempFolder) && !mkdir($tempFolder)) {
trigger_error("Couldn't create the temp folder!"); trigger_error("Couldn't create the temp folder!");
return false; return false;
@ -128,7 +128,7 @@ abstract class FileUtil {
$directories = array($directories); $directories = array($directories);
} }
foreach ($directories as $directory) { foreach ($directories as $directory) {
$dir = new \RecursiveDirectoryIterator(ManiaControlDir . $directory); $dir = new \RecursiveDirectoryIterator(MANIACONTROL_PATH . $directory);
foreach (new \RecursiveIteratorIterator($dir) as $fileName => $file) { foreach (new \RecursiveIteratorIterator($dir) as $fileName => $file) {
if (substr($fileName, 0, 1) === '.') { if (substr($fileName, 0, 1) === '.') {
continue; continue;

View File

@ -46,7 +46,7 @@ abstract class Logger {
* @return string * @return string
*/ */
public static function getLogsFolder() { public static function getLogsFolder() {
$logsFolder = ManiaControlDir . 'logs' . DIRECTORY_SEPARATOR; $logsFolder = MANIACONTROL_PATH . 'logs' . DIRECTORY_SEPARATOR;
if (!is_dir($logsFolder) && !mkdir($logsFolder)) { if (!is_dir($logsFolder) && !mkdir($logsFolder)) {
self::logError("Couldn't create the logs folder!"); self::logError("Couldn't create the logs folder!");
return null; return null;

View File

@ -31,8 +31,8 @@ use Maniaplanet\DedicatedServer\Connection;
use Maniaplanet\DedicatedServer\Xmlrpc\AuthenticationException; use Maniaplanet\DedicatedServer\Xmlrpc\AuthenticationException;
use Maniaplanet\DedicatedServer\Xmlrpc\TransportException; use Maniaplanet\DedicatedServer\Xmlrpc\TransportException;
require_once ManiaControlDir . '/libs/Symfony/autoload.php'; require_once MANIACONTROL_PATH . '/libs/Symfony/autoload.php';
require_once ManiaControlDir . '/libs/curl-easy/autoload.php'; require_once MANIACONTROL_PATH . '/libs/curl-easy/autoload.php';
/** /**
* ManiaControl Server Controller for ManiaPlanet Server * ManiaControl Server Controller for ManiaPlanet Server

View File

@ -248,7 +248,7 @@ class PluginManager {
* @return string[] * @return string[]
*/ */
public function loadPlugins() { public function loadPlugins() {
$pluginsDirectory = ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR; $pluginsDirectory = MANIACONTROL_PATH . 'plugins' . DIRECTORY_SEPARATOR;
$classesBefore = get_declared_classes(); $classesBefore = get_declared_classes();
$this->loadPluginFiles($pluginsDirectory); $this->loadPluginFiles($pluginsDirectory);

View File

@ -310,7 +310,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
return; return;
} }
$zip->extractTo(ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR); $zip->extractTo(MANIACONTROL_PATH . 'plugins' . DIRECTORY_SEPARATOR);
$zip->close(); $zip->close();
unlink($updateFileName); unlink($updateFileName);
FileUtil::deleteTempFolder(); FileUtil::deleteTempFolder();

View File

@ -255,7 +255,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
*/ */
public function getNightlyBuildDate() { public function getNightlyBuildDate() {
if (!$this->currentBuildDate) { if (!$this->currentBuildDate) {
$nightlyBuildDateFile = ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'nightly_build.txt'; $nightlyBuildDateFile = MANIACONTROL_PATH . 'core' . DIRECTORY_SEPARATOR . 'nightly_build.txt';
if (file_exists($nightlyBuildDateFile)) { if (file_exists($nightlyBuildDateFile)) {
$this->currentBuildDate = file_get_contents($nightlyBuildDateFile); $this->currentBuildDate = file_get_contents($nightlyBuildDateFile);
} }
@ -401,7 +401,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
return; return;
} }
$zip->extractTo(ManiaControlDir); $zip->extractTo(MANIACONTROL_PATH);
$zip->close(); $zip->close();
unlink($updateFileName); unlink($updateFileName);
FileUtil::deleteTempFolder(); FileUtil::deleteTempFolder();
@ -429,7 +429,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* @return bool * @return bool
*/ */
public function setNightlyBuildDate($date) { 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); $success = (bool)file_put_contents($nightlyBuildDateFile, $date);
$this->currentBuildDate = $date; $this->currentBuildDate = $date;
return $success; return $success;

View File

@ -128,7 +128,7 @@ class SystemUtil {
Logger::log("Can't restart ManiaControl because the function 'exec' is disabled!"); Logger::log("Can't restart ManiaControl because the function 'exec' is disabled!");
return; return;
} }
$fileName = ManiaControlDir . 'ManiaControl.sh'; $fileName = MANIACONTROL_PATH . 'ManiaControl.sh';
if (!is_readable($fileName)) { if (!is_readable($fileName)) {
Logger::log("Can't restart ManiaControl because the file 'ManiaControl.sh' doesn't exist or isn't readable!"); Logger::log("Can't restart ManiaControl because the file 'ManiaControl.sh' doesn't exist or isn't readable!");
return; return;
@ -165,7 +165,7 @@ class SystemUtil {
Logger::log("Can't restart ManiaControl because the function 'system' is disabled!"); Logger::log("Can't restart ManiaControl because the function 'system' is disabled!");
return; return;
} }
$command = escapeshellarg(ManiaControlDir . "ManiaControl.bat"); $command = escapeshellarg(MANIACONTROL_PATH . "ManiaControl.bat");
system($command); // TODO: windows gets stuck here as long controller is running system($command); // TODO: windows gets stuck here as long controller is running
} }
} }