public function filter(FilterChain &$chain, $input = null)
 {
     $_POST = $this->sanitize($_POST);
     $_GET = $this->sanitize($_GET);
     $_REQUEST = $this->sanitize($_REQUEST);
     return $chain->filter($input);
 }
 public function filter(FilterChain &$chain, $input = null)
 {
     $replacements = $this->getHeaderContent();
     // replace gethead-taglib
     $input = str_replace(HtmlHeaderGetHeadTag::HTML_HEADER_INDICATOR, $replacements[0], $input);
     // replace getbodyjs-taglib
     $input = str_replace(HtmlHeaderGetBodyJsTag::HTML_BODYJS_INDICATOR, $replacements[1], $input);
     return $chain->filter($input);
 }
 public function filter(FilterChain &$chain, $input = null)
 {
     /* @var $t BenchmarkTimer */
     $t = Singleton::getInstance(BenchmarkTimer::class);
     $id = get_class($this);
     $t->start($id);
     $fC = $this->getFrontcontroller();
     $tokens = $fC->getActionUrlMappingTokens();
     foreach ($this->getRequest()->getParameters() as $key => $value) {
         // ID#63: re-map action instructions according to registered aliases
         if (in_array($key, $tokens)) {
             $mapping = $fC->getActionUrlMapping($key);
             $key = str_replace('\\', '_', $mapping->getNamespace()) . self::$FC_ACTION_KEYWORD . ':' . $mapping->getName();
         }
         if (substr_count($key, self::$FC_ACTION_KEYWORD . ':') > 0) {
             // get namespace and class from the REQUEST key
             $actionName = substr($key, strpos($key, ':') + 1);
             $actionNamespace = substr($key, 0, strpos($key, '-'));
             // initialize the input params
             $inputParams = [];
             // create param array
             $paramsArray = explode('|', $value);
             $count = count($paramsArray);
             for ($i = 0; $i < $count; $i++) {
                 $tmpArray = explode(':', $paramsArray[$i]);
                 // ID#240: allow "0" values to be passed as within front controller action input value.
                 if (isset($tmpArray[0]) && isset($tmpArray[1]) && !empty($tmpArray[0]) && (!empty($tmpArray[1]) || (string) $tmpArray[1] === '0')) {
                     $inputParams[$tmpArray[0]] = $tmpArray[1];
                 }
             }
             // add action to the front controller
             $fC->addAction($actionNamespace, $actionName, $inputParams);
         }
     }
     $t->stop($id);
     // delegate further filtering to the applied chain
     $chain->filter($input);
 }
 public function filter(FilterChain &$chain, $input = null)
 {
     /* @var $t BenchmarkTimer */
     $t = Singleton::getInstance(BenchmarkTimer::class);
     $id = get_class($this);
     $t->start($id);
     $request = $this->getRequest();
     // extract the session id from $_REQUEST if existent to re-add it after filtering
     $sessionId = $request->getSessionId();
     // initialize param to analyze
     $query = $request->getParameter(self::$REWRITE_QUERY_PARAM, '');
     // delete the rewrite param indicator
     $request->deleteParameter(self::$REWRITE_QUERY_PARAM);
     // reset request but save POST data
     $postData = $request->getPostParameters();
     $request->resetParameters();
     // ID#63: re-map action instructions according to registered aliases
     $fC = $this->getFrontcontroller();
     $tokens = $fC->getActionUrlMappingTokens();
     // re-map action urls
     foreach ($tokens as $token) {
         if (strpos($query, '/' . $token . '/') !== false) {
             $mapping = $fC->getActionUrlMapping($token);
             $query = str_replace('/' . $token . '/', '/' . str_replace('\\', '_', $mapping->getNamespace()) . '-action/' . $mapping->getName() . '/', $query);
         } else {
             if (substr($query, -(strlen($token) + 1)) == '/' . $token) {
                 // URL mapping appears at the end of the query and/or is the only part of it
                 $mapping = $fC->getActionUrlMapping($token);
                 $query = str_replace('/' . $token, '/' . str_replace('\\', '_', $mapping->getNamespace()) . '-action/' . $mapping->getName(), $query);
             }
         }
     }
     // extract actions from the request url, in case the action keyword or the action
     // delimiter is present in url.
     if (substr_count($query, self::$ACTION_TO_PARAM_DELIMITER) > 0 || substr_count($query, self::$FC_ACTION_KEYWORD . '/') > 0) {
         // split url by delimiter
         $requestURLParts = explode(self::$ACTION_TO_PARAM_DELIMITER, $query);
         $count = count($requestURLParts);
         for ($i = 0; $i < $count; $i++) {
             // remove leading slash
             $requestURLParts[$i] = $this->deleteTrailingSlash($requestURLParts[$i]);
             if (substr_count($requestURLParts[$i], self::$FC_ACTION_KEYWORD) > 0) {
                 $requestArray = explode(self::$REWRITE_URL_DELIMITER, $requestURLParts[$i]);
                 if (isset($requestArray[1])) {
                     // create action params
                     $actionNamespace = str_replace(self::$FC_ACTION_KEYWORD, '', $requestArray[0]);
                     $actionName = $requestArray[1];
                     $actionParams = array_slice($requestArray, 2);
                     $actionParamsArray = [];
                     $actionParamCount = count($actionParams);
                     if ($actionParamCount > 0) {
                         $x = 0;
                         while ($x <= $actionParamCount - 1) {
                             if (isset($actionParams[$x + 1])) {
                                 $actionParamsArray[$actionParams[$x]] = $actionParams[$x + 1];
                             }
                             $x = $x + 2;
                             // increase by two, because next offset is the value!
                         }
                     }
                     $fC->addAction($actionNamespace, $actionName, $actionParamsArray);
                 }
             } else {
                 $paramArray = $this->createRequestArray($requestURLParts[$i]);
                 $request->setParameters(array_merge($request->getParameters(), $paramArray));
             }
         }
     } else {
         // do page controller-style rewriting!
         $paramArray = $this->createRequestArray($query);
         $request->setParameters(array_merge($request->getParameters(), $paramArray));
     }
     // re-initialize GET params to support e.g. form submission
     $request->setGetParameters($request->getParameters());
     // re-add POST params
     $request->setParameters(array_merge($request->getParameters(), $postData));
     $request->setPostParameters($postData);
     // add session id to the request again
     if (!empty($sessionId)) {
         $request->setParameter($request->getSessionName(), $sessionId);
     }
     $t->stop($id);
     // delegate further filtering to the applied chain
     $chain->filter($input);
 }
 public function filter(FilterChain &$chain, $input = null)
 {
     /* @var $t BenchmarkTimer */
     $t = Singleton::getInstance(BenchmarkTimer::class);
     $id = get_class($this);
     $t->start($id);
     $input = preg_replace_callback('/<form (.*?)action="(.*?)"(.*?)>(.*?)<\\/form>/ims', [ChainedUrlRewritingOutputFilter::class, 'replaceForm'], preg_replace_callback('/<a (.*?)href="(.*?)"(.*?)>(.*?)<\\/a>/ims', [ChainedUrlRewritingOutputFilter::class, 'replaceLink'], $input));
     $t->stop($id);
     // delegate filtering to the applied chain
     return $chain->filter($input);
 }