improved directory separator
This commit is contained in:
parent
50fad3f71b
commit
7e5054b58a
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ class Server implements CallbackListener {
|
||||
if (!$dataDirectory) {
|
||||
return null;
|
||||
}
|
||||
return "{$dataDirectory}Maps/";
|
||||
return "{$dataDirectory}Maps".DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user