* log errors instead showing them to users with system directories

* now it will print a notice, and aditionally log full path into
system/logs/error.log
* also, when it fails to load config.lua it will output error also to
error.log
* fix when $_SERVER['HTTP_ACCEPT_ENCODING'] is not set.
This commit is contained in:
slawkens1
2017-08-28 23:58:53 +02:00
parent 2cd9f80b34
commit 3a6a1c448a
5 changed files with 23 additions and 9 deletions

View File

@@ -1202,7 +1202,7 @@ function convert_bytes($size)
function log_append($file, $str)
{
$f = fopen(LOGS . $file, 'a');
fwrite($f, $str . PHP_EOL);
fwrite($f, '[' . date(DateTime::RFC1123) . '] ' . $str . PHP_EOL);
fclose($f);
}
@@ -1215,8 +1215,11 @@ function load_config_lua($filename)
die('ERROR: Cannot find ' . $filename . ' file.');
$tempFile = @tempnam('/tmp', 'lua');
$file = fopen($tempFile, 'w');
if(!$file) die('Cannot load server config!');
$file = @fopen($tempFile, 'w');
if(!$file) {
log_append('error.log', '[functions.php] Cannot load config.lua file. Error: ' . print_r(error_get_last(), true));
die('Cannot load server config! More info in system/logs/error.log file.');
}
// TODO: new parser that will also load dofile() includes