From 020da0f9e30ad4efdb76c2b155331d13a39b3677 Mon Sep 17 00:00:00 2001 From: SylvainLelievre Date: Wed, 24 Nov 2021 07:18:29 +0100 Subject: [PATCH] Modification gestion des cookies --- core/core.js.php | 43 +++++++++++++++++++++---------------------- core/core.php | 10 +++++----- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/core/core.js.php b/core/core.js.php index 0d9f7e64..de79f572 100644 --- a/core/core.js.php +++ b/core/core.js.php @@ -219,31 +219,30 @@ core.start = function() { } }); - /** - * Traitement du formulaire cookies - */ - $("#cookieForm").submit(function(event){ - var samesite = "samesite=lax"; - var getUrl = window.location; - var domain = "domain=" + getUrl.host; - var path = "path=" + getUrl.pathname.split('/')[1]; - var samesite = "samesite=lax"; - var e = new Date(); - e.setFullYear(e.getFullYear() + 1); - var expires = "expires=" + e.toUTCString(); + /** + * Traitement du formulaire cookies + */ + $("#cookieForm").submit(function(event){ + var samesite = "samesite=lax"; + var getUrl = window.location; + var domain = "domain=" + getUrl.host; + var path = "path=" + getUrl.pathname.split('/')[1]; + var samesite = "samesite=lax"; + var e = new Date(); + e.setFullYear(e.getFullYear() + 1); + var expires = "expires=" + e.toUTCString(); // Crée le cookie d'acceptation Google Analytics si nécessaire - var analytics = "getData(['config', 'seo', 'analyticsId']);?>"; - if( analytics.length > 0){ - document.cookie = "ZWII_COOKIE_CONSENT_GA=" + $("#googleAnalytics").prop("checked") + ";" + domain + ";" + path + ";" + samesite + ";" + expires; - } - //document.cookie = "ZWII_COOKIE_CONSENT=true;" + domain + ";" + path + ";" + samesite + ";" + expires; - document.cookie = "ZWII_COOKIE_CONSENT=;" + domain + ";" + path + ";" + samesite + ";" + expires; - }); + var analytics = "getData(['config', 'seo', 'analyticsId']);?>"; + if( analytics.length > 0){ + document.cookie = "ZWII_COOKIE_GA_CONSENT=" + $("#googleAnalytics").prop("checked") + "" +";" + domain + ";" + path + ";" + samesite + ";" + expires; + } + document.cookie = "ZWII_COOKIE_CONSENT=;" + domain + ";" + path + ";" + samesite + ";" + expires; + }); - $("#cookieConsent .cookieClose").on("click", function() { - $(this).parents("#cookieConsent").fadeOut(); - }); + $("#cookieConsent .cookieClose").on("click", function() { + $(this).parents("#cookieConsent").fadeOut(); + }); /** * Choix de page dans la barre de membre diff --git a/core/core.php b/core/core.php index 09286b13..7ea952b8 100644 --- a/core/core.php +++ b/core/core.php @@ -1173,7 +1173,7 @@ class common { */ public function showAnalytics() { if( !empty($code = $this->getData(['config', 'seo', 'analyticsId'])) && - $this->getInput('ZWII_COOKIE_GA_CONSENT') === 'true_'.str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF']))) { + $this->getInput('ZWII_COOKIE_GA_CONSENT') === 'true'.$_SERVER['PHP_SELF']) { echo '