Fix trackid must contains an id of instance

This commit is contained in:
Laurent Destailleur
2018-11-16 16:43:13 +01:00
parent 3b193a8a7b
commit 5d596fe584
6 changed files with 155 additions and 32 deletions

View File

@@ -610,9 +610,9 @@ if (! function_exists('dol_getprefix'))
{
/**
* Return a prefix to use for this Dolibarr instance, for session/cookie names or email id.
* This prefix is valid in a web context only and is unique for instance and avoid conflict
* between multi-instances, even when having two instances with one root dir or two instances
* in virtual servers.
* The prefix for session is unique in a web context only and is unique for instance and avoid conflict
* between multi-instances, even when having two instances with one root dir or two instances in virtual servers.
* The prefix for email is unique if MAIL_PREFIX_FOR_EMAIL_ID is set to a value, otherwise value may be same than other instance.
*
* @param string $mode '' (prefix for session name) or 'email' (prefix for email id)
* @return string A calculated prefix
@@ -621,11 +621,15 @@ if (! function_exists('dol_getprefix'))
{
global $conf;
// If MAIL_PREFIX_FOR_EMAIL_ID is set and prefix is for email
if ($mode == 'email' && ! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID))
// If prefix is for email
if ($mode == 'email')
{
if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
else if (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"];
if (! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended)
{
if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
else if (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"];
}
return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
}
if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"]))
@@ -634,7 +638,7 @@ if (! function_exists('dol_getprefix'))
// Use this for a "readable" cookie name
//return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
}
else return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
}
}