Merge branch 'master' of github.com:gebhardtdasense/system

Conflicts:
	sai/modules/saimod_sys_log/saimod_sys_log.php
This commit is contained in:
Ulf Gebhardt 2013-12-25 20:05:14 +01:00
commit ee209a16bf
6 changed files with 75 additions and 16 deletions

16
docu/code_docu.php Normal file
View File

@ -0,0 +1,16 @@
<?php
namespace SYSTEM\DOCU;
class code_docu {
public static function generate(){
\SYSTEM\autoload::autoload_all();
echo '<pre>';
print_r(\get_declared_classes());
print_r(\get_declared_interfaces());
//print_r(\get_declared_traits());
print_r(\get_defined_constants(true));
print_r(\get_defined_functions());
print_r(\get_defined_vars());
echo '</pre>';
}
}

View File

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

View File

@ -1,8 +1,6 @@
<?php
namespace SYSTEM\SAI;
class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_sys_log_action_truncate(){
@ -127,13 +125,32 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
}
public static function sai_mod__SYSTEM_SAI_saimod_sys_log_action_stats_name_unique_basic($filter){
/*
$children = array();
is_subclass_of
foreach(get_declared_classes() as $class){
if($class instanceof foo) $children[] = $class;
}
*/
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
if(\SYSTEM\system::isSystemDbInfoPG()){
$res = $con->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,'
.'count(*) as count,'
.'count(distinct "'.\SYSTEM\DBD\system_log::FIELD_USER.'") as user_unique,'
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_IP.') as ip_unique,'
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_SERVER_NAME.') as server_name_unique'
.'count(*) as count,'
.'sum(case when not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'SYSTEM\LOG\COUNTER\' and'
.' 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.' = \'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.' = \'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
.' GROUP BY day'
.' ORDER BY day DESC'

View File

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

View File

@ -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;');}
}
}

View File

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