From a4f6c2d0c610f0a5269c6005895aa221ae137af5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Feb 2021 22:03:58 +0100 Subject: [PATCH] More log --- htdocs/blockedlog/admin/blockedlog_list.php | 21 ++++++++++++++++---- htdocs/blockedlog/class/blockedlog.class.php | 15 +++++++++----- htdocs/core/lib/functions.lib.php | 6 ++++++ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 67c6c394815..f618042c994 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -261,7 +261,7 @@ if (GETPOST('withtab', 'alpha')) llxHeader('', $langs->trans("BrowseBlockedLog")); -$MAXLINES = 10000; +$MAXLINES = 100000; $blocks = $block_static->getLog('all', 0, $MAXLINES, $sortfield, $sortorder, $search_fk_user, $search_start, $search_end, $search_ref, $search_amount, $search_code); if (!is_array($blocks)) @@ -433,12 +433,18 @@ if (!empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR)) { // This is version that optimize the memory (but will not report errors that are outside the filter range) $loweridinerror = 0; $checkresult = array(); + $checkdetail = array(); if (is_array($blocks)) { foreach ($blocks as &$block) { - $checksignature = $block->checkSignature(); // Note: this make a sql request at each call, we can't avoid this as the sorting order is various + $tmpcheckresult = $block->checkSignature('', 1); // Note: this make a sql request at each call, we can't avoid this as the sorting order is various + + $checksignature = $tmpcheckresult['checkresult']; + $checkresult[$block->id] = $checksignature; // false if error + $checkdetail[$block->id] = $tmpcheckresult; + if (!$checksignature) { if (empty($loweridinerror)) $loweridinerror = $block->id; @@ -488,7 +494,11 @@ if (is_array($blocks)) // Fingerprint print ''; - print $form->textwithpicto(dol_trunc($block->signature, '8'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint'.$block->id); + $texttoshow = $langs->trans("Fingerprint").' - '.$langs->trans("Saved").':
'.$block->signature; + $texttoshow .= '

'.$langs->trans("Fingerprint").' - Recalculated sha256(previoushash * data):
'.$checkdetail[$block->id]['calculatedsignature']; + $texttoshow .= '
'.$langs->trans("PreviousHash").'='.$checkdetail[$block->id]['previoushash'].''; + //$texttoshow .= '
keyforsignature='.$checkdetail[$block->id]['keyforsignature']; + print $form->textwithpicto(dol_trunc($block->signature, '8'), $texttoshow, 1, 'help', '', 0, 2, 'fingerprint'.$block->id); print ''; // Status @@ -500,7 +510,6 @@ if (is_array($blocks)) } else { print img_picto($langs->trans('OkCheckFingerprintValidity'), 'statut4'); } - print ''; // Note @@ -520,6 +529,10 @@ if (is_array($blocks)) print ''; } } + + if (count($blocks) == 0) { + print ''.$langs->trans("NoRecordFound").''; + } } print ''; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index f6402ca3b04..4e32533074a 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -840,10 +840,11 @@ class BlockedLog /** * Check if current signature still correct compared to the value in chain * - * @param string $previoushash If previous signature hash is known, we can provide it to avoid to make a search of it in database. - * @return boolean True if OK, False if KO + * @param string $previoushash If previous signature hash is known, we can provide it to avoid to make a search of it in database. + * @param int $returnarray 1=Return array of details, 0=Boolean + * @return boolean|array True if OK, False if KO */ - public function checkSignature($previoushash = '') + public function checkSignature($previoushash = '', $returnarray = 0) { if (empty($previoushash)) { @@ -852,7 +853,7 @@ class BlockedLog // Recalculate hash $keyforsignature = $this->buildKeyForSignature(); - $signature_line = dol_hash($keyforsignature, '5'); // Not really usefull + //$signature_line = dol_hash($keyforsignature, '5'); // Not really usefull $signature = dol_hash($previoushash.$keyforsignature, '5'); //var_dump($previoushash); var_dump($keyforsignature); var_dump($signature_line); var_dump($signature); @@ -862,7 +863,11 @@ class BlockedLog $this->error = 'Signature KO'; } - return $res; + if ($returnarray) { + return array('checkresult' => $res, 'calculatedsignature' => $signature, 'previoushash' => $previoushash, 'keyforsignature'=>$keyforsignature); + } else { + return $res; + } } /** diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 61bf5dc87a6..c5b1593cbc5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3363,6 +3363,12 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ } else { $fakey = 'fa-'.$pictowithouttext; } + if ($pictowithouttext == 'payment') { + $fasize = '0.9em'; + } + if ($pictowithouttext == 'loan') { + $fasize = '0.95em'; + } // Define $marginleftonlyshort $arrayconvpictotomarginleftonly = array(