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('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__);
|
define('ManiaControlDir', __DIR__ . DIRECTORY_SEPARATOR);
|
||||||
|
|
||||||
// Define fatal error level
|
// Define fatal error level
|
||||||
define('E_FATAL', E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_USER_ERROR);
|
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
|
// Build log file name
|
||||||
$logFileName = ManiaControlDir . '/logs/';
|
$logFileName = ManiaControlDir . 'logs' . DIRECTORY_SEPARATOR;
|
||||||
if (!is_dir($logFileName)) {
|
if (!is_dir($logFileName)) {
|
||||||
mkdir($logFileName);
|
mkdir($logFileName);
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ define('LOG_FILE', $logFileName);
|
|||||||
|
|
||||||
// Delete old current log file
|
// Delete old current log file
|
||||||
if (LOG_WRITE_CURRENT_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)) {
|
if (file_exists($currentLogFileName) && is_writable($currentLogFileName)) {
|
||||||
unlink($currentLogFileName);
|
unlink($currentLogFileName);
|
||||||
}
|
}
|
||||||
@ -73,18 +73,18 @@ if (extension_loaded('curl')) {
|
|||||||
* @param bool $eol
|
* @param bool $eol
|
||||||
*/
|
*/
|
||||||
function logMessage($message, $eol = true) {
|
function logMessage($message, $eol = true) {
|
||||||
$date = date("d.M y H:i:s");
|
$date = date('d.M y H:i:s');
|
||||||
$message = $date . ' ' . $message;
|
$message = $date . ' ' . $message;
|
||||||
if ($eol) {
|
if ($eol) {
|
||||||
$message .= PHP_EOL;
|
$message .= PHP_EOL;
|
||||||
}
|
}
|
||||||
if (defined('LOG_CURRENT_FILE')) {
|
if (defined('LOG_CURRENT_FILE')) {
|
||||||
if (!file_put_contents(LOG_CURRENT_FILE, $message, FILE_APPEND)) {
|
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)) {
|
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;
|
echo $message;
|
||||||
}
|
}
|
||||||
@ -95,14 +95,14 @@ spl_autoload_register(function ($className) {
|
|||||||
|
|
||||||
// Core file
|
// Core file
|
||||||
$classDirectoryPath = preg_replace('/ManiaControl/', 'core', $classPath, 1);
|
$classDirectoryPath = preg_replace('/ManiaControl/', 'core', $classPath, 1);
|
||||||
$filePath = ManiaControlDir . DIRECTORY_SEPARATOR . $classDirectoryPath . '.php';
|
$filePath = ManiaControlDir . $classDirectoryPath . '.php';
|
||||||
if (file_exists($filePath)) {
|
if (file_exists($filePath)) {
|
||||||
require_once $filePath;
|
require_once $filePath;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin file
|
// Plugin file
|
||||||
$filePath = ManiaControlDir . DIRECTORY_SEPARATOR . 'plugins/' . $classPath . '.php';
|
$filePath = ManiaControlDir . 'plugins'.DIRECTORY_SEPARATOR . $classPath . '.php';
|
||||||
if (file_exists($filePath)) {
|
if (file_exists($filePath)) {
|
||||||
require_once $filePath;
|
require_once $filePath;
|
||||||
return;
|
return;
|
||||||
|
@ -15,7 +15,7 @@ abstract class BackupUtil {
|
|||||||
/*
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const FOLDER_NAME_BACKUP = '/backup/';
|
const FOLDER_NAME_BACKUP = 'backup/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a Full Backup of ManiaControl
|
* Perform a Full Backup of ManiaControl
|
||||||
@ -32,7 +32,7 @@ abstract class BackupUtil {
|
|||||||
}
|
}
|
||||||
$excludes = array('.', '..', 'backup', 'logs', 'ManiaControl.log');
|
$excludes = array('.', '..', 'backup', 'logs', 'ManiaControl.log');
|
||||||
$pathInfo = pathInfo(ManiaControlDir);
|
$pathInfo = pathInfo(ManiaControlDir);
|
||||||
$parentPath = $pathInfo['dirname'] . '/';
|
$parentPath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR;
|
||||||
$dirName = $pathInfo['basename'];
|
$dirName = $pathInfo['basename'];
|
||||||
$backupZip->addEmptyDir($dirName);
|
$backupZip->addEmptyDir($dirName);
|
||||||
self::zipDirectory($backupZip, ManiaControlDir, strlen($parentPath), $excludes);
|
self::zipDirectory($backupZip, ManiaControlDir, strlen($parentPath), $excludes);
|
||||||
@ -72,7 +72,7 @@ abstract class BackupUtil {
|
|||||||
if (in_array($file, $excludes)) {
|
if (in_array($file, $excludes)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$filePath = $folderName . '/' . $file;
|
$filePath = $folderName . DIRECTORY_SEPARATOR . $file;
|
||||||
$localPath = substr($filePath, $prefixLength);
|
$localPath = substr($filePath, $prefixLength);
|
||||||
if (is_file($filePath)) {
|
if (is_file($filePath)) {
|
||||||
$zipArchive->addFile($filePath, $localPath);
|
$zipArchive->addFile($filePath, $localPath);
|
||||||
@ -102,11 +102,11 @@ abstract class BackupUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$excludes = array('.', '..');
|
$excludes = array('.', '..');
|
||||||
$pathInfo = pathInfo(ManiaControlDir . '/plugins');
|
$pathInfo = pathInfo(ManiaControlDir . 'plugins');
|
||||||
$parentPath = $pathInfo['dirname'] . '/';
|
$parentPath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR;
|
||||||
$dirName = $pathInfo['basename'];
|
$dirName = $pathInfo['basename'];
|
||||||
$backupZip->addEmptyDir($dirName);
|
$backupZip->addEmptyDir($dirName);
|
||||||
self::zipDirectory($backupZip, ManiaControlDir . '/plugins', strlen($parentPath), $excludes);
|
self::zipDirectory($backupZip, ManiaControlDir . 'plugins', strlen($parentPath), $excludes);
|
||||||
$backupZip->close();
|
$backupZip->close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -223,10 +223,10 @@ class ManiaControl implements CommandListener, TimerListener {
|
|||||||
// Execute start script in background
|
// Execute start script in background
|
||||||
// TODO: restart the .php script itself ($_SERVER['scriptname'] or something + $argv)
|
// TODO: restart the .php script itself ($_SERVER['scriptname'] or something + $argv)
|
||||||
if ($this->getOS(self::OS_UNIX)) {
|
if ($this->getOS(self::OS_UNIX)) {
|
||||||
$command = 'sh ' . escapeshellarg(ManiaControlDir . '/ManiaControl.sh') . ' > /dev/null &';
|
$command = 'sh ' . escapeshellarg(ManiaControlDir . 'ManiaControl.sh') . ' > /dev/null &';
|
||||||
exec($command);
|
exec($command);
|
||||||
} else {
|
} else {
|
||||||
$command = escapeshellarg(ManiaControlDir . "\ManiaControl.bat");
|
$command = escapeshellarg(ManiaControlDir . "ManiaControl.bat");
|
||||||
system($command); // TODO, windows stucks here as long controller is running
|
system($command); // TODO, windows stucks here as long controller is running
|
||||||
}
|
}
|
||||||
exit();
|
exit();
|
||||||
|
@ -264,7 +264,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$maplist = 'maplist.txt';
|
$maplist = 'maplist.txt';
|
||||||
}
|
}
|
||||||
|
|
||||||
$maplist = 'MatchSettings/' . $maplist;
|
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist;
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->client->saveMatchSettings($maplist);
|
$this->maniaControl->client->saveMatchSettings($maplist);
|
||||||
|
|
||||||
@ -299,7 +299,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$maplist = 'maplist.txt';
|
$maplist = 'maplist.txt';
|
||||||
}
|
}
|
||||||
|
|
||||||
$maplist = 'MatchSettings/' . $maplist;
|
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist;
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->client->loadMatchSettings($maplist);
|
$this->maniaControl->client->loadMatchSettings($maplist);
|
||||||
|
|
||||||
|
@ -284,9 +284,9 @@ class MapManager implements CallbackListener {
|
|||||||
$fileName = FileUtil::getClearedFileName($fileName);
|
$fileName = FileUtil::getClearedFileName($fileName);
|
||||||
|
|
||||||
$downloadFolderName = $this->maniaControl->settingManager->getSetting($this, 'MapDownloadDirectory', 'MX');
|
$downloadFolderName = $this->maniaControl->settingManager->getSetting($this, 'MapDownloadDirectory', 'MX');
|
||||||
$relativeMapFileName = $downloadFolderName . '/' . $fileName;
|
$relativeMapFileName = $downloadFolderName . DIRECTORY_SEPARATOR . $fileName;
|
||||||
$mapDir = $this->maniaControl->client->getMapsDirectory();
|
$mapDir = $this->maniaControl->client->getMapsDirectory();
|
||||||
$downloadDirectory = $mapDir . '/' . $downloadFolderName . '/';
|
$downloadDirectory = $mapDir . DIRECTORY_SEPARATOR . $downloadFolderName . DIRECTORY_SEPARATOR;
|
||||||
$fullMapFileName = $downloadDirectory . $fileName;
|
$fullMapFileName = $downloadDirectory . $fileName;
|
||||||
|
|
||||||
// Check if it can get written locally
|
// Check if it can get written locally
|
||||||
|
@ -203,7 +203,7 @@ class PluginManager {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function loadPlugins() {
|
public function loadPlugins() {
|
||||||
$pluginsDirectory = ManiaControlDir . '/plugins/';
|
$pluginsDirectory = ManiaControlDir . 'plugins'. DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
$classesBefore = get_declared_classes();
|
$classesBefore = get_declared_classes();
|
||||||
$this->loadPluginFiles($pluginsDirectory);
|
$this->loadPluginFiles($pluginsDirectory);
|
||||||
@ -259,7 +259,7 @@ class PluginManager {
|
|||||||
|
|
||||||
$dirPath = $directory . $pluginFile;
|
$dirPath = $directory . $pluginFile;
|
||||||
if (is_dir($dirPath)) {
|
if (is_dir($dirPath)) {
|
||||||
$this->loadPluginFiles($dirPath . '/');
|
$this->loadPluginFiles($dirPath . DIRECTORY_SEPARATOR);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ class Server implements CallbackListener {
|
|||||||
if (!$dataDirectory) {
|
if (!$dataDirectory) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return "{$dataDirectory}Maps/";
|
return "{$dataDirectory}Maps".DIRECTORY_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -284,7 +284,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$zip->extractTo(ManiaControlDir . '/plugins/');
|
$zip->extractTo(ManiaControlDir . 'plugins' . DIRECTORY_SEPARATOR);
|
||||||
$zip->close();
|
$zip->close();
|
||||||
unlink($updateFileName);
|
unlink($updateFileName);
|
||||||
FileUtil::removeTempFolder();
|
FileUtil::removeTempFolder();
|
||||||
|
@ -214,7 +214,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
*/
|
*/
|
||||||
public function getNightlyBuildDate() {
|
public function getNightlyBuildDate() {
|
||||||
if (!$this->currentBuildDate) {
|
if (!$this->currentBuildDate) {
|
||||||
$nightlyBuildDateFile = ManiaControlDir . '/core/nightly_build.txt';
|
$nightlyBuildDateFile = ManiaControlDir . '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);
|
||||||
}
|
}
|
||||||
@ -282,7 +282,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
|
|
||||||
$this->maniaControl->log("Starting Update to Version v{$this->coreUpdateData->version}...");
|
$this->maniaControl->log("Starting Update to Version v{$this->coreUpdateData->version}...");
|
||||||
|
|
||||||
$directories = array('/core/', '/plugins/');
|
$directories = array('core', 'plugins');
|
||||||
if (!FileUtil::checkWritePermissions($directories)) {
|
if (!FileUtil::checkWritePermissions($directories)) {
|
||||||
$message = 'Update not possible: Incorrect File System Permissions!';
|
$message = 'Update not possible: Incorrect File System Permissions!';
|
||||||
if ($player) {
|
if ($player) {
|
||||||
@ -362,7 +362,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function setNightlyBuildDate($date) {
|
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);
|
$success = (bool)file_put_contents($nightlyBuildDateFile, $date);
|
||||||
$this->currentBuildDate = $date;
|
$this->currentBuildDate = $date;
|
||||||
return $success;
|
return $success;
|
||||||
|
Loading…
Reference in New Issue
Block a user