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:  * @version SVN Revision $Rev:$
 9:  *
10:  * @author ilia.schwarz
11:  * @author claus.schunk@4fb.de
12:  * @copyright four for business AG <www.4fb.de>
13:  * @license http://www.contenido.org/license/LIZENZ.txt
14:  * @link http://www.4fb.de
15:  * @link http://www.contenido.org
16:  */
17: 
18: if (!cRegistry::getBackendSessionId()) {
19: 
20:     $session = cRegistry::getSession();
21: 
22:     if (array_key_exists('acceptCookie', $_GET)) {
23:         // Check value in get, if js is off
24:         $allowCookie = $_GET['acceptCookie'] === '1'? 1 : 0;
25:         setcookie('allowCookie', $allowCookie);
26: 
27:         // Save value
28:         $session->register('allowCookie');
29:     } elseif (array_key_exists('allowCookie', $_COOKIE)) {
30:         // Check value in cookies
31:         $allowCookie = $_COOKIE['allowCookie'] === '1'? 1 : 0;
32: 
33:         // Save value
34:         $session->register('allowCookie');
35:     }
36: 
37:     // Show notify
38:     if (!isset($allowCookie)) {
39: 
40:         $tpl = cSmartyFrontend::getInstance();
41: 
42:         // build translations
43:         $tpl->assign('trans', array(
44:             'title' => mi18n("TITLE"),
45:             'infoText' => mi18n("INFOTEXT"),
46:             'userInput' => mi18n("USERINPUT"),
47:             'accept' => mi18n("ACCEPT"),
48:             'decline' => mi18n("DECLINE")
49:         ));
50: 
51:         /**
52:          *
53:          * @param string $uri
54:          * @return string
55:          */
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 (strpos($uri, '?' . $getKey . '=') !== false
60:                 || strpos($uri, '&' . $getKey . '=') !== false) {
61:                     continue;
62:                 }
63:                 if (strpos($uri, '?') === false) {
64:                     $uri .= '?';
65:                 } else {
66:                     $uri .= '&';
67:                 }
68:                 $uri .= htmlentities($getKey) . '=' . htmlentities($getValue);
69:             }
70: 
71:             return $uri;
72:         }
73: 
74:         // build accept url
75:         $acceptUrl = script_cookie_directive_add_get_params(cUri::getInstance()->build(array(
76:             'idart' => cRegistry::getArticleId(),
77:             'lang' => cRegistry::getLanguageId(),
78:             'acceptCookie' => 1
79:         ), true));
80: 
81:         $tpl->assign('pageUrlAccept', $acceptUrl);
82: 
83:         // build deny url
84:         $denyUrl = script_cookie_directive_add_get_params(cUri::getInstance()->build(array(
85:             'idart' => cRegistry::getArticleId(),
86:             'lang' => cRegistry::getLanguageId(),
87:             'acceptCookie' => 0
88:         ), true));
89:         $tpl->assign('pageUrlDeny', $denyUrl);
90: 
91:         $tpl->display('get.tpl');
92: 
93:     }
94: }
95: 
96: ?>
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0