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 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

View File

@ -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;

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
* @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);

View File

@ -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'];

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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();

View File

@ -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;

View File

@ -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
}
}