Add option to disable the anonymous ping
This commit is contained in:
parent
bc269462a7
commit
1463302bdd
@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||||||
|
|
||||||
$action=GETPOST('action', 'alpha');
|
$action=GETPOST('action', 'alpha');
|
||||||
$hash_unique_id=GETPOST('hash_unique_id', 'alpha');
|
$hash_unique_id=GETPOST('hash_unique_id', 'alpha');
|
||||||
$hash_algo=GETPOST('hash', 'alpha');
|
$hash_algo=GETPOST('hash_algo', 'alpha');
|
||||||
|
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
@ -53,7 +53,7 @@ print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"])
|
|||||||
// If ok
|
// If ok
|
||||||
if ($action == 'firstpingok')
|
if ($action == 'firstpingok')
|
||||||
{
|
{
|
||||||
// Note: pings are by entities
|
// Note: pings are by installation, done on entity 1.
|
||||||
dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt'));
|
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);
|
dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', $hash_unique_id);
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ if ($action == 'firstpingok')
|
|||||||
// If ko
|
// If ko
|
||||||
elseif ($action == 'firstpingko')
|
elseif ($action == 'firstpingko')
|
||||||
{
|
{
|
||||||
// Note: pings are by entities
|
// Note: pings are by installation, done on entity 1.
|
||||||
dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog'), 'gmt');
|
dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog'), 'gmt');
|
||||||
print 'First ping KO saved for entity '.$conf->entity;
|
print 'First ping KO saved for entity '.$conf->entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -412,7 +412,9 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl
|
|||||||
}
|
}
|
||||||
print '</span>'."\n";
|
print '</span>'."\n";
|
||||||
|
|
||||||
print '<form name="forminstall" style="width: 100%" action="'.$next.'.php'.($param?'?'.$param:'').'" method="POST">'."\n";
|
print '<form name="forminstall" style="width: 100%" action="'.$next.'.php'.($param?'?'.$param:'').'" method="POST"';
|
||||||
|
if ($next == 'step5') print ' autocomplete="off"';
|
||||||
|
print '>'."\n";
|
||||||
print '<input type="hidden" name="testpost" value="ok">'."\n";
|
print '<input type="hidden" name="testpost" value="ok">'."\n";
|
||||||
print '<input type="hidden" name="action" value="'.$action.'">'."\n";
|
print '<input type="hidden" name="action" value="'.$action.'">'."\n";
|
||||||
|
|
||||||
|
|||||||
@ -632,6 +632,25 @@ dolibarr_install_syslog("Exit ".$ret);
|
|||||||
|
|
||||||
dolibarr_install_syslog("- step2: end");
|
dolibarr_install_syslog("- step2: end");
|
||||||
|
|
||||||
|
|
||||||
|
$out = '<input type="checkbox" name="dolibarrpingno" id="dolibarrpingno" value="checked" checked="true"> ';
|
||||||
|
$out .= $langs->trans("MakeAnonymousPing");
|
||||||
|
|
||||||
|
$out .= '<!-- Add js script to manage the uncheck of option to not send the ping -->';
|
||||||
|
$out .= '<script type="text/javascript">';
|
||||||
|
$out .= 'jQuery(document).ready(function(){';
|
||||||
|
$out .= ' document.cookie = "DOLINSTALLNOPING_'.md5($dolibarr_main_instance_unique_id).'=0; path=/"'."\n";
|
||||||
|
$out .= ' jQuery("#dolibarrpingno").click(function() {';
|
||||||
|
$out .= ' if (! $(this).is(\':checked\')) {';
|
||||||
|
$out .= ' console.log("We uncheck anonymous ping");';
|
||||||
|
$out .= ' document.cookie = "DOLINSTALLNOPING_'.md5($dolibarr_main_instance_unique_id).'=1; path=/"'."\n";
|
||||||
|
$out .= ' }';
|
||||||
|
$out .= ' });';
|
||||||
|
$out .= '});';
|
||||||
|
$out .= '</script>';
|
||||||
|
|
||||||
|
print $out;
|
||||||
|
|
||||||
pFooter($ok?0:1, $setuplang);
|
pFooter($ok?0:1, $setuplang);
|
||||||
|
|
||||||
if (isset($db) && is_object($db)) $db->close();
|
if (isset($db) && is_object($db)) $db->close();
|
||||||
|
|||||||
@ -80,7 +80,7 @@ $db=getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->
|
|||||||
if ($db->ok)
|
if ($db->ok)
|
||||||
{
|
{
|
||||||
print '<tr><td><label for="login">'.$langs->trans("Login").' :</label></td><td>';
|
print '<tr><td><label for="login">'.$langs->trans("Login").' :</label></td><td>';
|
||||||
print '<input id="login" name="login" type="text" value="' . (!empty($_GET["login"]) ? GETPOST("login") : (isset($force_install_dolibarrlogin) ? $force_install_dolibarrlogin : '')) . '"' . (@$force_install_noedit == 2 && $force_install_dolibarrlogin !== null ? ' disabled' : '') . '></td></tr>';
|
print '<input id="login" name="login" type="text" value="' . (!empty($_GET["login"]) ? GETPOST("login", 'alpha') : (isset($force_install_dolibarrlogin) ? $force_install_dolibarrlogin : '')) . '"' . (@$force_install_noedit == 2 && $force_install_dolibarrlogin !== null ? ' disabled' : '') . '></td></tr>';
|
||||||
print '<tr><td><label for="pass">'.$langs->trans("Password").' :</label></td><td>';
|
print '<tr><td><label for="pass">'.$langs->trans("Password").' :</label></td><td>';
|
||||||
print '<input type="password" id="pass" name="pass" autocomplete="new-password"></td></tr>';
|
print '<input type="password" id="pass" name="pass" autocomplete="new-password"></td></tr>';
|
||||||
print '<tr><td><label for="pass_verif">'.$langs->trans("PasswordAgain").' :</label></td><td>';
|
print '<tr><td><label for="pass_verif">'.$langs->trans("PasswordAgain").' :</label></td><td>';
|
||||||
|
|||||||
@ -1935,4 +1935,5 @@ AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be de
|
|||||||
RESTRICT_API_ON_IP=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs.
|
RESTRICT_API_ON_IP=Allow available APIs to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can use the available APIs.
|
||||||
RESTRICT_ON_IP=Allow access to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can access.
|
RESTRICT_ON_IP=Allow access to some host IP only (wildcard not allowed, use space between values). Empty means every hosts can access.
|
||||||
BaseOnSabeDavVersion=Based on the library SabreDAV version
|
BaseOnSabeDavVersion=Based on the library SabreDAV version
|
||||||
NotAPublicIp=Not a public IP
|
NotAPublicIp=Not a public IP
|
||||||
|
MakeAnonymousPing=Make an anonymous Ping '+1' to the Dolibarr foundation server (done 1 time only after installation) to allow the foundation to count the number of Dolibarr installation.
|
||||||
@ -2205,7 +2205,7 @@ if (! function_exists("llxFooter"))
|
|||||||
*/
|
*/
|
||||||
function llxFooter($comment = '', $zone = 'private', $disabledoutputofmessages = 0)
|
function llxFooter($comment = '', $zone = 'private', $disabledoutputofmessages = 0)
|
||||||
{
|
{
|
||||||
global $conf, $langs, $user, $object;
|
global $conf, $db, $langs, $user, $object;
|
||||||
global $delayedhtmlcontent;
|
global $delayedhtmlcontent;
|
||||||
global $contextpage, $page, $limit;
|
global $contextpage, $page, $limit;
|
||||||
|
|
||||||
@ -2334,65 +2334,62 @@ if (! function_exists("llxFooter"))
|
|||||||
// Add code for the asynchronous anonymous first ping (for telemetry)
|
// Add code for the asynchronous anonymous first ping (for telemetry)
|
||||||
if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || GETPOST('forceping', 'alpha'))
|
if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || GETPOST('forceping', 'alpha'))
|
||||||
{
|
{
|
||||||
|
//print '<!-- instance_unique_id='.$conf->file->instance_unique_id.' MAIN_FIRST_PING_OK_ID='.$conf->global->MAIN_FIRST_PING_OK_ID.' -->';
|
||||||
if (empty($conf->global->MAIN_FIRST_PING_OK_DATE)
|
if (empty($conf->global->MAIN_FIRST_PING_OK_DATE)
|
||||||
|| (! empty($conf->file->instance_unique_id) && (md5($conf->file->instance_unique_id) != $conf->global->MAIN_FIRST_PING_OK_ID))
|
|| (! empty($conf->file->instance_unique_id) && (md5($conf->file->instance_unique_id) != $conf->global->MAIN_FIRST_PING_OK_ID) && ($conf->global->MAIN_FIRST_PING_OK_ID != 'disabled'))
|
||||||
|| GETPOST('forceping', 'alpha'))
|
|| GETPOST('forceping', 'alpha'))
|
||||||
{
|
{
|
||||||
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";
|
if (empty($_COOKIE['DOLINSTALLNOPING_'.md5($conf->file->instance_unique_id)]))
|
||||||
print "\n<!-- JS CODE TO ENABLE the anonymous Ontime Ping -->\n";
|
{
|
||||||
?>
|
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";
|
||||||
<script>
|
print "\n<!-- JS CODE TO ENABLE the anonymous Ontime Ping -->\n";
|
||||||
jQuery(document).ready(function (tmp) {
|
$hash_unique_id = md5('dolibarr'.$conf->file->instance_unique_id);
|
||||||
$.ajax({
|
?>
|
||||||
method: "POST",
|
<script>
|
||||||
url: "https://ping.dolibarr.org/",
|
jQuery(document).ready(function (tmp) {
|
||||||
timeout: 500, // timeout milliseconds
|
$.ajax({
|
||||||
cache: false,
|
method: "POST",
|
||||||
data: { hash_algo: "md5", hash_unique_id: "<?php echo md5('dolibarr'.$conf->file->instance_unique_id); ?>", action: "dolibarrping", version: "<?php echo (float) DOL_VERSION; ?>", entity: <?php echo (int) $conf->entity; ?> },
|
url: "https://ping.dolibarr.org/",
|
||||||
success: function (data, status, xhr) { // success callback function (data contains body of response)
|
timeout: 500, // timeout milliseconds
|
||||||
console.log("Ping ok");
|
cache: false,
|
||||||
$.ajax({
|
data: { hash_algo: "md5", hash_unique_id: "<?php echo $hash_unique_id; ?>", action: "dolibarrping", version: "<?php echo (float) DOL_VERSION; ?>", entity: <?php echo (int) $conf->entity; ?> },
|
||||||
method: "GET",
|
success: function (data, status, xhr) { // success callback function (data contains body of response)
|
||||||
url: "<?php echo DOL_URL_ROOT.'/core/ajax/pingresult.php'; ?>",
|
console.log("Ping ok");
|
||||||
timeout: 500, // timeout milliseconds
|
$.ajax({
|
||||||
cache: false,
|
method: "GET",
|
||||||
data: { hash_algo: "md5", hash_unique_id: "<?php echo md5($conf->file->instance_unique_id); ?>", action: "firstpingok" },
|
url: "<?php echo DOL_URL_ROOT.'/core/ajax/pingresult.php'; ?>",
|
||||||
});
|
timeout: 500, // timeout milliseconds
|
||||||
},
|
cache: false,
|
||||||
error: function (data,status,xhr) { // success callback function
|
data: { hash_algo: "md5", hash_unique_id: "<?php echo $hash_unique_id; ?>", action: "firstpingok" },
|
||||||
console.log("Ping ko: " + data);
|
});
|
||||||
$.ajax({
|
},
|
||||||
method: "GET",
|
error: function (data,status,xhr) { // success callback function
|
||||||
url: "<?php echo DOL_URL_ROOT.'/core/ajax/pingresult.php'; ?>",
|
console.log("Ping ko: " + data);
|
||||||
timeout: 500, // timeout milliseconds
|
$.ajax({
|
||||||
cache: false,
|
method: "GET",
|
||||||
data: { hash_algo: "md5", hash_unique_id: "<?php echo md5($conf->file->instance_unique_id); ?>", action: "firstpingko", version: "<?php echo (float) DOL_VERSION; ?>" },
|
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 $hash_unique_id; ?>", action: "firstpingko", version: "<?php echo (float) DOL_VERSION; ?>" },
|
||||||
});
|
});
|
||||||
</script>
|
}
|
||||||
<?php
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$now = dol_now();
|
||||||
|
print "\n<!-- NO JS CODE TO ENABLE the anonymous One time Ping. It was disabled -->\n";
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
|
dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt'));
|
||||||
|
dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', 'disabled');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</body>\n";
|
print "</body>\n";
|
||||||
print "</html>\n";
|
print "</html>\n";
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<!-- Disabled. This creates a lot of regression. A better solution is to add a protection on submitted page to avoid action to be done twice.
|
|
||||||
<script type="text/javascript">
|
|
||||||
//Prevent from multiple form sending
|
|
||||||
$(function() {
|
|
||||||
$('input[type=submit]').click(function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
$(this).prop('disabled', true);
|
|
||||||
$(this).closest('form').submit();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
-->
|
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user