2
0
forked from Wavyzz/dolibarr

Add warning on non https website to axplain why features is broken

This commit is contained in:
Laurent Destailleur
2020-12-18 15:08:00 +01:00
parent 832db82fce
commit 0eaf924d3b
5 changed files with 35 additions and 4 deletions

View File

@@ -2897,6 +2897,26 @@ function getUserRemoteIP()
return $ip;
}
/**
* Return if we are using a HTTPS connexion
* Check HTTPS (no way to be modified by user but may be empty or wrong if user is using a proxy)
* Take HTTP_X_FORWARDED_PROTO (defined when using proxy)
* Then HTTP_X_FORWARDED_SSL
*
* @return boolean True if user is using HTTPS
*/
function getIsHTTPS()
{
$isSecure = false;
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$isSecure = true;
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
$isSecure = true;
}
return $isSecure;
}
/**
* Return a country code from IP. Empty string if not found.
*