Example #1
0
 public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response)
 {
     // themeswitching must is enabled in configuration
     if ($this->config['themeswitch_via_url'] == 1) {
         return;
     }
     // check for "?theme=mytheme" URL parameter
     if (false === $request->issetParameter('theme', 'GET')) {
         return;
     }
     $theme = '';
     $theme = $request->getParameterFromGet('theme');
     /**
      * Inputfilter for $_GET['theme']. Allowed Chars are: az, 0-9, underscore.
      *
      */
     if (false === $this->input->check($theme, 'is_abc|is_int|is_custom', '_')) {
         throw new InvalidArgumentException('Please provide a proper theme name.');
     }
     $themedir = '';
     $themedir = ROOT_THEMES_FRONTEND . $theme . DIRECTORY_SEPARATOR;
     // theme exists, set it as session-user-theme
     if (is_dir($themedir) and is_file($themedir . 'theme_info.xml')) {
         $_SESSION['user']['frontend_theme'] = $theme;
     }
     unset($theme, $themedir);
 }
Example #2
0
 public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response)
 {
     // theme switching must be enabled in configuration
     if ($this->config['theme_via_get'] === 0) {
         return;
     }
     // check for "?theme=mytheme" URL parameter
     if (false === $request->issetParameter('theme', 'GET')) {
         return;
     }
     // get parameter
     $theme = '';
     $theme = $request->getParameterFromGet('theme');
     // Inputfilter for $_GET['theme']. Allowed Chars are: az, 0-9, underscore.
     if (false === $this->input->check($theme, 'is_abc|is_int|is_custom', '_')) {
         throw new \InvalidArgumentException('Please provide a proper theme name.');
     }
     // compose theme dir
     $themedir = '';
     $themedir = APPLICATION_PATH . 'themes/frontend/' . $theme . DIRECTORY_SEPARATOR;
     // if theme exists, set it as frontend theme to the session
     if (is_dir($themedir) and is_file($themedir . 'theme_info.xml')) {
         $_SESSION['user']['frontend_theme'] = $theme;
     }
     unset($theme, $themedir);
 }
Example #3
0
 public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response)
 {
     /*
      * If the renderer is not smarty, then bypass the filter.
      */
     if ($request->getRoute()->getRenderEngine() !== 'smarty') {
         return;
     }
     /*
      * Get HttpResponse output buffer
      */
     $content = $response->getContent();
     /*
      * This matches the PRE_HEAD_CLOSE tag.
      * The X marks the position: X</head>
      */
     $matches = [];
     $regexp1 = '!@@@SMARTY:PRE_HEAD_CLOSE:BEGIN@@@(.*?)@@@SMARTY:PRE_HEAD_CLOSE:END@@@!is';
     preg_match_all($regexp1, $content, $matches);
     $content = preg_replace($regexp1, '', $content);
     $matches = array_keys(array_flip($matches[1]));
     foreach ($matches as $value) {
         $content = str_replace('</head>', $value . "\n" . '</head>', $content);
     }
     /*
      * This matches the POST_BODY_OPEN tag.
      * The X marks the position: <body>X
      */
     $matches = [];
     $regexp2 = '!@@@SMARTY:POST_BODY_OPEN:BEGIN@@@(.*?)@@@SMARTY:POST_BODY_OPEN:END@@@!is';
     preg_match_all($regexp2, $content, $matches);
     $content = preg_replace($regexp2, '', $content);
     $matches = array_keys(array_flip($matches[1]));
     foreach ($matches as $values) {
         $content = str_replace('<body>', '<body>' . "\n" . $value, $content);
     }
     /*
      * This matches the POST_BODY_OPEN tag.
      * The X marks the position: X</body>
      */
     $matches = [];
     $regexp3 = '!@@@SMARTY:PRE_BODY_CLOSE:BEGIN@@@(.*?)@@@SMARTY:PRE_BODY_CLOSE:END@@@!is';
     preg_match_all($regexp3, $content, $matches);
     $content = preg_replace($regexp3, '', $content);
     $matches = array_keys(array_flip($matches[1]));
     foreach ($matches as $values) {
         $content = str_replace('</body>', $value . "\n" . '</body>', $content);
     }
     /*
      * Replace the http response buffer
      */
     $response->setContent($content, true);
 }
Example #4
0
 public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response)
 {
     // take the initiative or pass through (do nothing)
     if (isset($this->config['statistics']['enabled']) and $this->config['statistics']['enabled'] === 1) {
         return;
     }
     // @todo aquire pieces of informtion from current visitor
     // Determine the client's browser and system information based on
     // $_SERVER['HTTP_USER_AGENT']
     /*
      * The Who logics, must be processed in a seperate filter
      */
     Doctrine::getTable('CsStatistic')->deleteWhoEntriesOlderThen($this->statsWhoDeleteTime);
     $this->updateStatistics($request->getRemoteAddress());
     $this->updateWhoTables($request->getRemoteAddress(), $request->getRequestURI());
 }
Example #5
0
 public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response)
 {
     /*
      * take the initiative of filtering, if language switching is enabled in CONFIG
      * or pass through (do nothing) if disabled
      */
     if (true === (bool) $this->config['language_via_get']) {
         return;
     }
     // fetch URL parameter "&lang=" from $_GET['lang']
     $language = $request->getParameterFromGet('lang');
     if (isset($language) && mb_strlen($language) === 2) {
         /*
          * memorize in the user session
          * a) the selected language
          * b) that the language was set via $_GET parameter
          */
         $_SESSION['user']['language'] = mb_strtolower($language);
         $_SESSION['user']['language_via_get'] = 1;
     }
 }
Example #6
0
File: Router.php Project: ksst/kf
 /**
  * Constructor.
  */
 public function __construct(HttpRequestInterface $request)
 {
     $this->request = $request;
     // get URI from request, clean it and set it as a class property
     $this->uri = self::prepareRequestURI($request->getRequestURI());
 }