Merge branch 'master' of github.com:gebhardtdasense/system
Conflicts: sai/modules/saimod_sys_log/saimod_sys_log.php
This commit is contained in:
commit
fd0828060d
@ -18,7 +18,7 @@ class log {
|
|||||||
|
|
||||||
set_error_handler ('\SYSTEM\LOG\log::__error_handler');
|
set_error_handler ('\SYSTEM\LOG\log::__error_handler');
|
||||||
set_exception_handler ('\SYSTEM\LOG\log::__exception_handler');
|
set_exception_handler ('\SYSTEM\LOG\log::__exception_handler');
|
||||||
register_shutdown_function ( '\SYSTEM\LOG\log::__shutdown_handler' );
|
register_shutdown_function ('\SYSTEM\LOG\log::__shutdown_handler' );
|
||||||
ob_start ('\SYSTEM\LOG\log::__fatal_error_handler');
|
ob_start ('\SYSTEM\LOG\log::__fatal_error_handler');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -125,13 +125,6 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_log_action_stats_name_unique_basic($filter){
|
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());
|
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
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,'
|
$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,'
|
||||||
@ -210,9 +203,9 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
|||||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
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,'
|
$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(*) as count,'
|
||||||
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_FILE.') as file_unique,'
|
.'count(distinct "'.\SYSTEM\DBD\system_log::FIELD_USER.'") as user_unique,'
|
||||||
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_LINE.') as line_unique,'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_IP.') as ip_unique,'
|
||||||
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_CLASS.') as class_unique'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_SERVER_NAME.') as server_name_unique'
|
||||||
.' FROM '.\SYSTEM\DBD\system_log::NAME_PG
|
.' FROM '.\SYSTEM\DBD\system_log::NAME_PG
|
||||||
.' GROUP BY day'
|
.' GROUP BY day'
|
||||||
.' ORDER BY day DESC'
|
.' ORDER BY day DESC'
|
||||||
@ -240,10 +233,10 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
|||||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
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,'
|
$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(*) as count,'
|
||||||
.'count(distinct "'.\SYSTEM\DBD\system_log::FIELD_USER.'") as user_unique,'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_SERVER_NAME.') as server_name_unique,'
|
||||||
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_IP.') as ip_unique,'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_SERVER_PORT.') as server_port_unique,'
|
||||||
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_HTTP_REFERER.') as http_referer_unique,'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_REQUEST_URI.') as request_uri_unique,'
|
||||||
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_HTTP_USER_AGENT.') as http_user_agent_unique'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_POST.') as post_unique'
|
||||||
.' FROM '.\SYSTEM\DBD\system_log::NAME_PG
|
.' FROM '.\SYSTEM\DBD\system_log::NAME_PG
|
||||||
.' GROUP BY day'
|
.' GROUP BY day'
|
||||||
.' ORDER BY day DESC'
|
.' ORDER BY day DESC'
|
||||||
@ -272,8 +265,9 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
|||||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
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,'
|
$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(*) as count,'
|
||||||
.'count(distinct "'.\SYSTEM\DBD\system_log::FIELD_USER.'") as user_unique,'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_FILE.') as file_unique,'
|
||||||
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_IP.') as ip_unique'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_LINE.') as line_unique,'
|
||||||
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_CLASS.') as class_unique'
|
||||||
.' FROM '.\SYSTEM\DBD\system_log::NAME_PG
|
.' FROM '.\SYSTEM\DBD\system_log::NAME_PG
|
||||||
.' GROUP BY day'
|
.' GROUP BY day'
|
||||||
.' ORDER BY day DESC'
|
.' ORDER BY day DESC'
|
||||||
@ -300,19 +294,10 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
|||||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
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,'
|
$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(*) as count,'
|
||||||
.'sum(case when not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'SYSTEM\LOG\COUNTER\' and'
|
.'count(distinct "'.\SYSTEM\DBD\system_log::FIELD_USER.'") as user_unique,'
|
||||||
.' not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'SYSTEM\LOG\INFO\' and'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_IP.') as ip_unique,'
|
||||||
.' not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'INFO\' and'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_HTTP_REFERER.') as http_referer_unique,'
|
||||||
.' not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'SYSTEM\LOG\DEPRECATED\' and'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_HTTP_USER_AGENT.') as http_user_agent_unique'
|
||||||
.' not '.\SYSTEM\DBD\system_log::FIELD_CLASS.' = \'EPRECATED\' '
|
|
||||||
.'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\' '
|
|
||||||
.'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
|
.' FROM '.\SYSTEM\DBD\system_log::NAME_PG
|
||||||
.' GROUP BY day'
|
.' GROUP BY day'
|
||||||
.' ORDER BY day DESC'
|
.' ORDER BY day DESC'
|
||||||
@ -350,10 +335,8 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
|||||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
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,'
|
$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(*) as count,'
|
||||||
.'avg('.\SYSTEM\DBD\system_log::FIELD_QUERYTIME.') as querytime_avg,'
|
.'count(distinct "'.\SYSTEM\DBD\system_log::FIELD_USER.'") as user_unique,'
|
||||||
.'max('.\SYSTEM\DBD\system_log::FIELD_QUERYTIME.') as querytime_max,'
|
.'count(distinct '.\SYSTEM\DBD\system_log::FIELD_IP.') as ip_unique'
|
||||||
.'min('.\SYSTEM\DBD\system_log::FIELD_QUERYTIME.') as querytime_min,'
|
|
||||||
.'variance('.\SYSTEM\DBD\system_log::FIELD_QUERYTIME.') as querytime_var'
|
|
||||||
.' FROM '.\SYSTEM\DBD\system_log::NAME_PG
|
.' FROM '.\SYSTEM\DBD\system_log::NAME_PG
|
||||||
.' GROUP BY day'
|
.' GROUP BY day'
|
||||||
.' ORDER BY day DESC'
|
.' ORDER BY day DESC'
|
||||||
@ -462,17 +445,10 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
|||||||
$table='';
|
$table='';
|
||||||
while($r = $res->next()){
|
while($r = $res->next()){
|
||||||
//print_r($r);
|
//print_r($r);
|
||||||
$table .= '<tr class="sai_log_error '.self::tablerow_class($r['class']).'" error="'.$r['ID'].'">'.
|
$r['class_row'] = self::tablerow_class($r['class']);
|
||||||
'<td>'.self::time_elapsed_string(strtotime($r['time'])).'</td>'.
|
$r['time'] = self::time_elapsed_string(strtotime($r['time']));
|
||||||
'<td>'.$r['class'].'</td>'.
|
$r['message'] = substr($r['message'],0,255);
|
||||||
'<td style="word-break: break-all;">'.substr($r['message'],0,255).'</td>'.
|
$table .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_log/saimod_sys_log_table_row.tpl'),$r);
|
||||||
'<td style="word-break: break-all;">'.$r['file'].'</td>'.
|
|
||||||
'<td>'.$r['line'].'</td>'.
|
|
||||||
'<td>'.$r['ip'].'</td>'.
|
|
||||||
'<td style="word-break: break-all;">'.$r['server_name'].':'.$r['server_port'].$r['request_uri'].'</td>'.
|
|
||||||
'<td>'.$r['username'].'</td>'.
|
|
||||||
'<td>'.$r['querytime'].'</td>'.
|
|
||||||
'</tr>';
|
|
||||||
}
|
}
|
||||||
$vars = array();
|
$vars = array();
|
||||||
$vars['count'] = $count;
|
$vars['count'] = $count;
|
||||||
|
|||||||
11
sai/modules/saimod_sys_log/saimod_sys_log_table_row.tpl
Normal file
11
sai/modules/saimod_sys_log/saimod_sys_log_table_row.tpl
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<tr class="sai_log_error ${class_row}" error="${ID}">
|
||||||
|
<td>${time}</td>
|
||||||
|
<td>${class}</td>
|
||||||
|
<td style="word-break: break-all;">${message}</td>
|
||||||
|
<td style="word-break: break-all;">${file}</td>
|
||||||
|
<td>${line}</td>
|
||||||
|
<td>${ip}</td>
|
||||||
|
<td style="word-break: break-all;">${server_name}:${server_port}${request_uri}</td>
|
||||||
|
<td>${username}</td>
|
||||||
|
<td>${querytime}</td>
|
||||||
|
</tr>
|
||||||
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SYSTEM\SAI;
|
namespace SYSTEM\SAI;
|
||||||
|
|
||||||
class saimod_sys_sai extends \SYSTEM\SAI\SaiModule {
|
class saimod_sys_sai extends \SYSTEM\SAI\SaiModule {
|
||||||
|
|||||||
@ -24,18 +24,21 @@ class saimod_sys_security extends \SYSTEM\SAI\SaiModule {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function html_content_users(){
|
public static function html_content_users($search = null){
|
||||||
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
$con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
|
||||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
if(\SYSTEM\system::isSystemDbInfoPG()){
|
||||||
$res = $con->query('SELECT id,username,email,joindate,locale,last_active,account_flag FROM system.user ORDER BY last_active DESC;');
|
$res = $con->query('SELECT id,username,email,joindate,locale,last_active,account_flag FROM system.user ORDER BY last_active DESC LIMIT 100;');
|
||||||
|
$res2 = $con->query('SELECT count(*) as count FROM system.user;');
|
||||||
} else {
|
} else {
|
||||||
$res = $con->query('SELECT id,username,email,joindate,locale,last_active,account_flag FROM system_user ORDER BY last_active DESC;');
|
$res = $con->query('SELECT id,username,email,joindate,locale,last_active,account_flag FROM system_user ORDER BY last_active DESC LIMIT 100;');
|
||||||
|
$res2 = $con->query('SELECT count(*) as count FROM system.user;');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pcount = $res2->next();
|
||||||
$now = microtime(true);
|
$count = $pcount['count'];
|
||||||
|
$result = 'Users: '.$count.
|
||||||
$result = '<table class="table table-hover table-condensed" style="overflow: auto;">'.
|
'</br><input type="text" value="Search email or username" size="30"/>'.
|
||||||
|
'<table class="table table-hover table-condensed" style="overflow: auto;">'.
|
||||||
'<tr>'.'<th>'.'ID'.'</th>'.'<th>'.'Username'.'</th>'.'<th>'.'E-Mail'.'</th>'.'<th>'.'JoinDate'.'</th>'.'<th>'.'Locale'.'</th>'.'<th>'.'Last Active'.'</th>'.'<th>'.'Flag'.'</th>'.'<th style="width: 110px;">'.'Rights'.'</th><th>reset password</th>'.'</tr>';
|
'<tr>'.'<th>'.'ID'.'</th>'.'<th>'.'Username'.'</th>'.'<th>'.'E-Mail'.'</th>'.'<th>'.'JoinDate'.'</th>'.'<th>'.'Locale'.'</th>'.'<th>'.'Last Active'.'</th>'.'<th>'.'Flag'.'</th>'.'<th style="width: 110px;">'.'Rights'.'</th><th>reset password</th>'.'</tr>';
|
||||||
while($r = $res->next()){
|
while($r = $res->next()){
|
||||||
if(\SYSTEM\system::isSystemDbInfoPG()){
|
if(\SYSTEM\system::isSystemDbInfoPG()){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user