mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
* 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:
parent
2cd9f80b34
commit
3a6a1c448a
@ -1202,7 +1202,7 @@ function convert_bytes($size)
|
|||||||
function log_append($file, $str)
|
function log_append($file, $str)
|
||||||
{
|
{
|
||||||
$f = fopen(LOGS . $file, 'a');
|
$f = fopen(LOGS . $file, 'a');
|
||||||
fwrite($f, $str . PHP_EOL);
|
fwrite($f, '[' . date(DateTime::RFC1123) . '] ' . $str . PHP_EOL);
|
||||||
fclose($f);
|
fclose($f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1215,8 +1215,11 @@ function load_config_lua($filename)
|
|||||||
die('ERROR: Cannot find ' . $filename . ' file.');
|
die('ERROR: Cannot find ' . $filename . ' file.');
|
||||||
|
|
||||||
$tempFile = @tempnam('/tmp', 'lua');
|
$tempFile = @tempnam('/tmp', 'lua');
|
||||||
$file = fopen($tempFile, 'w');
|
$file = @fopen($tempFile, 'w');
|
||||||
if(!$file) die('Cannot load server config!');
|
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
|
// TODO: new parser that will also load dofile() includes
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ if($config['server_path'][strlen($config['server_path']) - 1] != '/')
|
|||||||
$config['server_path'] .= '/';
|
$config['server_path'] .= '/';
|
||||||
|
|
||||||
// enable gzip compression if supported by the browser
|
// enable gzip compression if supported by the browser
|
||||||
if($config['gzip_output'] && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) && function_exists('ob_gzhandler'))
|
if($config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler'))
|
||||||
ob_start('ob_gzhandler');
|
ob_start('ob_gzhandler');
|
||||||
|
|
||||||
// cache
|
// cache
|
||||||
|
@ -47,7 +47,7 @@ class OTS_Group extends OTS_Row_DAO implements IteratorAggregate, Countable
|
|||||||
*
|
*
|
||||||
* @param DOMElement $group Group info.
|
* @param DOMElement $group Group info.
|
||||||
*/
|
*/
|
||||||
public function __construct($data)
|
public function __construct($data = array())
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,12 @@ class OTS_Groups_List implements IteratorAggregate, Countable
|
|||||||
$file = $config['data_path'] . 'XML/groups.xml';
|
$file = $config['data_path'] . 'XML/groups.xml';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!@file_exists($file)) {
|
||||||
|
error('Error: Cannot load groups.xml. More info in system/logs/error.log file.');
|
||||||
|
log_append('error.log', '[OTS_Groups_List.php] Fatal error: Cannot load groups.xml (' . $file . '). It doesnt exist.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
global $cache;
|
global $cache;
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
@ -63,7 +69,9 @@ class OTS_Groups_List implements IteratorAggregate, Countable
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$groups = new DOMDocument();
|
$groups = new DOMDocument();
|
||||||
$groups->load($file);
|
error('Error: Cannot load groups.xml. More info in system/logs/error.log file.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// loads groups
|
// loads groups
|
||||||
foreach( $groups->getElementsByTagName('group') as $group)
|
foreach( $groups->getElementsByTagName('group') as $group)
|
||||||
@ -85,7 +93,9 @@ class OTS_Groups_List implements IteratorAggregate, Countable
|
|||||||
{
|
{
|
||||||
// loads DOM document
|
// loads DOM document
|
||||||
$groups = new DOMDocument();
|
$groups = new DOMDocument();
|
||||||
$groups->load($file);
|
error('Error: Cannot load groups.xml. More info in system/logs/error.log file.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// loads groups
|
// loads groups
|
||||||
foreach($groups->getElementsByTagName('group') as $group)
|
foreach($groups->getElementsByTagName('group') as $group)
|
||||||
|
@ -644,7 +644,8 @@ class OTS_Player extends OTS_Row_DAO
|
|||||||
if($tmp)
|
if($tmp)
|
||||||
return $tmp;
|
return $tmp;
|
||||||
|
|
||||||
echo 'error while loading group..';
|
return new OTS_Group();
|
||||||
|
// echo 'error while loading group..';
|
||||||
/*
|
/*
|
||||||
$_id = $this->data['group_id'];
|
$_id = $this->data['group_id'];
|
||||||
$tmpGroup = new OTS_Group;
|
$tmpGroup = new OTS_Group;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user