LSaddon::accesslog: Fix PHP < 7.3 compatibility

This commit is contained in:
Benjamin Renard 2022-07-20 14:53:28 +02:00
parent c0d8f9f81a
commit 75258d9744

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;
@ -118,7 +118,7 @@ function getEntryAccessLog($dn) {
'reqMod', 'reqMod',
'reqOld', 'reqOld',
), ),
), )
); );
if (!is_array($data)) { if (!is_array($data)) {
return; return;
@ -151,7 +151,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 +193,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
); );
} }