improved directory separator

This commit is contained in:
Steffen Schröder
2014-05-03 21:37:28 +02:00
parent 50fad3f71b
commit 7e5054b58a
9 changed files with 27 additions and 27 deletions

View File

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