saimod security fixes for user actions, cleanup
This commit is contained in:
parent
58568161b0
commit
7335a4059c
@ -56,21 +56,23 @@ class saimod_sys_security extends \SYSTEM\SAI\SaiModule {
|
||||
if(!\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_SECURITY_RIGHTS_EDIT)){
|
||||
return false;}
|
||||
return \SYSTEM\DBD\SYS_SAIMOD_SECURITY_RIGHT_DELETE::QI(array($id));}
|
||||
|
||||
|
||||
//Todo move to log
|
||||
private static function user_actions($userid){
|
||||
$count = \SYSTEM\DBD\SYS_SAIMOD_SECURITY_USER_LOG_COUNT::Q1(array($userid));
|
||||
$res = \SYSTEM\DBD\SYS_SAIMOD_SECURITY_USER_LOG::QQ(array($userid));
|
||||
$table='';
|
||||
while($r = $res->next()){
|
||||
$r['class_row'] = \SYSTEM\SAI\saimod_sys_log::tablerow_class($r['class']);
|
||||
$r['time'] = self::time_elapsed_string(strtotime($r['time']));
|
||||
$r['time'] = \SYSTEM\time::time_ago_string(strtotime($r['time']));
|
||||
$r['message'] = substr($r['message'],0,255);
|
||||
$table .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_log/tpl/saimod_sys_log_table_row.tpl'),$r);
|
||||
$table .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_security/tpl/saimod_sys_security_user_actions_row.tpl'),$r);
|
||||
}
|
||||
$vars = \SYSTEM\PAGE\text::tag(\SYSTEM\DBD\system_text::TAG_SAI_SECURITY);
|
||||
$vars = array();
|
||||
$vars['count'] = $count['count'];
|
||||
$vars['table'] = $table;
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_log/tpl/saimod_sys_log_table.tpl'), $vars);
|
||||
$vars = array_merge($vars, \SYSTEM\PAGE\text::tag(\SYSTEM\DBD\system_text::TAG_SAI_SECURITY));
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_security/tpl/saimod_sys_security_user_actions.tpl'), $vars);
|
||||
}
|
||||
|
||||
private static function user_rights($userid){
|
||||
@ -109,7 +111,7 @@ class saimod_sys_security extends \SYSTEM\SAI\SaiModule {
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_security_action_user($username){
|
||||
$vars = \SYSTEM\DBD\SYS_SAIMOD_SECURITY_USER::Q1(array($username));
|
||||
$vars['time_elapsed'] = self::time_elapsed_string($vars['last_active']);
|
||||
$vars['time_elapsed'] = \SYSTEM\time::time_ago_string($vars['last_active']);
|
||||
$vars['user_rights'] = array_key_exists('id', $vars) ? self::user_rights($vars['id']) : '';
|
||||
$vars['user_actions'] = array_key_exists('id', $vars) ? self::user_actions($vars['id']) : '';
|
||||
$vars = array_merge($vars,\SYSTEM\PAGE\text::tag(\SYSTEM\DBD\system_text::TAG_SAI_SECURITY));
|
||||
@ -123,12 +125,13 @@ class saimod_sys_security extends \SYSTEM\SAI\SaiModule {
|
||||
$res = \SYSTEM\DBD\SYS_SAIMOD_SECURITY_USERS::QQ(array($search),array($search,$search));
|
||||
while($r = $res->next()){
|
||||
$r['class'] = self::tablerow_class($r['last_active']);
|
||||
$r['time_elapsed'] = self::time_elapsed_string($r['last_active']);
|
||||
$r['time_elapsed'] = \SYSTEM\time::time_ago_string($r['last_active']);
|
||||
$rows .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_security/tpl/saimod_sys_security_user.tpl'),$r);
|
||||
}
|
||||
$vars = \SYSTEM\PAGE\text::tag(\SYSTEM\DBD\system_text::TAG_SAI_SECURITY);
|
||||
$vars = array();
|
||||
$vars['rows'] = $rows;
|
||||
$vars['count'] = $count['count'];
|
||||
$vars = array_merge($vars,\SYSTEM\PAGE\text::tag(\SYSTEM\DBD\system_text::TAG_SAI_SECURITY));
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_security/tpl/saimod_sys_security_users.tpl'),$vars);
|
||||
}
|
||||
|
||||
@ -150,34 +153,6 @@ class saimod_sys_security extends \SYSTEM\SAI\SaiModule {
|
||||
return 'error';
|
||||
}
|
||||
|
||||
private static function time_elapsed_string($ptime)
|
||||
{
|
||||
$etime = time() - $ptime;
|
||||
|
||||
if ($etime < 1)
|
||||
{
|
||||
return '0 seconds';
|
||||
}
|
||||
|
||||
$a = array( 12 * 30 * 24 * 60 * 60 => 'year',
|
||||
30 * 24 * 60 * 60 => 'month',
|
||||
24 * 60 * 60 => 'day',
|
||||
60 * 60 => 'hour',
|
||||
60 => 'minute',
|
||||
1 => 'second'
|
||||
);
|
||||
|
||||
foreach ($a as $secs => $str)
|
||||
{
|
||||
$d = $etime / $secs;
|
||||
if ($d >= 1)
|
||||
{
|
||||
$r = round($d);
|
||||
return $r . ' ' . $str . ($r > 1 ? 's' : '') . ' ago';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a id="menu_security" href="#!security">${sai_menu_security}</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI) && \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_SECURITY);}
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
<div id="table_log">
|
||||
${basic_rows}: ${count}
|
||||
<table class="table table-hover table-condensed">
|
||||
<tr>
|
||||
<th>${time_ago}</th>
|
||||
<th>${table_class}</th>
|
||||
<th>${table_message}</th>
|
||||
<th>${table_file}</th>
|
||||
<th>${table_line}</th>
|
||||
<th>${table_ip}</th>
|
||||
<th>${table_url}</th>
|
||||
<th>${table_user}</th>
|
||||
<th>${table_querytime}</th>
|
||||
</tr>
|
||||
${table}
|
||||
</table>
|
||||
</div>
|
||||
@ -0,0 +1,11 @@
|
||||
<tr class="sai_log_error ${class_row}" onClick="system.load('log(error);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>
|
||||
Loading…
x
Reference in New Issue
Block a user