mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Do no retry ping after error the same month
This commit is contained in:
parent
8e18a08377
commit
b81d223ab3
|
|
@ -53,8 +53,8 @@ print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"])
|
|||
// If ok
|
||||
if ($action == 'firstpingok')
|
||||
{
|
||||
// Note: pings are by installation, done on entity 1.
|
||||
// Once this constant are set, no more ping will be tried (except if we add parameter &forceping=1 on URL). So we can say this are 'first' ping.
|
||||
// Note: pings are per installed instances / entity.
|
||||
// Once this constants are set, no more ping will be tried (except if we add parameter &forceping=1 on URL). So we can say this are 'first' ping.
|
||||
dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt'));
|
||||
dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', $hash_unique_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -2553,72 +2553,81 @@ if (!function_exists("llxFooter"))
|
|||
|
||||
// Add code for the asynchronous anonymous first ping (for telemetry)
|
||||
// You can use &forceping=1 in parameters to force the ping if the ping was already sent.
|
||||
if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || GETPOST('forceping', 'alpha'))
|
||||
$forceping = GETPOST('forceping', 'alpha');
|
||||
if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || $forceping)
|
||||
{
|
||||
//print '<!-- instance_unique_id='.$conf->file->instance_unique_id.' MAIN_FIRST_PING_OK_ID='.$conf->global->MAIN_FIRST_PING_OK_ID.' -->';
|
||||
$hash_unique_id = md5('dolibarr'.$conf->file->instance_unique_id);
|
||||
if (empty($conf->global->MAIN_FIRST_PING_OK_DATE)
|
||||
|| (!empty($conf->file->instance_unique_id) && ($hash_unique_id != $conf->global->MAIN_FIRST_PING_OK_ID) && ($conf->global->MAIN_FIRST_PING_OK_ID != 'disabled'))
|
||||
|| GETPOST('forceping', 'alpha'))
|
||||
|| $forceping)
|
||||
{
|
||||
if (strpos('alpha', DOL_VERSION) > 0) {
|
||||
// No ping done if we are into an alpha version
|
||||
if (strpos('alpha', DOL_VERSION) > 0 && ! $forceping) {
|
||||
print "\n<!-- NO JS CODE TO ENABLE the anonymous Ping. It is an alpha version -->\n";
|
||||
}
|
||||
elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id])) // Cookie is set when we uncheck the checkbox in the installation wizard.
|
||||
elseif (empty($_COOKIE['DOLINSTALLNOPING_'.$hash_unique_id]) || $forceping) // Cookie is set when we uncheck the checkbox in the installation wizard.
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
// MAIN_LAST_PING_KO_DATE
|
||||
// TODO Disable ping if MAIN_LAST_PING_KO_DATE is set and is recent
|
||||
if (! empty($conf->global->MAIN_LAST_PING_KO_DATE) && substr($conf->global->MAIN_LAST_PING_KO_DATE, 0, 6) == dol_print_date(dol_now(), '%Y%m') && ! $forceping) {
|
||||
print "\n<!-- NO JS CODE TO ENABLE the anonymous Ping. An error already occured this month, we will try later. -->\n";
|
||||
} else {
|
||||
|
||||
print "\n".'<!-- Includes JS for Ping of Dolibarr MAIN_FIRST_PING_OK_DATE = '.$conf->global->MAIN_FIRST_PING_OK_DATE.' MAIN_FIRST_PING_OK_ID = '.$conf->global->MAIN_FIRST_PING_OK_ID.' -->'."\n";
|
||||
print "\n<!-- JS CODE TO ENABLE the anonymous Ping -->\n";
|
||||
$url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ? "https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING);
|
||||
// Try to guess the distrib used
|
||||
$distrib = 'standard';
|
||||
if ($_SERVER["SERVER_ADMIN"] == 'doliwamp@localhost') $distrib = 'doliwamp';
|
||||
if (! empty($dolibarr_distrib)) $distrib = $dolibarr_distrib;
|
||||
?>
|
||||
<script>
|
||||
jQuery(document).ready(function (tmp) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "<?php echo $url_for_ping ?>",
|
||||
timeout: 500, // timeout milliseconds
|
||||
cache: false,
|
||||
data: {
|
||||
hash_algo: "md5",
|
||||
hash_unique_id: "<?php echo dol_escape_js($hash_unique_id); ?>",
|
||||
action: "dolibarrping",
|
||||
version: "<?php echo (float) DOL_VERSION; ?>",
|
||||
entity: "<?php echo (int) $conf->entity; ?>",
|
||||
dbtype: "<?php echo dol_escape_js($db->type); ?>",
|
||||
country_code: "<?php echo dol_escape_js($mysoc->country_code); ?>",
|
||||
php_version: "<?php echo phpversion(); ?>",
|
||||
os_version: "<?php echo version_os('smr'); ?>",
|
||||
distrib: "<?php echo $distrib ? $distrib : 'unknown'; ?>"
|
||||
},
|
||||
success: function (data, status, xhr) { // success callback function (data contains body of response)
|
||||
console.log("Ping ok");
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "<?php echo DOL_URL_ROOT.'/core/ajax/pingresult.php'; ?>",
|
||||
timeout: 500, // timeout milliseconds
|
||||
cache: false,
|
||||
data: { hash_algo: "md5", hash_unique_id: "<?php echo dol_escape_js($hash_unique_id); ?>", action: "firstpingok" }, // to update
|
||||
});
|
||||
},
|
||||
error: function (data,status,xhr) { // error callback function
|
||||
console.log("Ping ko: " + data);
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "<?php echo DOL_URL_ROOT.'/core/ajax/pingresult.php'; ?>",
|
||||
timeout: 500, // timeout milliseconds
|
||||
cache: false,
|
||||
data: { hash_algo: "md5", hash_unique_id: "<?php echo dol_escape_js($hash_unique_id); ?>", action: "firstpingko" },
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
print "\n".'<!-- Includes JS for Ping of Dolibarr forceping='.$forceping.' MAIN_FIRST_PING_OK_DATE='.$conf->global->MAIN_FIRST_PING_OK_DATE.' MAIN_FIRST_PING_OK_ID='.$conf->global->MAIN_FIRST_PING_OK_ID.' MAIN_LAST_PING_KO_DATE='.$conf->global->MAIN_LAST_PING_KO_DATE.' -->'."\n";
|
||||
print "\n<!-- JS CODE TO ENABLE the anonymous Ping -->\n";
|
||||
$url_for_ping = (empty($conf->global->MAIN_URL_FOR_PING) ? "https://ping.dolibarr.org/" : $conf->global->MAIN_URL_FOR_PING);
|
||||
// Try to guess the distrib used
|
||||
$distrib = 'standard';
|
||||
if ($_SERVER["SERVER_ADMIN"] == 'doliwamp@localhost') $distrib = 'doliwamp';
|
||||
if (! empty($dolibarr_distrib)) $distrib = $dolibarr_distrib;
|
||||
?>
|
||||
<script>
|
||||
jQuery(document).ready(function (tmp) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "<?php echo $url_for_ping ?>",
|
||||
timeout: 500, // timeout milliseconds
|
||||
cache: false,
|
||||
data: {
|
||||
hash_algo: "md5",
|
||||
hash_unique_id: "<?php echo dol_escape_js($hash_unique_id); ?>",
|
||||
action: "dolibarrping",
|
||||
version: "<?php echo (float) DOL_VERSION; ?>",
|
||||
entity: "<?php echo (int) $conf->entity; ?>",
|
||||
dbtype: "<?php echo dol_escape_js($db->type); ?>",
|
||||
country_code: "<?php echo dol_escape_js($mysoc->country_code); ?>",
|
||||
php_version: "<?php echo phpversion(); ?>",
|
||||
os_version: "<?php echo version_os('smr'); ?>",
|
||||
distrib: "<?php echo $distrib ? $distrib : 'unknown'; ?>"
|
||||
},
|
||||
success: function (data, status, xhr) { // success callback function (data contains body of response)
|
||||
console.log("Ping ok");
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "<?php echo DOL_URL_ROOT.'/core/ajax/pingresult.php'; ?>",
|
||||
timeout: 500, // timeout milliseconds
|
||||
cache: false,
|
||||
data: { hash_algo: "md5", hash_unique_id: "<?php echo dol_escape_js($hash_unique_id); ?>", action: "firstpingok" }, // to update
|
||||
});
|
||||
},
|
||||
error: function (data,status,xhr) { // error callback function
|
||||
console.log("Ping ko: " + data);
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "<?php echo DOL_URL_ROOT.'/core/ajax/pingresult.php'; ?>",
|
||||
timeout: 500, // timeout milliseconds
|
||||
cache: false,
|
||||
data: { hash_algo: "md5", hash_unique_id: "<?php echo dol_escape_js($hash_unique_id); ?>", action: "firstpingko" },
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user