/**
  * Validate the current user
  * 
  * @param \string $argument		Form argument name
  * @return \boolean				Successful validation
  */
 protected function _validate($argument)
 {
     $templateVariableContainer = $this->renderingContext->getTemplateVariableContainer();
     $request = $this->controllerContext->getRequest();
     $request = $request->getOriginalRequest() ?: $request;
     $arguments = $request->getArguments();
     return \Tollwerk\TwAntibot\Validation\Validator::validate($this->_extendedSettings, $argument && array_key_exists($argument, $arguments) ? $arguments[$argument] : null);
 }
Ejemplo n.º 2
0
 /**
  * Create and return the antibot armor HTML
  * 
  * @param \string $content			Content
  * @param \array $config			Configuration
  * @return \string					Armor fields 
  */
 public function armor($content, array $config)
 {
     try {
         $settings = \Tollwerk\TwAntibot\Utility\Utility::settings();
         if (array_key_exists('antibot.', $config) && is_array($config['antibot.'])) {
             $typoscriptService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService');
             $antibotSettings = $typoscriptService->convertTypoScriptArrayToPlainArray($config['antibot.']);
             \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($settings, $antibotSettings);
         }
         return \Tollwerk\TwAntibot\Validation\Validator::armor($settings);
     } catch (\Exception $e) {
         die(get_class($e));
     }
 }
 /**
  * Validate the current user
  * 
  * @param \string $argument		Form argument name
  * @return \boolean				Successful validation
  */
 protected function _validate($argument = null)
 {
     $templateVariableContainer = $this->renderingContext->getTemplateVariableContainer();
     $request = $this->controllerContext->getRequest();
     $request = $request->getOriginalRequest() ?: $request;
     $arguments = $request->getArguments();
     // If the form has just been submitted
     if ($argument && array_key_exists($argument, $arguments)) {
         try {
             \Tollwerk\TwAntibot\Validation\Validator::validate($this->_extendedSettings, $arguments[$argument]);
         } catch (\Tollwerk\TwAntibot\Validation\Exception $e) {
             die(get_class($e));
         }
     }
     return true;
 }
 /**
  * Test if the current user is blocked access to the current form
  *
  * @return \boolean				Blocked
  */
 public function render()
 {
     $GLOBALS['TSFE']->set_no_cache();
     // TODO: Only exclude the current plugin from cache?!
     return \Tollwerk\TwAntibot\Validation\Validator::armor($this->_extendedSettings);
 }