cookie consent path + lax

This commit is contained in:
fredtempez 2021-11-22 09:53:33 +01:00
parent fbdf44daa5
commit 7f113a6d82
2 changed files with 41 additions and 26 deletions

View File

@ -219,31 +219,46 @@ core.start = function() {
} }
}); });
/** /**
* Traitement du formulaire cookies * Message sur l'utilisation des cookies
*/ */
$("#cookieForm").submit(function(event){ var analytics = "";
var samesite = "samesite=lax"; if (<?php echo json_encode($this->getData(['config', 'seo', 'analyticsId'])); ?>) {
var getUrl = window.location; analytics = ' grâce au cookie Google Analytics'
var domain = "domain=" + getUrl.host; }
var path = "path=" + getUrl.pathname.split('/')[1]; if(<?php echo json_encode($this->getData(['config', 'cookieConsent'])); ?>) {
var samesite = "samesite=lax"; if(document.cookie.indexOf("ZWII_COOKIE_CONSENT") === -1) {
var e = new Date(); $("body").append(
e.setFullYear(e.getFullYear() + 1); $("<div>").attr("id", "cookieConsent").append(
var expires = "expires=" + e.toUTCString(); $("<span>").html("<p>Ce site utilise des cookies pour assurer l'authentification, améliorer l'expérience utilisateur"+analytics+". <br/>En cliquant sur ”Jaccepte”, vous acceptez lutilisation de ces cookies.</p>"),
$("<span>")
// Crée le cookie d'acceptation Google Analytics si nécessaire .attr("id", "cookieConsentConfirm")
var analytics = "<?php echo $this->getData(['config', 'seo', 'analyticsId']);?>"; .text("Accepter")
if( analytics.length > 0){ .on("click", function() {
document.cookie = "ZWII_COOKIE_GA_CONSENT=" + $("#googleAnalytics").prop("checked") + "<?php echo $_SERVER['PHP_SELF']; ?>" +";" + domain + ";" + path + ";" + samesite + ";" + expires; // Créé le cookie d'acceptation
} var expires = new Date();
document.cookie = "ZWII_COOKIE_CONSENT=<?php echo $_SERVER['PHP_SELF']; ?>;" + domain + ";" + path + ";" + samesite + ";" + expires; expires.setFullYear(expires.getFullYear() + 1);
}); expires = "expires=" + expires.toUTCString();
document.cookie = "ZWII_COOKIE_CONSENT=true;path:/;samesite=lax;" + expires;
$("#cookieConsent .cookieClose").on("click", function() { // Ferme le message
$(this).parents("#cookieConsent").fadeOut(); $(this).parents("#cookieConsent").fadeOut();
}); }),
$("<span>")
.attr("id", "cookieConsentRefuse")
.text("Refuser")
.on("click", function() {
// Créé le cookie d'acceptation
var expires = new Date();
expires.setFullYear(expires.getFullYear() + 1);
expires = "expires=" + expires.toUTCString();
document.cookie = "ZWII_COOKIE_CONSENT=false;path:/;samesite=lax;" + expires;
// Ferme le message
$(this).parents("#cookieConsent").fadeOut();
}),
)
);
}
}
/** /**
* Choix de page dans la barre de membre * Choix de page dans la barre de membre
*/ */

View File

@ -45,7 +45,7 @@ class common {
// Numéro de version // Numéro de version
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/'; const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/';
const ZWII_VERSION = '11.2.00.7'; const ZWII_VERSION = '11.2.00.8';
const ZWII_UPDATE_CHANNEL = "test"; const ZWII_UPDATE_CHANNEL = "test";
public static $actions = []; public static $actions = [];