Merge branch 'dev' into blog_v3

This commit is contained in:
Fred Tempez 2020-07-13 10:27:45 +02:00
commit 2899195ef8
2 changed files with 20 additions and 20 deletions

View File

@ -125,6 +125,22 @@ class helper {
return ($fileName);
}
/**
* Retourne true si le protocole est en TLS
* @return bool
*/
public static function isHttps() {
if(
(empty($_SERVER['HTTPS']) === false AND $_SERVER['HTTPS'] !== 'off')
OR $_SERVER['SERVER_PORT'] === 443
) {
return true;
} else {
return false;
}
}
/**
* Retourne l'URL de base du site
* @param bool $queryString Affiche ou non le point d'interrogation
@ -132,16 +148,8 @@ class helper {
* @return string
*/
public static function baseUrl($queryString = true, $host = true) {
// Protocol
if(
(empty($_SERVER['HTTPS']) === false AND $_SERVER['HTTPS'] !== 'off')
OR $_SERVER['SERVER_PORT'] === 443
) {
$protocol = 'https://';
}
else {
$protocol = 'http://';
}
// Protocole
$protocol = helper::isHttps() === true ? 'https://' : 'http://';
// Host
if($host) {
$host = $protocol . $_SERVER['HTTP_HOST'];

View File

@ -388,17 +388,9 @@ class user extends common {
AND password_verify($this->getInput('userLoginPassword', helper::FILTER_STRING_SHORT, true), $this->getData(['user', $userId, 'password']))
AND $this->getData(['user', $userId, 'group']) >= self::GROUP_MEMBER
) {
// Protocol
$secure = false;
if(
(empty($_SERVER['HTTPS']) === false AND $_SERVER['HTTPS'] !== 'off')
OR $_SERVER['SERVER_PORT'] === 443
) {
$secure = true;
}
$expire = $this->getInput('userLoginLongTime') ? strtotime("+1 year") : 0;
setcookie('ZWII_USER_ID', $userId, $expire, helper::baseUrl(false, false), '', $secure, true);
setcookie('ZWII_USER_PASSWORD', $this->getData(['user', $userId, 'password']), $expire, helper::baseUrl(false, false), '', $secure, true);
setcookie('ZWII_USER_ID', $userId, $expire, helper::baseUrl(false, false), '', helper::isHttps(), true);
setcookie('ZWII_USER_PASSWORD', $this->getData(['user', $userId, 'password']), $expire, helper::baseUrl(false, false), '', helper::isHttps(), true);
// Accès multiples avec le même compte
$this->setData(['user',$userId,'accessCsrf',$_SESSION['csrf']]);
// Valeurs en sortie lorsque le site est en maintenance et que l'utilisateur n'est pas administrateur