This commit is contained in:
Laurent Destailleur 2021-02-04 22:03:58 +01:00
parent 2a48529aea
commit a4f6c2d0c6
3 changed files with 33 additions and 9 deletions

View File

@ -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 '<td class="nowrap">';
print $form->textwithpicto(dol_trunc($block->signature, '8'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint'.$block->id);
$texttoshow = $langs->trans("Fingerprint").' - '.$langs->trans("Saved").':<br>'.$block->signature;
$texttoshow .= '<br><br>'.$langs->trans("Fingerprint").' - Recalculated sha256(previoushash * data):<br>'.$checkdetail[$block->id]['calculatedsignature'];
$texttoshow .= '<br><span class="opacitymedium">'.$langs->trans("PreviousHash").'='.$checkdetail[$block->id]['previoushash'].'</span>';
//$texttoshow .= '<br>keyforsignature='.$checkdetail[$block->id]['keyforsignature'];
print $form->textwithpicto(dol_trunc($block->signature, '8'), $texttoshow, 1, 'help', '', 0, 2, 'fingerprint'.$block->id);
print '</td>';
// Status
@ -500,7 +510,6 @@ if (is_array($blocks))
} else {
print img_picto($langs->trans('OkCheckFingerprintValidity'), 'statut4');
}
print '</td>';
// Note
@ -520,6 +529,10 @@ if (is_array($blocks))
print '</tr>';
}
}
if (count($blocks) == 0) {
print '<tr><td colspan="12"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
}
print '</table>';

View File

@ -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;
}
}
/**

View File

@ -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(