To add the message to an existing element by ID, simply add a query string with an "el" parameter like so (customid should be the ID of your element): Or trigger it by visiting your page with the added query string, like so: http://www.yourdomain.com/?el=customid To ignore the message when signed in, you may also add a "signedin" parameter to the query string, like so: Or trigger it by visiting your page with the added query string, like so: http://www.yourdomain.com/?signedin=true To spoof a specific IP address, you may also add a "wriauth_ip" parameter to the query string, like so: Or trigger it by visiting your page with the added query string, like so: http://www.yourdomain.com/?wriauth_ip=2.160.0.0 These parameters can be used together in any combination or order. ========================================================================== */ /* ========================================================================== send headers ========================================================================== */ header('Content-Type: application/javascript'); header('Expires: '.gmdate('D, d M Y H:i:s', time()+600).' GMT'); // cache on this file expires in 10 minutes /* ========================================================================== process query strings ========================================================================== */ if (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) { parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $rquery); } else { $rquery = array(); } if (array_key_exists('wriauth_ip', $rquery) && !empty($rquery['wriauth_ip'])) { $ip = $rquery['wriauth_ip']; } elseif (array_key_exists('wriauth_ip', $_GET) && !empty($_GET['wriauth_ip'])) { $ip = $_GET['wriauth_ip']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } if (array_key_exists('signedin', $rquery) && !empty($rquery['signedin'])) { $signedin = $rquery['signedin']; } elseif (array_key_exists('signedin', $_GET) && !empty($_GET['signedin'])) { $signedin = $_GET['signedin']; } else { $signedin = ''; } if (array_key_exists('el', $rquery) && !empty($rquery['el'])) { $el = $rquery['el']; } elseif (array_key_exists('el', $_GET) && !empty($_GET['el'])) { $el = $_GET['el']; } else { $el = ''; } /* ========================================================================== lookup ip in maxmind db ========================================================================== */ $countrycode = 'us'; require_once('/www/proj/php/Wri/MaxmindApi.php'); $maxmind = new Wri_MaxmindApi(); $result = $maxmind->legacyCity($ip); if ($result !== false && $result['country_code'] !== null) { $countrycode = strtolower($result['country_code']); } /* ========================================================================== localize ========================================================================== */ $language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr(strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']), 0, 2) : 'en'; $paragraph = 'This website uses cookies to optimize your experience with our services on the site, as described in our Privacy Policy.'; $button = 'Accept & Close'; switch ($language) { case 'de': $paragraph = 'Diese Website verwendet Cookies, um Ihr Online-Erlebnis mit unseren Diensten zu verbessern, wie in unseren Datenschutzbestimmungen beschrieben.'; $button = 'Akzeptieren und schließen'; break; case 'es': $paragraph = 'Este sitio web utiliza cookies para optimizar y mejorar su experiencia al navegar o usarnuestros servicios, como se lo describe en nuestra política de privacidad.'; $button = 'Aceptar y Cerrar'; break; case 'fr': $paragraph = 'Ce site internet utilise des cookies pour optimiser votre experience de nos services sur le site selon les conditions prévues par notre politique de confidentialité.'; $button = 'Accepter et Fermer'; break; case 'ja': $paragraph = 'このWebサイトでは,お客様がサイト上のサービスをより便利にお使いになれるように,弊社のプライバシーポリシーに記載の通りクッキーを使用しています.'; $button = '同意して閉じる'; break; case 'ko': $paragraph = '이 웹 사이트는 쿠키를 사용하여 개인 정보 보호 정책에 언급된 바와 같이 사이트의 서비스 이용에 대한 사용자 경험을최적화합니다.'; $button = '동의 & 닫기'; break; case 'pt': $paragraph = 'Este site usa cookies para otimizar sua experiência com nossos serviços no site, conforme descrito em nossa Política de Privacidade.'; $button = 'Aceitar e Fechar'; break; case 'ru': $paragraph = 'Этот веб-сайт использует файлы cookie для оптимизации вашего взаимодействия с нашими услугами на сайте, как описано в нашей Политике конфиденциальности.'; $button = 'Принять и закрыть'; break; case 'zh': $paragraph = '本网站使用 cookie 来优化您对我们网站服务的体验,详情可参照我们的隐私政策。'; $button = '同意并关闭'; break; } /* ========================================================================== output js ========================================================================== */ echo "if (window.self == window.top) { var __cookieConsent = {}; __cookieConsent.countryCode = '".$countrycode."'; __cookieConsent.signedIn = '".$signedin."'; __cookieConsent.getDomain = function(d) { var p = d.split('.'); if (p.length <= 2) { return __cookieConsent.buildDomain(p); } p = p.slice(-3); if (p[2].length >= 3 || p[1].length > 3) { return __cookieConsent.buildDomain(p.slice(-2)); } return __cookieConsent.buildDomain(p); } __cookieConsent.buildDomain = function(p) { var d = '.' + p.join('.'); return d; } __cookieConsent.getValue = function() { var n = '__cookie_consent=', a = decodeURIComponent(document.cookie).split(';'); for (var i = 0; i < a.length; i++) { var c = a[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(n) == 0) { return parseInt(c.substring(n.length, c.length)); } } return null; } __cookieConsent.setValue = function(v) { v = parseInt(v); v = v >= 0 && v <= 2 ? v : -1; if (v < 0) return; var d = __cookieConsent.getDomain(window.location.hostname), e = new Date, t = new Date; t.setHours(e.getHours() + 1); switch (v) { case 0: e = t.toUTCString(); break; case 1: e.setFullYear(e.getFullYear() + 100); __cookieConsent.killMessage(); break; case 2: e = t.toUTCString(); __cookieConsent.killMessage(); break; } if (location.protocol == 'https:') { document.cookie = '__cookie_consent='+v+';expires='+e+';domain='+d+';path=/;SameSite=None;Secure'; } else { document.cookie = '__cookie_consent='+v+';expires='+e+';domain='+d+';path=/;SameSite=Lax;'; } } __cookieConsent.killCookie = function() { var d = __cookieConsent.getDomain(window.location.hostname), e = new Date; e.setDate(e.getDate() - 1); if (location.protocol == 'https:') { document.cookie = '__cookie_consent=0;expires='+e+';domain='+d+';path=/;SameSite=None;Secure'; } else { document.cookie = '__cookie_consent=0;expires='+e+';domain='+d+';path=/;SameSite=Lax;'; } } __cookieConsent.killMessage = function() { var w = document.getElementById('__cookie-consent-wrapper'); if (w !== null) { w.style.display = 'none'; w.outerHTML = ''; } } __cookieConsent.appendMessage = function() { __cookieConsent.wrapper = '".$el."'; if (__cookieConsent.wrapper !== '' && document.getElementById(__cookieConsent.wrapper) !== null) { var w = document.createElement('div'); w.id = '__cookie-consent-wrapper'; var ow = document.getElementById(__cookieConsent.wrapper); ow.appendChild(w); } else { var w = document.createElement('div'); w.id = '__cookie-consent-wrapper'; document.body.appendChild(w); } w.innerHTML = '
'; var b = document.getElementById('__cookie-consent-button'); b.onclick = function() { __cookieConsent.setValue(1); } document.removeEventListener('DOMContentLoaded', __cookieConsent.appendMessage); } __cookieConsent.load = function() { var c = __cookieConsent.countryCode, v = __cookieConsent.getValue(); if (__cookieConsent.signedIn == 'true' && (v == null || v == 0)) { __cookieConsent.setValue(1); } else { if (v == null) { var a = ['ad', 'al', 'am', 'at', 'az', 'ba', 'be', 'bg', 'by', 'ch', 'cy', 'cz', 'de', 'dk', 'ee', 'es', 'fi', 'fr', 'ge', 'gb', 'gr', 'hr', 'hu', 'ie', 'is', 'it', 'li', 'lt', 'lu', 'lv', 'mc', 'md', 'me', 'mk', 'mt', 'nl', 'no', 'pl', 'pt', 'ro', 'rs', 'ru', 'se', 'si', 'sk', 'sm', 'tr', 'ua', 'va', 'xk']; if (a.indexOf(c) > -1) { __cookieConsent.setValue(0); if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', __cookieConsent.appendMessage); } else { __cookieConsent.appendMessage(); } } else { __cookieConsent.setValue(2); } } else if (v == 0) { if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', __cookieConsent.appendMessage); } else { __cookieConsent.appendMessage(); } } } }(); }"; die(); /* ========================================================================== un-minified copy of the HTML ========================================================================== */ /* */ /* ========================================================================== copy of the styles in stylesheet format (for overriding the inline styles) ========================================================================== */ /* div#__cookie-consent, div#__cookie-consent * { color: #fff; font-family: Arial, sans-serif; font-weight: 400; line-height: 1.2; margin: 0; padding: 0; z-index: 3000000000; } @keyframes slideupCustom { 0% { bottom: -70px; } 100% { bottom: 0px; } } div#__cookie-consent { animation-name: slideupCustom; animation-delay: 1s; animation-duration: .5s; animation-fill-mode: forwards; animation-iteration-count: 1; animation-timing-function: ease; background: rgba(101, 101, 101, .9); bottom: -70px; height: 70px; left: 0; min-width: 320px; position: fixed; right: 0; width: 100%; } div#__cookie-consent-table { display: table; width: 100%; } div#__cookie-consent-left, div#__cookie-consent-right { display: table-cell; font-size: 13px; height: 70px; vertical-align: middle; } div#__cookie-consent-left { line-height: 1.2; padding: 0 15px; text-align: left; } div#__cookie-consent-right { padding: 0 15px 0 0; text-align: right; } button#__cookie-consent-button { background: #51a9b1; border-radius: 4px; border: 1px solid #6c6c6c; cursor: pointer; padding: 5px 15px; white-space: nowrap; } button#__cookie-consent-button:hover { background: #55b8c0; } a#__cookie-consent-link { color: #bdf4f8; text-decoration: none; } a#__cookie-consent-link:hover { border-bottom: 1px dashed #bdf4f8; color: #bdf4f8; } @media all and (max-width:600px) { div#__cookie-consent-left { font-size: 10px; } button#__cookie-consent-button { font-size: 12px; } button#__cookie-consent-button span:before { clear: both; content: ''; display: table; } } */