Compare commits

..

2 commits

Author SHA1 Message Date
Benjamin Renard
e23ee2f209 LSaddon::accesslog: show events author 2022-07-20 14:56:16 +02:00
Benjamin Renard
75258d9744 LSaddon::accesslog: Fix PHP < 7.3 compatibility 2022-07-20 14:53:28 +02:00
5 changed files with 3577 additions and 3557 deletions

View file

@ -54,7 +54,7 @@ function LSaddon_accesslog_support() {
'getEntryAccessLog', 'getEntryAccessLog',
'cli_getEntryAccessLog', 'cli_getEntryAccessLog',
'Get entry access log', 'Get entry access log',
'[entry DN] [page]', '[entry DN] [page]'
); );
} }
return true; return true;
@ -64,6 +64,12 @@ function mapAccessLogEntry(&$entry) {
$attrs = $entry['attrs']; $attrs = $entry['attrs'];
$entry['start'] = LSldap::parseDate(LSldap::getAttr($attrs, 'reqStart')); $entry['start'] = LSldap::parseDate(LSldap::getAttr($attrs, 'reqStart'));
$entry['end'] = LSldap::parseDate(LSldap::getAttr($attrs, 'reqEnd')); $entry['end'] = LSldap::parseDate(LSldap::getAttr($attrs, 'reqEnd'));
$entry['author_dn'] = LSldap::getAttr($attrs, 'reqAuthzID');
$entry['author_rdn'] = (
$entry['author_dn']?
explode('=', explode(',', $entry['author_dn'])[0])[1]:
null
);
$entry['type'] = LSldap::getAttr($attrs, 'reqType'); $entry['type'] = LSldap::getAttr($attrs, 'reqType');
$entry['result'] = ldap_err2str(LSldap::getAttr($attrs, 'reqResult')); $entry['result'] = ldap_err2str(LSldap::getAttr($attrs, 'reqResult'));
$entry['message'] = LSldap::getAttr($attrs, 'reqMessage'); $entry['message'] = LSldap::getAttr($attrs, 'reqMessage');
@ -112,13 +118,14 @@ function getEntryAccessLog($dn) {
'attributes' => array( 'attributes' => array(
'reqStart', 'reqStart',
'reqEnd', 'reqEnd',
'reqAuthzID',
'reqType', 'reqType',
'reqResult', 'reqResult',
'reqMessage', 'reqMessage',
'reqMod', 'reqMod',
'reqOld', 'reqOld',
), ),
), )
); );
if (!is_array($data)) { if (!is_array($data)) {
return; return;
@ -151,7 +158,7 @@ function getEntryAccessLogPage($dn, $page = false, $nbByPage = 30) {
'logs' => array_slice( 'logs' => array_slice(
$_SESSION['entryAccessLogPages'][$dn], $_SESSION['entryAccessLogPages'][$dn],
$page > 1 ? (($page - 1) * $nbByPage) - 1 : 0, $page > 1 ? (($page - 1) * $nbByPage) - 1 : 0,
$nbByPage, $nbByPage
) )
); );
} }
@ -193,6 +200,6 @@ function cli_getEntryAccessLog($command_args) {
$page = isset($command_args[1]) ? intval($command_args[1]) : 1; $page = isset($command_args[1]) ? intval($command_args[1]) : 1;
echo json_encode( echo json_encode(
getEntryAccessLogPage($dn, $page), getEntryAccessLogPage($dn, $page),
JSON_PRETTY_PRINT, JSON_PRETTY_PRINT
); );
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,7 @@
<thead> <thead>
<tr> <tr>
<th>{tr msg="Date"}</th> <th>{tr msg="Date"}</th>
<th>{tr msg="Author"}</th>
<th>{tr msg="Operation"}</th> <th>{tr msg="Operation"}</th>
<th>{tr msg="Result"}</th> <th>{tr msg="Result"}</th>
<th>{tr msg="Details"}</th> <th>{tr msg="Details"}</th>
@ -16,6 +17,7 @@
{foreach $page.logs as $log} {foreach $page.logs as $log}
<tr> <tr>
<td>{$log.start->format('Y/m/d H:i:s')}</td> <td>{$log.start->format('Y/m/d H:i:s')}</td>
<td class="center">{if $log.author_dn}<span title='{$log.author_dn|escape:quotes}' class='LStips'>{$log.author_rdn}</span>{/if}</td>
<td class="center">{$log.type}</td> <td class="center">{$log.type}</td>
<td class="center">{$log.result}{if $log.message} <img class='LStips' src="{img name='help'}" alt="?" title='{$log.message|escape:quotes}'/>{/if}</td> <td class="center">{$log.result}{if $log.message} <img class='LStips' src="{img name='help'}" alt="?" title='{$log.message|escape:quotes}'/>{/if}</td>
<td> <td>