コード例 #1
0
ファイル: TagsWidget.php プロジェクト: zonky2/core
 /**
  * {@inheritDoc}
  */
 protected function validator($varInput)
 {
     if (is_array($varInput)) {
         return parent::validator($varInput);
     }
     return parent::validator(trim($varInput));
 }
コード例 #2
0
ファイル: SectionWizard.php プロジェクト: contao/core-bundle
 /**
  * Standardize the ID
  *
  * @param mixed $varInput
  *
  * @return mixed
  */
 protected function validator($varInput)
 {
     if (isset($varInput['id'])) {
         $varInput['id'] = \StringUtil::standardize($varInput['id']);
     }
     return parent::validator($varInput);
 }
コード例 #3
0
ファイル: ImageSize.php プロジェクト: rikaix/core
 /**
  * Trim values
  * @param mixed
  * @return mixed
  */
 protected function validator($varInput)
 {
     $varInput[0] = parent::validator($varInput[0]);
     $varInput[1] = parent::validator($varInput[1]);
     $varInput[2] = preg_replace('/[^a-z0-9_]+/', '', $varInput[2]);
     return $varInput;
 }
コード例 #4
0
ファイル: FileTree.php プロジェクト: jens-wetzel/use2
 /**
  * Skip the field if "change selection" is not checked
  * @param mixed
  * @return mixed
  */
 protected function validator($varInput)
 {
     $this->import('BackendUser', 'User');
     if (!$this->Input->post($this->strName . '_save')) {
         $this->mandatory = false;
         $this->blnSubmitInput = false;
     } elseif ($varInput == '') {
         return parent::validator($varInput);
     } elseif (strlen($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['eval']['path'])) {
         $rgxp = '/^' . preg_quote($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField]['eval']['path'], '/') . '\\//i';
         foreach ((array) $varInput as $strFile) {
             if (!preg_match($rgxp, $strFile)) {
                 $this->addError('File or folder "' . $strFile . '" is not mounted!');
                 $this->log('File or folder "' . $strFile . '" is not mounted (hacking attempt)', 'FileTree validator()', TL_ERROR);
             }
         }
     } elseif (!$this->User->isAdmin) {
         foreach ((array) $varInput as $strFile) {
             if (!$this->User->hasAccess($strFile, 'filemounts')) {
                 $this->addError('File or folder "' . $strFile . '" is not mounted!');
                 $this->log('File or folder "' . $strFile . '" is not mounted (hacking attempt)', 'FileTree validator()', TL_ERROR);
             }
         }
     }
     return parent::validator($varInput);
 }
コード例 #5
0
ファイル: TextStore.php プロジェクト: iCodr8/core
 /**
  * Ignore the field if nothing has been entered
  * @param mixed
  * @return mixed
  */
 protected function validator($varInput)
 {
     if ($varInput == '*****') {
         $this->blnSubmitInput = false;
         return true;
     }
     return parent::validator(trim($varInput));
 }
コード例 #6
0
 /**
  * Do not check stop fields.
  *
  * @param	mixed $varInput
  * @return	mixed
  */
 protected function validator($varInput)
 {
     if ($this->conditionType == 'stop') {
         $this->mandatory = false;
         $this->blnSubmitInput = false;
     }
     return parent::validator($varInput);
 }
コード例 #7
0
ファイル: PageTree.php プロジェクト: jens-wetzel/use2
 /**
  * Skip the field if "change selection" is not checked
  * @param mixed
  * @return mixed
  */
 protected function validator($varInput)
 {
     if (!$this->Input->post($this->strName . '_save')) {
         $this->mandatory = false;
         $this->blnSubmitInput = false;
     }
     return parent::validator($varInput);
 }
コード例 #8
0
 /**
  * Trim values
  * @param mixed
  * @return mixed
  */
 public function validator($varInput)
 {
     if (is_array($varInput)) {
         return parent::validator($varInput);
     }
     $varInput = $this->fixUuidToBinary($varInput);
     $varInput = trim($varInput);
     return parent::validator($varInput);
 }
コード例 #9
0
ファイル: TimePeriod.php プロジェクト: bytehead/contao-core
 /**
  * Do not validate unit fields
  *
  * @param mixed $varInput
  *
  * @return mixed
  */
 protected function validator($varInput)
 {
     foreach ($varInput as $k => $v) {
         if ($k != 'unit') {
             $varInput[$k] = parent::validator($v);
         }
     }
     return $varInput;
 }
コード例 #10
0
ファイル: ImageSize.php プロジェクト: contao/core-bundle
 /**
  * Trim values
  *
  * @param mixed $varInput
  *
  * @return mixed
  */
 protected function validator($varInput)
 {
     $this->import('BackendUser', 'User');
     $varInput[0] = parent::validator($varInput[0]);
     $varInput[1] = parent::validator($varInput[1]);
     $varInput[2] = preg_replace('/[^a-z0-9_]+/', '', $varInput[2]);
     $imageSizes = \System::getContainer()->get('contao.image.image_sizes');
     $this->arrAvailableOptions = $this->User->isAdmin ? $imageSizes->getAllOptions() : $imageSizes->getOptionsForUser($this->User);
     if (!$this->isValidOption($varInput[2])) {
         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalid'], $varInput[2]));
     }
     return $varInput;
 }
コード例 #11
0
 /**
  * Validate input and set value
  * @param mixed
  * @return string
  */
 protected function validator($varInput)
 {
     $this->blnSubmitInput = false;
     if (!strlen($varInput) && (strlen($this->varValue) || !$this->mandatory)) {
         return '';
     }
     if ($varInput != $this->getPost($this->strName . '_confirm')) {
         $this->addError($GLOBALS['TL_LANG']['ERR']['confirmedEmailMismatch']);
     }
     $varInput = $this->idnaEncodeEmail($varInput);
     $varInput = parent::validator($varInput);
     if (!$this->hasErrors()) {
         $this->blnSubmitInput = true;
         return $varInput;
     }
     return '';
 }
コード例 #12
0
ファイル: FormTextField.php プロジェクト: Mozan/core-bundle
 /**
  * Trim the values
  *
  * @param mixed $varInput The user input
  *
  * @return mixed The validated user input
  */
 protected function validator($varInput)
 {
     if (is_array($varInput)) {
         return parent::validator($varInput);
     }
     // Convert to Punycode format (see #5571)
     if ($this->rgxp == 'url') {
         $varInput = \Idna::encodeUrl($varInput);
     } elseif ($this->rgxp == 'email' || $this->rgxp == 'friendly') {
         $varInput = \Idna::encodeEmail($varInput);
     }
     return parent::validator($varInput);
 }
コード例 #13
0
 /**
  * Validate input and set value
  * @param mixed
  * @return string
  */
 protected function validator($varInput)
 {
     $this->blnSubmitInput = false;
     if (!strlen($varInput) && (strlen($this->varValue) || !$this->mandatory)) {
         return '';
     }
     if (utf8_strlen($varInput) < $GLOBALS['TL_CONFIG']['minPasswordLength']) {
         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], $GLOBALS['TL_CONFIG']['minPasswordLength']));
     }
     if ($varInput != $this->getPost($this->strName . '_confirm')) {
         $this->addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
     }
     $varInput = parent::validator($varInput);
     if (!$this->hasErrors()) {
         $this->blnSubmitInput = true;
         $_SESSION['TL_CONFIRM'][] = $GLOBALS['TL_LANG']['MSC']['pw_changed'];
         $strSalt = substr(md5(uniqid(mt_rand(), true)), 0, 23);
         return sha1($strSalt . $varInput) . ':' . $strSalt;
     }
     return '';
 }
コード例 #14
0
ファイル: MultiTextWidget.php プロジェクト: metamodels/core
 /**
  * Trim the values and validate them.
  *
  * @param mixed $varInput The value to process.
  *
  * @return mixed The processed value
  */
 protected function validator($varInput)
 {
     if (is_array($varInput)) {
         $value = array();
         foreach ($varInput as $key => $input) {
             $value[$key] = parent::validator($input);
         }
         return $value;
     }
     return parent::validator(trim($varInput));
 }
コード例 #15
0
ファイル: ProductTree.php プロジェクト: rburch/core-1
 /**
  * Skip the field if "change selection" is not checked
  * @param mixed
  * @return mixed
  */
 protected function validator($varInput)
 {
     if (!$this->Input->post($this->strName . '_save')) {
         $this->mandatory = false;
         $this->blnSubmitInput = false;
     }
     // Check if there is at least one value
     if ($this->fieldType == 'text') {
         if (is_array($varInput)) {
             foreach ($varInput as $k => $option) {
                 if ($this->mandatory && $option != '') {
                     $this->mandatory = false;
                 } elseif ($option == '') {
                     unset($varInput[$k]);
                 }
             }
         }
     }
     return parent::validator($varInput);
 }
コード例 #16
0
ファイル: Password.php プロジェクト: bytehead/contao-core
 /**
  * Validate input and set value
  *
  * @param mixed $varInput
  *
  * @return string
  */
 protected function validator($varInput)
 {
     $this->blnSubmitInput = false;
     if (($varInput == '' || $varInput == '*****') && $this->varValue != '') {
         return '*****';
     }
     if (utf8_strlen($varInput) < \Config::get('minPasswordLength')) {
         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], \Config::get('minPasswordLength')));
     }
     if ($varInput != $this->getPost($this->strName . '_confirm')) {
         $this->addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
     }
     if ($varInput == $GLOBALS['TL_USERNAME']) {
         $this->addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
     }
     $varInput = parent::validator($varInput);
     if (!$this->hasErrors()) {
         $this->blnSubmitInput = true;
         \Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
         return \Encryption::hash($varInput);
     }
     return '';
 }
コード例 #17
0
ファイル: TreePicker.php プロジェクト: zonky2/dc-general
 /**
  * Skip the field if "change selection" is not checked.
  *
  * @param array $varInput The current value.
  *
  * @return array|string
  */
 protected function validator($varInput)
 {
     if (!($this->Input->post($this->strName . '_save') || $this->alwaysSave)) {
         $this->blnSubmitInput = false;
     }
     return parent::validator($varInput);
 }
コード例 #18
0
ファイル: TaxonomyTree.php プロジェクト: smohring/taxonomy
 /**
  * Skip the field if "change selection" is not checked
  * @param mixed
  * @return mixed
  */
 protected function validator($varInput)
 {
     //Todo: Change this code to support Contao 3.x
     /*
     if (!$this->Input->post($this->strName . '_save')) {
         $this->mandatory = false;
         $this->blnSubmitInput = false;
     }
     */
     return parent::validator($varInput);
 }
コード例 #19
0
 /**
  * Trim the values
  *
  * @param mixed $varInput The user input
  *
  * @return mixed The validated user input
  */
 protected function validator($varInput)
 {
     if (is_array($varInput)) {
         return parent::validator($varInput);
     }
     $varInput = \Idna::encodeUrl($varInput);
     return parent::validator(trim($varInput));
 }
コード例 #20
0
ファイル: FormPassword.php プロジェクト: bytehead/contao-core
 /**
  * Validate input and set value
  *
  * @param mixed $varInput The user input
  *
  * @return mixed The validated user input
  */
 protected function validator($varInput)
 {
     $this->blnSubmitInput = false;
     if (!strlen($varInput) && (strlen($this->varValue) || !$this->mandatory)) {
         return '';
     }
     if (utf8_strlen($varInput) < \Config::get('minPasswordLength')) {
         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], \Config::get('minPasswordLength')));
     }
     if ($varInput != $this->getPost($this->strName . '_confirm')) {
         $this->addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
     }
     $varInput = parent::validator($varInput);
     if (!$this->hasErrors()) {
         $this->blnSubmitInput = true;
         return \Encryption::hash($varInput);
     }
     return '';
 }
コード例 #21
0
ファイル: Password.php プロジェクト: rikaix/core
 /**
  * Validate input and set value
  * @param mixed
  * @return string
  */
 protected function validator($varInput)
 {
     $this->blnSubmitInput = false;
     if (($varInput == '' || $varInput == '*****') && $this->varValue != '') {
         return '*****';
     }
     if (utf8_strlen($varInput) < $GLOBALS['TL_CONFIG']['minPasswordLength']) {
         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['passwordLength'], $GLOBALS['TL_CONFIG']['minPasswordLength']));
     }
     if ($varInput != $this->getPost($this->strName . '_confirm')) {
         $this->addError($GLOBALS['TL_LANG']['ERR']['passwordMatch']);
     }
     if ($varInput == $GLOBALS['TL_USERNAME']) {
         $this->addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
     }
     $varInput = parent::validator($varInput);
     if (!$this->hasErrors()) {
         $this->blnSubmitInput = true;
         \Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['pw_changed']);
         $strSalt = substr(md5(uniqid(mt_rand(), true)), 0, 23);
         return sha1($strSalt . $varInput) . ':' . $strSalt;
     }
     return '';
 }
コード例 #22
0
 /**
  * Trim values
  * @param mixed
  * @return mixed
  */
 protected function validator($varInput)
 {
     $arrNames = array();
     foreach ($varInput as $k => $size) {
         if (in_array($size['name'], $arrNames)) {
             $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['unique'], $GLOBALS['TL_LANG'][$this->strTable]['iwName']));
         }
         $arrNames[] = $size['name'];
         $this->mandatory = true;
         $this->rgxp = 'alpha';
         $this->spaceToUnderscore = true;
         $size['name'] = parent::validator($size['name']);
         $this->mandatory = false;
         $this->rgxp = 'digit';
         $this->spaceToUnderscore = false;
         $size['width'] = parent::validator($size['width']);
         $size['height'] = parent::validator($size['height']);
         $varInput[$k] = $size;
     }
     return $varInput;
 }