diff --git a/htdocs/blockedlog/admin/blockedlog_archives.php b/htdocs/blockedlog/admin/blockedlog_archives.php
index 0c498bd6249..486711e67c4 100644
--- a/htdocs/blockedlog/admin/blockedlog_archives.php
+++ b/htdocs/blockedlog/admin/blockedlog_archives.php
@@ -751,92 +751,222 @@ print "\n";
if ($action == 'check' || $action == 'checkconfirmed') {
print '
';
- print '
';
+ print '
';
+
if ($action == 'checkconfirmed') {
- // TODO
-
- print '
';
- print '
File integrity: '.img_picto('', 'tick').'
';
- print '
File authenticity: '.img_picto('', 'tick').'
';
- print '
Detection of database restoration or not allowed line deletion in period: This feature is available only from www.dolibarr.org/onlinecheckarchive.php
';
-
$totalamount = array(
'BILL_VALIDATE' => 0,
'PAYMENT_CUSTOMER_CREATE' => 0
);
+ $reg = array();
+ $refinvoicefound = array();
+ $recalculatedhashsign = '';
+ $recalculatedhashauth = '';
+ $hashsign = '';
+ $hashauth = '';
+ $algosign = '';
+ $algoauth = '';
- foreach ($totalamount as $key => $totalamountperref) {
- if ($key == 'BILL_VALIDATE' || $key == 'PAYMENT_CUSTOMER_CREATE') {
- $totalhttoshow = 0;
- foreach ($totalhtamount[$key] as $value) { // Loop on each module
- $totalhttoshow += $value;
- }
- $totalvattoshow = 0;
- foreach ($totalvatamount[$key] as $value) {
- $totalvattoshow += $value;
- }
- $totaltoshow = 0;
- foreach ($totalamountperref as $value) {
- $totaltoshow += $value;
- }
+ $handle = fopen($fullpath, "r");
+ if ($handle) {
+ $numline=0;
+ while ($line = fgetcsv($handle, 10000, ';', '"', '')) {
+ $numline++;
- print '
'.dolPrintHTML($langs->trans("TotalForAction").' '.$langs->trans('log'.$key)).': ';
+ $linetech = $linerowid = $linedatecreation = $lineactioncode = $lineorigin = '';
+ $lineamountht = $lineamountttc = 0;
+ $lineref = $linedate = $lineuser = $linelinkto = $linelinktype = $linecontent = '';
+ $lineversiondoli = $lineversionsign = $linesignaturedb = $linesignatureexport = '';
- if ($key == 'PAYMENT_CUSTOMER_CREATE') {
- print price($totaltoshow);
+ if ($formatexport == 'VE1') {
+ $linetech = $line[0];
+ $linerowid = $line[1];
+ $linedatecreation = $line[2];
+ $lineactioncode = $line[3];
+ $lineorigin = $line[4];
+ $lineamountht = $line[5];
+ $lineamountttc = $line[6];
+ $lineref = $line[7];
+ $linedate = $line[8];
+ $lineuser = $line[9];
+ $linelinkto = $line[10];
+ $linelinktype = $line[11];
+ $linecontent = $line[12];
+ $lineversiondoli = $line[13];
+ $lineversionsign = $line[14];
+ $linesignaturedb = $line[15];
+ $linesignatureexport = $line[16];
} else {
- print $langs->trans("HT").': ';
- print price($totalhttoshow);
-
- print ' - ';
-
- print $langs->trans("VAT").': ';
- print price($totalvattoshow);
-
- print ' - ';
-
- print $langs->trans("TTC").': ';
- print price($totaltoshow);
+ print 'Line '.$numline.' has format '.$formatexport.' that is not supported';
+ }
+
+ if ($lineactioncode == 'BILL_VALIDATE' || $lineactioncode == 'PAYMENT_CUSTOMER_CREATE') {
+ // For action = BILL_VALIDATE, we keep only first invoice found, but this should not happen because edition of invoice is never possible on
+ // certified version and very difficult on other version.
+ if ($lineactioncode != 'BILL_VALIDATE' || empty($refinvoicefound[$lineref])) {
+ $totalhtamount[$lineactioncode] += $lineamountht;
+ $totalvatamount[$lineactioncode] += ($lineamountttc - $lineamountht);
+ $totalamount[$lineactioncode] += $lineamountttc;
+ }
+ if ($lineactioncode == 'BILL_VALIDATE') {
+ $refinvoicefound[$lineref] = 1;
+ }
+ }
+
+ if (preg_match('/END - ([a-z0-9_]+)=([a-z0-9]+) - ([a-z0-9_]+)=([a-z0-9]+)$/', $linetech, $reg)) {
+ $algosign=$reg[1];
+ $hashsign=$reg[2];
+ $algoauth=$reg[3];
+ $hashauth=$reg[4];
+
+ if ($algosign == 'sha256') {
+ $algo = 'sha256';
+ $recalculatedhashsign = hash_file($algo, $fullpathtmp);
+ }
+ if ($algoauth == 'hmac_sha256') {
+ $algo = 'sha256';
+ $recalculatedhashauth = hash_hmac_file($algo, $fullpathtmp, $secretkey);
+ }
}
- print '
';
}
+ fclose($handle);
+ } else {
+ print 'Failed to open file '.GETPOST('urlfile');
+ }
+
+ print '
';
+ print '
'.$langs->trans("FileIntegrity").': ';
+ if ($recalculatedhashsign && $recalculatedhashsign == $hashsign) {
+ print img_picto('', 'tick', 'class="valignmiddle"');
+ print ' '.$form->textwithpicto('', $algosign.' = '.$recalculatedhashsign);
+ } else {
+ print img_picto('', 'cross', 'class="error valignmiddle"');
+ print ' '.$form->textwithpicto('', $langs->trans("FileHasBeenCorrupted").'
Recalculated '.$recalculatedhashsign.' != Found in file '.$hashsign);
+ }
+ print '
';
+
+ print '
'.$langs->trans("FileAuthenticity").': ';
+ if ($recalculatedhashauth && $recalculatedhashauth == $hashauth) {
+ print img_picto('', 'tick', 'class="valignmiddle"');
+ print ' -
'.$langs->trans("FileWasGeneratedByThisInstance").'';
+ print ' '.$form->textwithpicto('', $algoauth.' = '.$recalculatedhashauth);
+ } elseif ($recalculatedhashsign == $hashsign) {
+ print img_picto('', 'cross', 'class="error valignmiddle"');
+ print ' '.$form->textwithpicto('', $langs->trans("FileNotFromInstance").'
Recalculated '.$recalculatedhashauth.' != Found in file '.$hashauth);
+ } else {
+ print img_picto('', 'cross', 'class="error valignmiddle"');
+ print ' '.$form->textwithpicto('', $langs->trans("FileHasBeenCorruptedOrNotFromInstance").'
Recalculated '.$recalculatedhashauth.' != Found in file '.$hashauth);
+ }
+ print '
';
+
+ print '
Detection of database restoration or not allowed line deletion in period: ';
+ print 'This feature is for the moment available only from https://www.dolibarr.org/onlinecheckarchive.php
';
+ print '
';
+
+ $arraykeys = array('BILL_VALIDATE', 'PAYMENT_CUSTOMER_CREATE');
+ foreach ($arraykeys as $key) {
+ $totalhttoshow = $totalhtamount[$key];
+ $totalvattoshow = $totalvatamount[$key];
+ $totaltoshow = $totalamount[$key];
+
+ print '
'.dolPrintHTML($langs->trans("TotalForAction").' '.$langs->trans('log'.$key)).': ';
+
+ if ($key == 'PAYMENT_CUSTOMER_CREATE') {
+ print price($totaltoshow);
+ } else {
+ print $langs->trans("HT").': ';
+ print price($totalhttoshow);
+
+ print ' - ';
+
+ print $langs->trans("VAT").': ';
+ print price($totalvattoshow);
+
+ print ' - ';
+
+ print $langs->trans("TTC").': ';
+ print price($totaltoshow);
+ }
+ print '
';
}
}
- print '
';
print '