Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Functions

  • script_cookie_directive_add_get_params
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: 
 3: /**
 4:  * Description: Cookie Directive
 5:  *
 6:  * @package Module
 7:  * @subpackage ScriptCookieDirective
 8:  * @author ilia.schwarz
 9:  * @author claus.schunk@4fb.de
10:  * @copyright four for business AG <www.4fb.de>
11:  * @license http://www.contenido.org/license/LIZENZ.txt
12:  * @link http://www.4fb.de
13:  * @link http://www.contenido.org
14:  */
15: 
16: if (!cRegistry::getBackendSessionId()) {
17: 
18:     $session = cRegistry::getSession();
19:     $params = session_get_cookie_params();
20: 
21:     if (array_key_exists('acceptCookie', $_GET)) {
22:         // Check value in get, if js is off
23:         $allowCookie = $_GET['acceptCookie'] === '1'? 1 : 0;
24:         setcookie('allowCookie', $allowCookie, 0, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
25: 
26:         // Save value
27:         $session->register('allowCookie');
28:     } elseif (array_key_exists('allowCookie', $_COOKIE)) {
29:         // Check value in cookies
30:         $allowCookie = $_COOKIE['allowCookie'] === '1'? 1 : 0;
31: 
32:         // Save value
33:         $session->register('allowCookie');
34:     }
35: 
36:     // Show notify
37:     if (!isset($allowCookie)) {
38: 
39:         $tpl = cSmartyFrontend::getInstance();
40: 
41:         // build translations
42:         $tpl->assign('trans', array(
43:             'title' => mi18n("TITLE"),
44:             'infoText' => mi18n("INFOTEXT"),
45:             'userInput' => mi18n("USERINPUT"),
46:             'accept' => mi18n("ACCEPT"),
47:             'decline' => mi18n("DECLINE")
48:         ));
49: 
50:         /**
51:          *
52:          * @param string $uri
53:          * @return string
54:          */
55:         if (!function_exists('script_cookie_directive_add_get_params')) {
56:             function script_cookie_directive_add_get_params($uri) {
57:                 foreach ($_GET as $getKey => $getValue) {
58:                     // do not add already added GET parameters to redirect url
59:                     if (cString::findFirstPos($uri, '?' . $getKey . '=') !== false
60:                         || cString::findFirstPos($uri, '&' . $getKey . '=') !== false
61:                     ) {
62:                         continue;
63:                     }
64:                     if (cString::findFirstPos($uri, '?') === false) {
65:                         $uri .= '?';
66:                     } else {
67:                         $uri .= '&';
68:                     }
69:                     $uri .= htmlentities($getKey) . '=' . htmlentities($getValue);
70:                 }
71: 
72:                 return $uri;
73:             }
74:         }
75: 
76:         // build accept url
77:         $acceptUrl = script_cookie_directive_add_get_params(cUri::getInstance()->build(array(
78:             'idart' => cRegistry::getArticleId(),
79:             'lang' => cRegistry::getLanguageId(),
80:             'acceptCookie' => 1
81:         ), true));
82: 
83:         $tpl->assign('pageUrlAccept', $acceptUrl);
84: 
85:         // build deny url
86:         $denyUrl = script_cookie_directive_add_get_params(cUri::getInstance()->build(array(
87:             'idart' => cRegistry::getArticleId(),
88:             'lang' => cRegistry::getLanguageId(),
89:             'acceptCookie' => 0
90:         ), true));
91:         $tpl->assign('pageUrlDeny', $denyUrl);
92: 
93:         $tpl->display('get.tpl');
94: 
95:     }
96: }
97: 
98: ?>
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0