Add more information on pushcounter call
This commit is contained in:
parent
7c143c15b7
commit
43d16d73ba
7 changed files with 70 additions and 21 deletions
|
|
@ -30,6 +30,7 @@ require '../../main.inc.php';
|
|||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var HookManager $hookmanager
|
||||
* @var Societe $mysoc
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*
|
||||
|
|
@ -45,6 +46,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("install", "other", "admin"));
|
||||
|
|
@ -58,6 +60,9 @@ if (!$user->admin) {
|
|||
$sfurl = '';
|
||||
$version = '0.0';
|
||||
|
||||
// Version blockedlog
|
||||
$versionbadge = '<span class="badge-text badge-secondary">'.getBlockedLogVersionToShow().'</span>';
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
|
@ -171,14 +176,41 @@ print '<tr class="oddeven"><td>'.$langs->trans("VersionLastUpgrade").'<br><span
|
|||
if (getDolGlobalString('MAIN_VERSION_LAST_UPGRADE')) {
|
||||
print '<span class="badge-text badge-secondary">'.getDolGlobalString('MAIN_VERSION_LAST_UPGRADE').'</span>';
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("VersionLastInstall").'<br><span class="opacitymedium">('.$langs->trans("Database").')</span></td><td>';
|
||||
if (getDolGlobalString('MAIN_VERSION_LAST_INSTALL')) {
|
||||
print '<span class="badge-text badge-secondary">'.getDolGlobalString('MAIN_VERSION_LAST_INSTALL').'</span>';
|
||||
print ' <span class="opacitymedium">'.$langs->trans("VersionLastInstall").': <span class="">'.getDolGlobalString('MAIN_VERSION_LAST_INSTALL').'</span></span>';
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
if (isALNERunningVersion()) {
|
||||
print '<tr class="oddeven nohover">';
|
||||
print '<td width="300">'.$langs->trans("VersionOfModule", $langs->transnoentitiesnoconv("BlockedLog")).'</td><td>';
|
||||
print $versionbadge;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
// Add a complementary optional information
|
||||
$infotoshow = '';
|
||||
if ($mysoc->country_code == 'FR') {
|
||||
$islne = isALNEQualifiedVersion(1, 1);
|
||||
if ($islne) {
|
||||
if (preg_match('/\-/', getBlockedLogVersionToShow())) {
|
||||
// This is an alpha or beta version
|
||||
$infotoshow = $langs->trans("LNECandidateVersionForCertificationFR", getBlockedLogVersionToShow());
|
||||
} else {
|
||||
$infotoshow = $langs->trans("LNECertifiedVersionFR", getBlockedLogVersionToShow());
|
||||
}
|
||||
} else {
|
||||
$infotoshow = $langs->trans("NotCertifiedVersionFR", getBlockedLogVersionToShow());
|
||||
}
|
||||
}
|
||||
if ($infotoshow) {
|
||||
print info_admin($infotoshow, 0, 0, 'info');
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Session
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ if (isALNERunningVersion()) {
|
|||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class BlockedLog
|
|||
public $fk_user = 0;
|
||||
|
||||
/**
|
||||
* @var int|string
|
||||
* @var int|string Note we store in database in gmt time, not in server timezone time
|
||||
*/
|
||||
public $date_creation;
|
||||
|
||||
|
|
@ -1321,12 +1321,14 @@ class BlockedLog
|
|||
|
||||
$previoushash = '';
|
||||
$previousid = 0;
|
||||
$previousdatecreation = 0;
|
||||
|
||||
try {
|
||||
$tmparray = $this->getPreviousHash(1, 0); // This get last record and lock database until insert is done and transaction closed
|
||||
|
||||
$previoushash = $tmparray['previoushash'];
|
||||
$previousid = $tmparray['previousid'];
|
||||
$previousdatecreation = $tmparray['previousdatecreation'];
|
||||
|
||||
$concatenateddata = $this->buildKeyForSignature(); // All the information for the hash (meta data + data saved)
|
||||
|
||||
|
|
@ -1420,7 +1422,7 @@ class BlockedLog
|
|||
// Call remote API service to record the last counter
|
||||
include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
|
||||
try {
|
||||
$resultcall = callApiToPushCounter((int) $this->id, $this->signature, 0, (int) $previousid, $previoushash);
|
||||
$resultcall = callApiToPushCounter((int) $this->id, $this->signature, $this->date_creation, 0, (int) $previousid, $previoushash, $previousdatecreation);
|
||||
} catch (Exception $e) {
|
||||
$error++;
|
||||
$this->error = $e->getMessage();
|
||||
|
|
@ -1601,10 +1603,11 @@ class BlockedLog
|
|||
|
||||
$previousid = 0;
|
||||
$previoussignature = '';
|
||||
$previousdatecreation = 0;
|
||||
|
||||
// Fast search of previous record by searching with beforeid - 1. This is very fast and will work 99% of time.
|
||||
if ($beforeid) {
|
||||
$sql = "SELECT rowid, signature FROM ".MAIN_DB_PREFIX."blockedlog";
|
||||
$sql = "SELECT rowid, signature, date_creation, object_format FROM ".MAIN_DB_PREFIX."blockedlog";
|
||||
$sql .= " WHERE entity = ".((int) $conf->entity);
|
||||
$sql .= " AND rowid = ".((int) $beforeid - 1);
|
||||
$sql .= ($withlock ? " FOR UPDATE " : ""); // To be sure transaction the get last hash to generate the next one will be unlocked once transaction to create new record is finished
|
||||
|
|
@ -1615,6 +1618,11 @@ class BlockedLog
|
|||
if ($obj) {
|
||||
$previousid = $obj->rowid;
|
||||
$previoussignature = $obj->signature;
|
||||
$tz = 'gmt';
|
||||
if (empty($obj->object_format) || $obj->object_format == 'V1') {
|
||||
$tz = 'tzserver';
|
||||
}
|
||||
$previousdatecreation = $this->db->jdate($obj->date_creation, $tz);
|
||||
}
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
|
|
@ -1624,7 +1632,7 @@ class BlockedLog
|
|||
|
||||
if (empty($previoussignature)) {
|
||||
// Note: a select max rowid and then a select to get signature seems not faster due to filter on entity
|
||||
$sql = "SELECT rowid, signature FROM ".MAIN_DB_PREFIX."blockedlog";
|
||||
$sql = "SELECT rowid, signature, date_creation, object_format FROM ".MAIN_DB_PREFIX."blockedlog";
|
||||
if ($beforeid) {
|
||||
$sql .= $this->db->hintindex('entity_rowid', 1);
|
||||
}
|
||||
|
|
@ -1641,6 +1649,11 @@ class BlockedLog
|
|||
if ($obj) {
|
||||
$previousid = $obj->rowid;
|
||||
$previoussignature = $obj->signature;
|
||||
$tz = 'gmt';
|
||||
if (empty($obj->object_format) || $obj->object_format == 'V1') {
|
||||
$tz = 'tzserver';
|
||||
}
|
||||
$previousdatecreation = $this->db->jdate($obj->date_creation, $tz);
|
||||
}
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
|
|
@ -1654,7 +1667,7 @@ class BlockedLog
|
|||
$previoussignature = $this->getOrInitFirstSignature();
|
||||
}
|
||||
|
||||
return array('previousid' => $previousid, 'previoushash' => $previoussignature);
|
||||
return array('previousid' => $previousid, 'previoushash' => $previoussignature, 'previousdatecreation' => $previousdatecreation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -369,14 +369,16 @@ function sumAmountsForUnalterableEvent($block, &$refinvoicefound, &$totalhtamoun
|
|||
/**
|
||||
* Call remote API service to push the last counter and signature
|
||||
*
|
||||
* @param int $id Last counter ID/value
|
||||
* @param string $signature Signature
|
||||
* @param int $test Add property test to 1 if it is for test
|
||||
* @param int $previousid Last counter ID/value
|
||||
* @param string $previoussignature Signature
|
||||
* @return int Return <0 if KO, 0 if nothing done, >0 if OK
|
||||
* @param int $id Counter ID/value of ne record
|
||||
* @param string $signature Signature of new record
|
||||
* @param int $datecreation Date creation of new record
|
||||
* @param int $test Add property test to 1 if it is for test
|
||||
* @param int $previousid Counter ID/value of previous record
|
||||
* @param string $previoussignature Signature of previous record
|
||||
* @param int $previousdatecreation Date creation of previous record
|
||||
* @return int Return <0 if KO, 0 if nothing done, >0 if OK
|
||||
*/
|
||||
function callApiToPushCounter($id, $signature, $test, $previousid, $previoussignature)
|
||||
function callApiToPushCounter($id, $signature, $datecreation, $test, $previousid, $previoussignature, $previousdatecreation)
|
||||
{
|
||||
global $mysoc, $conf;
|
||||
|
||||
|
|
@ -391,7 +393,7 @@ function callApiToPushCounter($id, $signature, $test, $previousid, $previoussign
|
|||
$hash_unique_id = getHashUniqueIdOfRegistration($algo); // The hash of the unique IDof instance
|
||||
|
||||
$t = microtime(true);
|
||||
$micro = sprintf("%06d", (int) ($t - floor($t)) * 1000000);
|
||||
$micro = sprintf("%06d", (int) (($t - floor($t)) * 1000000));
|
||||
|
||||
$data = '';
|
||||
$data .= 'hash_algo=dol_hash-'.urlencode($algo);
|
||||
|
|
@ -407,8 +409,10 @@ function callApiToPushCounter($id, $signature, $test, $previousid, $previoussign
|
|||
|
||||
$data .= '&lastrowid='.(int) $id;
|
||||
$data .= '&lastsignature='.urlencode($signature);
|
||||
$data .= '&lastdatecreation='.urlencode($datecreation);
|
||||
$data .= '&previousrowid='.(int) $previousid;
|
||||
$data .= '&previoussignature='.urlencode($previoussignature);
|
||||
$data .= '&previousdatecreation='.urlencode($previousdatecreation);
|
||||
if ($test) {
|
||||
$data .= '&test=1';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -553,7 +553,7 @@ function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler
|
|||
});
|
||||
</script>';
|
||||
if (count($arraysql)) {
|
||||
print ' - <a class="trforrunsqlshowhide'.$keyforsql.' reposition" href="#" title="'.($langs->trans("ShowHideTheNRequests", count($arraysql))).'">'.$langs->trans("ShowHideDetails").'</a>';
|
||||
print ' - <a class="reposition trforrunsqlshowhide'.$keyforsql.' reposition" href="#" title="'.($langs->trans("ShowHideTheNRequests", count($arraysql))).'">'.$langs->trans("ShowHideDetails").'</a>';
|
||||
} else {
|
||||
print ' - <span class="opacitymedium">'.$langs->trans("ScriptIsEmpty").'</span>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -875,7 +875,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
|
|||
});
|
||||
});
|
||||
</script>';
|
||||
print '<a class="trforrunsqlshowhide" href="#">'.$langs->trans("ShowHideDetails").'</a>';
|
||||
print '<a class="reposition trforrunsqlshowhide" href="#">'.$langs->trans("ShowHideDetails").'</a>';
|
||||
//}
|
||||
|
||||
print '</td></tr>'."\n";
|
||||
|
|
|
|||
|
|
@ -3911,7 +3911,8 @@ if (!function_exists("llxFooter")) {
|
|||
|
||||
if (isModEnabled('blockedlog') && ($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') && $forcepushcounter) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
|
||||
if (!isALNEQualifiedVersion()) {
|
||||
$islne = isALNEQualifiedVersion(1, 1);
|
||||
if (!$islne) {
|
||||
print "\n<!-- NO CALL TO API TO PUSH COUNTER. Not a LNE qualified version -->\n";
|
||||
} elseif (!isRegistrationDataSaved()) {
|
||||
print "\n<!-- NO CALL TO API TO PUSH COUNTER. Registration data not saved -->\n";
|
||||
|
|
@ -3926,7 +3927,7 @@ if (!function_exists("llxFooter")) {
|
|||
|
||||
if ((int) $tmpresult2['previousid']) {
|
||||
// Call remote API service to record the last counter
|
||||
$resultcall = callApiToPushCounter((int) $tmpresult['previousid'], $tmpresult['previoushash'], 1, (int) $tmpresult2['previousid'], $tmpresult2['previoushash']);
|
||||
$resultcall = callApiToPushCounter((int) $tmpresult['previousid'], $tmpresult['previoushash'], $tmpresult['previousdatecreation'], 1, (int) $tmpresult2['previousid'], $tmpresult2['previoushash'], $tmpresult2['previousdatecreation']);
|
||||
|
||||
print "\n<!-- API TO PUSH COUNTER WAS CALLED. Result is ".$resultcall.". You may have log into dolibarr_dolibarrpushcounter.log -->\n";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue