From 59ca6e5ab9fa5669ce17b7640d1a60bab68d5502 Mon Sep 17 00:00:00 2001 From: rylon Date: Wed, 25 Dec 2013 09:38:10 +0100 Subject: [PATCH] fixes for saimod log and security,header fixes, autoload_all --- sai/modules/saimod_sys_log/saimod_sys_log.js | 2 +- sai/modules/saimod_sys_log/saimod_sys_log.php | 15 ++++++++---- security/Security.php | 5 ++-- system/HEADER.php | 15 +++++++----- system/autoload.php | 24 +++++++++++++++++++ 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/sai/modules/saimod_sys_log/saimod_sys_log.js b/sai/modules/saimod_sys_log/saimod_sys_log.js index 5aad7b8..7076bc1 100644 --- a/sai/modules/saimod_sys_log/saimod_sys_log.js +++ b/sai/modules/saimod_sys_log/saimod_sys_log.js @@ -122,7 +122,7 @@ function load_visualisation(id, filter){ }); $.each(json, function(key, value){first = true; data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [(v == null || parseFloat(v) <= 0) ? 0.1 : parseFloat(v)];}}));}); - var options = {title: id, aggregationTarget: 'category', selectionMode: 'multiple', /*focusTarget: 'category',*/ chartArea:{left:100,top:40}, vAxis:{logScale: true}, interpolateNulls: false, width: "1200", height: "500"}; + var options = {title: id, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{left:100,top:40}, vAxis:{logScale: true}, interpolateNulls: false, width: "1200", height: "500"}; new google.visualization.LineChart(document.getElementById(id)).draw(data, options); }); } \ No newline at end of file diff --git a/sai/modules/saimod_sys_log/saimod_sys_log.php b/sai/modules/saimod_sys_log/saimod_sys_log.php index e01ee51..ed55a02 100644 --- a/sai/modules/saimod_sys_log/saimod_sys_log.php +++ b/sai/modules/saimod_sys_log/saimod_sys_log.php @@ -1,8 +1,6 @@ query('SELECT to_timestamp(extract(epoch from '.\SYSTEM\DBD\system_log::FIELD_TIME.')::int - (extract(epoch from '.\SYSTEM\DBD\system_log::FIELD_TIME.')::int % '.$filter.')) as day,' @@ -102,13 +107,15 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule { .' not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'SYSTEM\LOG\INFO\' and' .' not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'INFO\' and' .' not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'SYSTEM\LOG\DEPRECATED\' and' - .' not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'EPRECATED\' ' + .' not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'DEPRECATED\' and ' + .' not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'PreprocessingLog\' ' .'then 1 else 0 end) class_fail,' .'sum(case when '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'SYSTEM\LOG\INFO\' or ' .\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'SYSTEM\LOG\INFO\' or ' .\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'INFO\' or ' .\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'SYSTEM\LOG\DEPRECATED\' or ' - .\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'EPRECATED\' ' + .\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'DEPRECATED\' or ' + .\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'PreprocessingLog\' ' .'then 1 else 0 end) class_log,' .'sum(case when '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'SYSTEM\LOG\COUNTER\' then 1 else 0 end) class_sucess' .' FROM '.\SYSTEM\DBD\system_log::NAME_PG diff --git a/security/Security.php b/security/Security.php index 3dad779..62d6ce8 100644 --- a/security/Security.php +++ b/security/Security.php @@ -270,10 +270,9 @@ class Security { self::startSession(); return (isset($_SESSION['user']) && $_SESSION['user'] instanceof User);} private static function startSession(){ - if(!isset($_SESSION)){ - session_start();} + if(!isset($_SESSION) && !headers_sent()){ + \session_start();} } - //This functions is called from \SYSTEM\locale::set() public static function _db_setLocale($lang){ $user = self::getUser(); diff --git a/system/HEADER.php b/system/HEADER.php index 93ee28c..3dd8ae1 100644 --- a/system/HEADER.php +++ b/system/HEADER.php @@ -7,15 +7,18 @@ class HEADER { $file = null; $line = null; if(headers_sent($file, $line)){ - throw new \SYSTEM\LOG\ERROR('Header already sent @ '.$file.' line '.$line);} + new \SYSTEM\LOG\WARNING('Header already sent @ '.$file.' line '.$line); + return false;} + return true; } public static function JSON(){ - self::checkHeader(); - header('Access-Control-Allow-Origin: *');//allow cross domain calls - header('content-type: application/json'); + if(self::checkHeader()){ + header('Access-Control-Allow-Origin: *');//allow cross domain calls + header('content-type: application/json');} } public static function PNG(){ - self::checkHeader(); - header('content-type:image/png;');} + if(self::checkHeader()){ + header('content-type:image/png;');} + } } \ No newline at end of file diff --git a/system/autoload.php b/system/autoload.php index da832f6..38a0c1b 100644 --- a/system/autoload.php +++ b/system/autoload.php @@ -67,4 +67,28 @@ class autoload { return true; } + + private static function file_extension($filename){ + $path_info = pathinfo($filename); + return array_key_exists('extension', $path_info) ? strtolower($path_info['extension']) : NULL; + } + + //for docu we need all classes actually declared + public static function autoload_all(){ + foreach(self::$files as $file){ + require_once $file[2];} + + foreach(self::$folders as $folder){ + if ($handle = opendir($folder[1])) { + while (false !== ($file = readdir($handle))) { + if ( $file != "." && $file != ".." && + self::file_extension($file) == 'php' && + !class_exists($folder[0].'\\'.substr($file,0,count($file)-5),false)) { + require_once $folder[1].'/'.$file; + } + } + } + closedir($handle); + } + } } \ No newline at end of file