From 19679875df17adb4fd1ac4f598d7e5b04595d663 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 27 Jun 2026 14:44:44 -0400 Subject: [PATCH] Implement cookie consent management across various scripts This commit introduces a comprehensive cookie consent management system by integrating the `fxCookiesAllowMarketing()` function across multiple files. It ensures that marketing-related scripts, such as Facebook Pixel and Google Analytics, are only executed if the user has consented to cookies. Additionally, it enhances the cookie consent UI in `inc_footer.php` and `inc_header.php`, improving user experience and compliance with privacy regulations. The changes also include refactoring of cookie handling functions for better maintainability. --- inc_footer.php | 150 +++++++++++++++---------------------- inc_footer_scripts.php | 16 ++-- inc_header.php | 4 +- php/inc_cookie_consent.php | 87 +++++++++++++++++++++ php/inc_facebook_pixel.php | 4 + php/inc_fonctions.php | 7 +- php/inc_maintenance.php | 6 +- php/inc_start_time.php | 3 + reserver.php | 2 +- 9 files changed, 177 insertions(+), 102 deletions(-) create mode 100644 php/inc_cookie_consent.php diff --git a/inc_footer.php b/inc_footer.php index 9206716..fec3bbd 100644 --- a/inc_footer.php +++ b/inc_footer.php @@ -114,9 +114,7 @@ if (isset($tabEvenement) && $tabEvenement['general']['eve_commanditaires'] == "1
- + cookies
@@ -183,12 +181,25 @@ if (isset($tabEvenement) && $tabEvenement['general']['eve_commanditaires'] == "1 } .cookie-consent-container { - max-width: 1000px; margin: 0 auto; display: flex; justify-content: center; align-items: center; + flex-wrap: wrap; + gap: 10px; + } + + .cookie-consent-actions { + display: flex; + gap: 10px; + flex-wrap: wrap; + justify-content: center; + } + + .cookie-consent-links { + margin-top: 10px; + text-align: center; } #acceptCookies, #rejectCookies { @@ -219,112 +230,69 @@ if (isset($tabEvenement) && $tabEvenement['general']['eve_commanditaires'] == "1 - - - - + - - - - \ No newline at end of file diff --git a/inc_footer_scripts.php b/inc_footer_scripts.php index aec3f7f..6d7bc56 100644 --- a/inc_footer_scripts.php +++ b/inc_footer_scripts.php @@ -2,14 +2,14 @@ - - + + diff --git a/php/inc_cookie_consent.php b/php/inc_cookie_consent.php new file mode 100644 index 0000000..2f7916e --- /dev/null +++ b/php/inc_cookie_consent.php @@ -0,0 +1,87 @@ + [ + 'fr' => 'Nous utilisons des témoins (cookies) pour assurer le bon fonctionnement du site et, avec votre consentement, mesurer l\'audience. Vous pouvez accepter ou refuser les témoins non essentiels sans affecter votre inscription.', + 'en' => 'We use cookies to ensure the site works properly and, with your consent, measure traffic. You may accept or refuse non-essential cookies without affecting your registration.', + ], + 'bouton_acceper_cookies' => [ + 'fr' => 'Tout accepter', + 'en' => 'Accept all', + ], + 'bouton_refuser_cookies' => [ + 'fr' => 'Tout refuser', + 'en' => 'Refuse all', + ], + 'politique_cookie' => [ + 'fr' => 'Politique de témoins', + 'en' => 'Cookie policy', + ], + ]; + + $lang = ($strLangue === 'en') ? 'en' : 'fr'; + $fallback = $defaults[$clef][$lang] ?? $clef; + + if (!function_exists('afficheTexte')) { + return $fallback; + } + + $text = afficheTexte($clef, 0, 1, 1); + + if ($text === '' || $text === $clef || $text === '*' . $clef . '*') { + return $fallback; + } + + return $text; +} diff --git a/php/inc_facebook_pixel.php b/php/inc_facebook_pixel.php index 14997f4..28e7f72 100644 --- a/php/inc_facebook_pixel.php +++ b/php/inc_facebook_pixel.php @@ -13,6 +13,10 @@ // // pixcel facebook +if (!fxCookiesAllowMarketing()) { + return; +} + // Facebook Pixel Code $mem_facebook_pixel=0; //echo $tabEvenement['general']['eve_facebook_pixel']; diff --git a/php/inc_fonctions.php b/php/inc_fonctions.php index 4760202..9c6dcb9 100644 --- a/php/inc_fonctions.php +++ b/php/inc_fonctions.php @@ -7,6 +7,7 @@ define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/..') . '/'); include_once APPLICATION_PATH . 'php/inc_fonctions_sl.php'; include_once APPLICATION_PATH . 'php/inc_fx_doc.php'; include_once APPLICATION_PATH . 'php/inc_settings.php'; +include_once APPLICATION_PATH . 'php/inc_cookie_consent.php'; include_once APPLICATION_PATH . 'php/inc_mysql.php'; include_once APPLICATION_PATH . 'php/inc_dates.php'; include_once APPLICATION_PATH . 'php/inc_mail.php'; @@ -156,6 +157,10 @@ if (isset($_GET['reloadlogin'])) { function fxsessionpixelfacebook($memarray) { + if (!fxCookiesAllowMarketing()) { + return; + } + $_SESSION['pixcel'][] = $memarray; } function fxcount($memarray) @@ -242,7 +247,7 @@ function fxListFieldsValues($tabData, $strKey, $strTable, $strBdd) // créé : 2012-09-18 function tcheckevents($category, $action, $label) { - if ($category == "") + if ($category == "" || !fxCookiesAllowMarketing()) return ""; else { $param = "'_trackEvent', '" . $category . "', '" . $action . "', '" . $label . "', 1"; diff --git a/php/inc_maintenance.php b/php/inc_maintenance.php index 6546059..04ae545 100644 --- a/php/inc_maintenance.php +++ b/php/inc_maintenance.php @@ -114,7 +114,10 @@ if ($tabMaintenance != null) { - + + +