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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • 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:         function script_cookie_directive_add_get_params($uri) {
56:             foreach ($_GET as $getKey => $getValue) {
57:                 // do not add already added GET parameters to redirect url
58:                 if (strpos($uri, '?' . $getKey . '=') !== false
59:                 || strpos($uri, '&' . $getKey . '=') !== false) {
60:                     continue;
61:                 }
62:                 if (strpos($uri, '?') === false) {
63:                     $uri .= '?';
64:                 } else {
65:                     $uri .= '&';
66:                 }
67:                 $uri .= htmlentities($getKey) . '=' . htmlentities($getValue);
68:             }
69: 
70:             return $uri;
71:         }
72: 
73:         // build accept url
74:         $acceptUrl = script_cookie_directive_add_get_params(cUri::getInstance()->build(array(
75:             'idart' => cRegistry::getArticleId(),
76:             'lang' => cRegistry::getLanguageId(),
77:             'acceptCookie' => 1
78:         ), true));
79: 
80:         $tpl->assign('pageUrlAccept', $acceptUrl);
81: 
82:         // build deny url
83:         $denyUrl = script_cookie_directive_add_get_params(cUri::getInstance()->build(array(
84:             'idart' => cRegistry::getArticleId(),
85:             'lang' => cRegistry::getLanguageId(),
86:             'acceptCookie' => 0
87:         ), true));
88:         $tpl->assign('pageUrlDeny', $denyUrl);
89: 
90:         $tpl->display('get.tpl');
91: 
92:     }
93: }
94: 
95: ?>
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0