コード例 #1
0
 /**
  * Validates that a specified field's value is a valid date
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
         # find out separator
         $pattern = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'pattern');
         preg_match('/^[d|m|y]*(.)[d|m|y]*/i', $pattern, $res);
         $sep = $res[1];
         // normalisation of format
         $pattern = $this->normalizeDatePattern($pattern, $sep);
         // find out correct positioins of "d","m","y"
         $pos1 = strpos($pattern, 'd');
         $pos2 = strpos($pattern, 'm');
         $pos3 = strpos($pattern, 'y');
         $dateCheck = t3lib_div::trimExplode($sep, $gp[$name]);
         if (sizeof($dateCheck) !== 3) {
             $checkFailed = $this->getCheckFailed($check);
         } elseif (intval($dateCheck[0]) === 0 || intval($dateCheck[1]) === 0 || intval($dateCheck[2]) === 0) {
             $checkFailed = $this->getCheckFailed($check);
         } elseif (!checkdate($dateCheck[$pos2], $dateCheck[$pos1], $dateCheck[$pos3])) {
             $checkFailed = $this->getCheckFailed($check);
         } elseif (strlen($dateCheck[$pos3]) !== 4) {
             $checkFailed = $this->getCheckFailed($check);
         }
     }
     return $checkFailed;
 }
 /**
  * Validates that a specified field contains at least one of the specified words
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     $formValue = trim($gp[$name]);
     if (strlen($formValue) > 0) {
         $checkValue = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'words');
         if (!is_array($checkValue)) {
             $checkValue = t3lib_div::trimExplode(',', $checkValue);
         }
         $error = FALSE;
         $array = preg_split('//', $formValue, -1, PREG_SPLIT_NO_EMPTY);
         foreach ($array as $idx => $char) {
             if (!in_array($char, $checkValue)) {
                 $error = TRUE;
             }
         }
         if ($error) {
             //remove userfunc settings and only store comma seperated words
             $check['params']['words'] = implode(',', $checkValue);
             unset($check['params']['words.']);
             $checkFailed = $this->getCheckFailed($check);
         }
     }
     return $checkFailed;
 }
コード例 #3
0
 /**
  * Logs the given values.
  *
  * @return void
  */
 public function process()
 {
     //set params
     $table = "tx_formhandler_log";
     $fields['ip'] = t3lib_div::getIndpEnv('REMOTE_ADDR');
     if (isset($this->settings['disableIPlog']) && intval($this->settings['disableIPlog']) == 1) {
         $fields['ip'] = NULL;
     }
     $fields['tstamp'] = time();
     $fields['crdate'] = time();
     $fields['pid'] = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'pid');
     if (!$fields['pid']) {
         $fields['pid'] = $GLOBALS['TSFE']->id;
     }
     ksort($this->gp);
     $keys = array_keys($this->gp);
     $serialized = serialize($this->gp);
     $hash = md5(serialize($keys));
     $fields['params'] = $serialized;
     $fields['key_hash'] = $hash;
     if (intval($this->settings['markAsSpam']) == 1) {
         $fields['is_spam'] = 1;
     }
     //query the database
     $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $fields);
     $insertedUID = $GLOBALS['TYPO3_DB']->sql_insert_id();
     $sessionValues = array('inserted_uid' => $insertedUID, 'inserted_tstamp' => $fields['tstamp'], 'key_hash' => $hash);
     Tx_Formhandler_Globals::$session->setMultiple($sessionValues);
     if (!$this->settings['nodebug']) {
         Tx_Formhandler_StaticFuncs::debugMessage('logging', array($table, implode(',', $fields)));
         if (strlen($GLOBALS['TYPO3_DB']->sql_error()) > 0) {
             Tx_Formhandler_StaticFuncs::debugMessage('error', array($GLOBALS['TYPO3_DB']->sql_error()), 3);
         }
     }
 }
 /**
  * Validates that up to x files get uploaded via the specified upload field.
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     $files = Tx_Formhandler_Globals::$session->get('files');
     $settings = Tx_Formhandler_Globals::$session->get('settings');
     $currentStep = Tx_Formhandler_Globals::$session->get('currentStep');
     $lastStep = Tx_Formhandler_Globals::$session->get('lastStep');
     $maxCount = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'maxCount');
     if (is_array($files[$name]) && count($files[$name]) >= $maxCount && $currentStep == $lastStep) {
         $found = FALSE;
         foreach ($_FILES as $idx => $info) {
             if (strlen($info['name'][$name]) > 0) {
                 $found = TRUE;
             }
         }
         if ($found) {
             $checkFailed = $this->getCheckFailed($check);
         }
     } elseif (is_array($files[$name]) && $currentStep > $lastStep) {
         foreach ($_FILES as $idx => $info) {
             if (strlen($info['name'][$name]) > 0 && count($files[$name]) >= $maxCount) {
                 $checkFailed = $this->getCheckFailed($check);
             }
         }
     }
     return $checkFailed;
 }
コード例 #5
0
 /**
  * Validates that a specified field is a string and at least a specified count of characters long
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     $min = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'value');
     if (isset($gp[$name]) && mb_strlen(trim($gp[$name]), $GLOBALS['TSFE']->renderCharset) > 0 && intVal($min) > 0 && mb_strlen(trim($gp[$name]), $GLOBALS['TSFE']->renderCharset) < intval($min)) {
         $checkFailed = $this->getCheckFailed($check);
     }
     return $checkFailed;
 }
 /**
  * The main method called by the controller
  *
  * @return array The probably modified GET/POST parameters
  */
 public function process()
 {
     $firstInsertInfo = array();
     if (is_array($this->gp['saveDB'])) {
         if (isset($this->settings['table'])) {
             foreach ($this->gp['saveDB'] as $idx => $insertInfo) {
                 if ($insertInfo['table'] === $this->settings['table']) {
                     $firstInsertInfo = $insertInfo;
                     break;
                 }
             }
         }
         if (empty($firstInsertInfo)) {
             reset($this->gp['saveDB']);
             $firstInsertInfo = current($this->gp['saveDB']);
         }
     }
     $table = $firstInsertInfo['table'];
     $uid = $firstInsertInfo['uid'];
     $uidField = $firstInsertInfo['uidField'];
     if (!$uidField) {
         $uidField = 'uid';
     }
     if ($table && $uid && $uidField) {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, $uidField . '=' . $uid);
         if ($res) {
             $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
             $authCode = $this->generateAuthCode($row);
             $this->gp['generated_authCode'] = $authCode;
             // looking for the page, which should be used for the authCode Link
             // first look for TS-setting 'authCodePage', second look for redirect_page-setting, third use actual page
             $authCodePage = '';
             if (isset($this->settings['authCodePage'])) {
                 $authCodePage = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'authCodePage');
             } else {
                 $authCodePage = Tx_Formhandler_StaticFuncs::pi_getFFvalue($this->cObj->data['pi_flexform'], 'redirect_page', 'sMISC');
             }
             if (!$authCodePage) {
                 $authCodePage = $GLOBALS['TSFE']->id;
             }
             //create the parameter-array for the authCode Link
             $paramsArray = array_merge($firstInsertInfo, array('authCode' => $authCode));
             // If we have set a formValuesPrefix, add it to the parameter-array
             if (!empty(Tx_Formhandler_Globals::$formValuesPrefix)) {
                 $paramsArray = array(Tx_Formhandler_Globals::$formValuesPrefix => $paramsArray);
             }
             // create the link, using typolink function, use baseUrl if set, else use t3lib_div::getIndpEnv('TYPO3_SITE_URL')
             $url = $this->cObj->getTypoLink_URL($authCodePage, $paramsArray);
             $tmpArr = parse_url($url);
             if (empty($tmpArr['scheme'])) {
                 $url = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . ltrim($url, '/');
             }
             $this->gp['authCodeUrl'] = $url;
         }
     }
     return $this->gp;
 }
 /**
  * Validates that a specified field is a string and has a length between two specified values
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     $min = intval(Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'minValue'));
     $max = intval(Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'maxValue'));
     if (isset($gp[$name]) && (mb_strlen($gp[$name], $GLOBALS['TSFE']->renderCharset) < intval($min) || mb_strlen($gp[$name], $GLOBALS['TSFE']->renderCharset) > intval($max))) {
         $checkFailed = $this->getCheckFailed($check);
     }
     return $checkFailed;
 }
 /**
  * Validates that a specified field is an array and has an item count between two specified values
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     $min = intval(Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'minValue'));
     $max = intval(Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'maxValue'));
     if (isset($gp[$name]) && is_array($gp[$name]) && (count($gp[$name]) < intval($min) || count($gp[$name]) > intval($max))) {
         $checkFailed = $this->getCheckFailed($check);
     }
     return $checkFailed;
 }
コード例 #9
0
 /**
  * Validates that a specified field is an integer and greater than or equal a specified value
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     $min = floatval(str_replace(',', '.', Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'value')));
     $valueToCheck = floatval(str_replace(',', '.', $gp[$name]));
     if (isset($gp[$name]) && $valueToCheck >= 0 && $min >= 0 && (!is_numeric($valueToCheck) || $valueToCheck < $min)) {
         $checkFailed = $this->getCheckFailed($check);
     }
     return $checkFailed;
 }
コード例 #10
0
 /**
  * Validates that a specified field's value matches a perl regular expression
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
         $regex = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'value');
         if ($regex && !preg_match($regex, $gp[$name])) {
             $checkFailed = $this->getCheckFailed($check);
         }
     }
     return $checkFailed;
 }
コード例 #11
0
 /**
  * The main method called by the controller
  *
  * @return array The probably modified GET/POST parameters
  */
 public function process()
 {
     $cacheCmd = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'cacheCmd');
     if (empty($cacheCmd)) {
         $cacheCmd = $GLOBALS['TSFE']->id;
     }
     Tx_Formhandler_StaticFuncs::debugMessage('cacheCmd', array($cacheCmd));
     $tce = t3lib_div::makeInstance('t3lib_tcemain');
     $tce->clear_cacheCmd($cacheCmd);
     return $this->gp;
 }
コード例 #12
0
 /**
  * The main method called by the controller
  *
  * @return array The probably modified GET/POST parameters
  */
 public function process()
 {
     //read redirect page
     $redirectPage = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'redirectPage');
     if (!isset($redirectPage)) {
         return $this->gp;
     }
     Tx_Formhandler_Globals::$session->reset();
     Tx_Formhandler_Staticfuncs::doRedirect($redirectPage, $this->settings['correctRedirectUrl'], $this->settings['additionalParams.']);
     exit;
 }
コード例 #13
0
 /**
  * Validates that a specified field doesn't equal the value
  * of fieldname in param
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
         $comparisonValue = $gp[Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'field')];
         if (strcmp($comparisonValue, $gp[$name]) != 0) {
             $checkFailed = $this->getCheckFailed($check);
         }
     }
     return $checkFailed;
 }
コード例 #14
0
 /**
  * Validates that an uploaded file has a maximum file size
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     $maxSize = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'maxSize');
     foreach ($_FILES as $sthg => &$files) {
         if (strlen($files['name'][$name]) > 0 && $maxSize && $files['size'][$name] > $maxSize) {
             unset($files);
             $checkFailed = $this->getCheckFailed($check);
         }
     }
     return $checkFailed;
 }
コード例 #15
0
 /**
  * Renders the CSV.
  *
  * @return void
  */
 public function process()
 {
     $this->pdf = $this->componentManager->getComponent('Tx_Formhandler_Template_TCPDF');
     $this->pdf->setHeaderText(Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'headerText'));
     $this->pdf->setFooterText(Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'footerText'));
     $this->pdf->AddPage();
     $this->pdf->SetFont('Helvetica', '', 12);
     $view = $this->componentManager->getComponent('Tx_Formhandler_View_PDF');
     $this->filename = FALSE;
     if (intval($this->settings['storeInTempFile']) === 1) {
         $this->outputPath = t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT');
         if ($this->settings['customTempOutputPath']) {
             $this->outputPath .= Tx_Formhandler_StaticFuncs::sanitizePath($this->settings['customTempOutputPath']);
         } else {
             $this->outputPath .= '/typo3temp/';
         }
         $this->filename = $this->outputPath . $this->settings['filePrefix'] . Tx_Formhandler_StaticFuncs::generateHash() . '.pdf';
         $this->filenameOnly = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'staticFileName');
         if (strlen($this->filenameOnly) === 0) {
             $this->filenameOnly = basename($this->filename);
         }
     }
     $this->formhandlerSettings = Tx_Formhandler_Globals::$settings;
     $suffix = $this->formhandlerSettings['templateSuffix'];
     $this->templateCode = Tx_Formhandler_StaticFuncs::readTemplateFile(FALSE, $this->formhandlerSettings);
     if ($suffix) {
         $view->setTemplate($this->templateCode, 'PDF' . $suffix);
     }
     if (!$view->hasTemplate()) {
         $view->setTemplate($this->templateCode, 'PDF');
     }
     if (!$view->hasTemplate()) {
         Tx_Formhandler_StaticFuncs::throwException('no_pdf_template');
     }
     $view->setComponentSettings($this->settings);
     $content = $view->render($this->gp, array());
     $this->pdf->writeHTML($content);
     $returns = $this->settings['returnFileName'];
     if ($this->filename !== FALSE) {
         $this->pdf->Output($this->filename, 'F');
         $downloadpath = $this->filename;
         if ($returns) {
             return $downloadpath;
         }
         $downloadpath = str_replace(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT'), '', $downloadpath);
         header('Location: ' . $downloadpath);
         exit;
     } else {
         $this->pdf->Output('formhandler.pdf', 'D');
         exit;
     }
 }
コード例 #16
0
    public function fillAjaxMarkers(&$markers)
    {
        $settings = Tx_Formhandler_Globals::$session->get('settings');
        $initial = Tx_Formhandler_StaticFuncs::getSingle($settings['ajax.']['config.'], 'initial');
        $loadingImg = Tx_Formhandler_StaticFuncs::getSingle($settings['ajax.']['config.'], 'loading');
        if (strlen($loadingImg) === 0) {
            $loadingImg = t3lib_extMgm::extRelPath('formhandler') . 'Resources/Images/ajax-loader.gif';
            $loadingImg = '<img src="' . $loadingImg . '"/>';
        }
        //parse validation settings
        if (is_array($settings['validators.'])) {
            foreach ($settings['validators.'] as $key => $validatorSettings) {
                if (is_array($validatorSettings['config.']['fieldConf.'])) {
                    foreach ($validatorSettings['config.']['fieldConf.'] as $fieldname => $fieldSettings) {
                        $replacedFieldname = str_replace('.', '', $fieldname);
                        $fieldname = $replacedFieldname;
                        if (Tx_Formhandler_Globals::$formValuesPrefix) {
                            $fieldname = Tx_Formhandler_Globals::$formValuesPrefix . '[' . $fieldname . ']';
                        }
                        $params = array('eID' => 'formhandler', 'pid' => $GLOBALS['TSFE']->id, 'randomID' => Tx_Formhandler_Globals::$randomID, 'field' => $replacedFieldname, 'value' => '');
                        $url = Tx_Formhandler_Globals::$cObj->getTypoLink_Url($GLOBALS['TSFE']->id, $params);
                        $markers['###validate_' . $replacedFieldname . '###'] = '
							<span class="loading" id="loading_' . $replacedFieldname . '" style="display:none">' . $loadingImg . '</span>
							<span id="result_' . $replacedFieldname . '">' . str_replace('###fieldname###', $replacedFieldname, $initial) . '</span>
							<script type="text/javascript">
								$(document).ready(function() {
									$("*[name=\'' . $fieldname . '\']").blur(function() {
										var fieldVal = escape($(this).val());
										if ($(this).attr("type") == "radio" || $(this).attr("type") == "checkbox") {
											if ($(this).attr("checked") == "") {
												fieldVal = "";
											}
										}
										$("#loading_' . $replacedFieldname . '").show();
										$("#result_' . $replacedFieldname . '").hide();
										var url = "' . $url . '";
										url = url.replace("value=", "value=" + fieldVal);
										$("#result_' . $replacedFieldname . '").load(url,
										function() {
										
											$("#loading_' . $replacedFieldname . '").hide();
											$("#result_' . $replacedFieldname . '").show();
										});
									});
								});
							</script>
						';
                    }
                }
            }
        }
    }
 /**
  * Validates that a specified field doesn't equal a specified default value.
  * This default value could have been set via a PreProcessor.
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
         $defaultValue = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'defaultValue');
         if (strlen($defaultValue) > 0) {
             if (!strcmp($defaultValue, $gp[$name])) {
                 $checkFailed = $this->getCheckFailed($check);
             }
         }
     }
     return $checkFailed;
 }
コード例 #18
0
 public function process()
 {
     if (Tx_Formhandler_Globals::$session->get('originalLanguage') === NULL) {
         Tx_Formhandler_Globals::$session->set('originalLanguage', $GLOBALS['TSFE']->lang);
     }
     $languageCode = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'languageCode');
     if ($languageCode) {
         $GLOBALS['TSFE']->lang = strtolower($languageCode);
         Tx_Formhandler_StaticFuncs::debugMessage('Language set to "' . $GLOBALS['TSFE']->lang . '"!', array(), 1);
     } else {
         Tx_Formhandler_StaticFuncs::debugMessage('Unable to set language! Language code set in TypoScript is empty!', array(), 2);
     }
     return $this->gp;
 }
コード例 #19
0
 /**
  * Validates that a specified field equals a specified word
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     $formValue = trim($gp[$name]);
     if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
         $checkValue = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'word');
         if (strcasecmp($formValue, $checkValue)) {
             //remove userfunc settings
             unset($check['params']['word.']);
             $checkFailed = $this->getCheckFailed($check);
         }
     }
     return $checkFailed;
 }
コード例 #20
0
 /**
  * Validates that a specified field's value is a valid date and between two specified dates
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
         $min = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'min');
         $max = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'max');
         $pattern = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'pattern');
         preg_match('/^[d|m|y]*(.)[d|m|y]*/i', $pattern, $res);
         $sep = $res[1];
         // normalisation of format
         $pattern = $this->normalizeDatePattern($pattern, $sep);
         // find out correct positioins of "d","m","y"
         $pos1 = strpos($pattern, 'd');
         $pos2 = strpos($pattern, 'm');
         $pos3 = strpos($pattern, 'y');
         $date = $gp[$name];
         $checkdate = explode($sep, $date);
         $check_day = $checkdate[$pos1];
         $check_month = $checkdate[$pos2];
         $check_year = $checkdate[$pos3];
         if (strlen($min) > 0) {
             $min_date = t3lib_div::trimExplode($sep, $min);
             $min_day = $min_date[$pos1];
             $min_month = $min_date[$pos2];
             $min_year = $min_date[$pos3];
             if ($check_year < $min_year) {
                 $checkFailed = $this->getCheckFailed($check);
             } elseif ($check_year == $min_year && $check_month < $min_month) {
                 $checkFailed = $this->getCheckFailed($check);
             } elseif ($check_year == $min_year && $check_month == $min_month && $check_day < $min_day) {
                 $checkFailed = $this->getCheckFailed($check);
             }
         }
         if (strlen($max) > 0) {
             $max_date = t3lib_div::trimExplode($sep, $max);
             $max_day = $max_date[$pos1];
             $max_month = $max_date[$pos2];
             $max_year = $max_date[$pos3];
             if ($check_year > $max_year) {
                 $checkFailed = $this->getCheckFailed($check);
             } elseif ($check_year == $max_year && $check_month > $max_month) {
                 $checkFailed = $this->getCheckFailed($check);
             } elseif ($check_year == $max_year && $check_month == $max_month && $check_day > $max_day) {
                 $checkFailed = $this->getCheckFailed($check);
             }
         }
     }
     return $checkFailed;
 }
コード例 #21
0
 /**
  * Validates that a specified field is an array and has less than or exactly a specified amount of items
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     if (isset($gp[$name])) {
         $value = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'value');
         if (is_array($gp[$name])) {
             if (count($gp[$name]) > $value) {
                 $checkFailed = $this->getCheckFailed($check);
             }
         } else {
             $checkFailed = $this->getCheckFailed($check);
         }
     }
     return $checkFailed;
 }
 /**
  * Validates that an uploaded file via specified field matches one of the given file types
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     $allowed = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'allowedTypes');
     foreach ($_FILES as $sthg => &$files) {
         if (strlen($files['name'][$name]) > 0) {
             if ($allowed) {
                 $types = t3lib_div::trimExplode(',', $allowed);
                 $fileext = substr($files['name'][$name], strrpos($files['name'][$name], '.') + 1);
                 $fileext = strtolower($fileext);
                 if (!in_array($fileext, $types)) {
                     unset($files);
                     $checkFailed = $this->getCheckFailed($check);
                 }
             }
         }
     }
     return $checkFailed;
 }
コード例 #23
0
 /**
  * Validates that a specified field contains all of the specified words
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     $formValue = trim($gp[$name]);
     if (strlen($formValue) > 0) {
         $checkValue = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'words');
         if (!is_array($checkValue)) {
             $checkValue = t3lib_div::trimExplode(',', $checkValue);
         }
         foreach ($checkValue as $idx => $word) {
             if (!stristr($formValue, $word)) {
                 // remove userfunc settings and only store comma seperated words
                 $check['params']['words'] = implode(',', $checkValue);
                 unset($check['params']['words.']);
                 $checkFailed = $this->getCheckFailed($check);
             }
         }
     }
     return $checkFailed;
 }
コード例 #24
0
 /**
  * Validates that a specified field's value is a valid time
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
         $pattern = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'pattern');
         preg_match('/^[h|m]*(.)[h|m]*/i', $pattern, $res);
         $sep = $res[1];
         $timeCheck = t3lib_div::trimExplode($sep, $gp[$name]);
         if (is_array($timeCheck)) {
             $hours = $timeCheck[0];
             if (!is_numeric($hours) || $hours < 0 || $hours > 23) {
                 $checkFailed = $this->getCheckFailed($check);
             }
             $minutes = $timeCheck[1];
             if (!is_numeric($minutes) || $minutes < 0 || $minutes > 59) {
                 $checkFailed = $this->getCheckFailed($check);
             }
         }
     }
     return $checkFailed;
 }
コード例 #25
0
 /**
  * Renders the CSV.
  *
  * @return void
  */
 public function process()
 {
     $params = $this->gp;
     $exportParams = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'exportParams');
     if (!is_array($exportParams)) {
         $exportParams = t3lib_div::trimExplode(',', $exportParams);
     }
     //build data
     foreach ($params as $key => &$value) {
         if (is_array($value)) {
             $value = implode(',', $value);
         }
         if (count($exportParams) > 0 && !in_array($key, $exportParams)) {
             unset($params[$key]);
         }
         $value = str_replace('"', '""', $value);
     }
     // create new parseCSV object.
     $csv = new parseCSV();
     $csv->output('formhandler.csv', $data, $params);
     die;
 }
コード例 #26
0
 /**
  * Validates that a specified field's value is found in a specified db table
  *
  * @param array &$check The TypoScript settings for this error check
  * @param string $name The field name
  * @param array &$gp The current GET/POST parameters
  * @return string The error string
  */
 public function check(&$check, $name, &$gp)
 {
     $checkFailed = '';
     if (isset($gp[$name]) && strlen(trim($gp[$name])) > 0) {
         $checkTable = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'table');
         $checkField = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'field');
         $additionalWhere = Tx_Formhandler_StaticFuncs::getSingle($check['params'], 'additionalWhere');
         if (!empty($checkTable) && !empty($checkField)) {
             $where = $checkField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($gp[$name], $checkTable) . ' ' . $additionalWhere;
             $showHidden = intval($check['params']['showHidden']) === 1 ? 1 : 0;
             $where .= $GLOBALS['TSFE']->sys_page->enableFields($checkTable, $showHidden);
             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($checkField, $checkTable, $where);
             if ($res && !$GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
                 $checkFailed = $this->getCheckFailed($check);
             } elseif (!$res) {
                 Tx_Formhandler_StaticFuncs::debugMessage('error', array($GLOBALS['TYPO3_DB']->sql_error()), 3);
             }
             $GLOBALS['TYPO3_DB']->sql_free_result($res);
         }
     }
     return $checkFailed;
 }
コード例 #27
0
 protected function getValueMarkers($values, $level = 0, $prefix = 'value_')
 {
     $markers = array();
     $arrayValueSeparator = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'arrayValueSeparator');
     if (strlen($arrayValueSeparator) === 0) {
         $arrayValueSeparator = ',';
     }
     if (is_array($values)) {
         foreach ($values as $k => $v) {
             $currPrefix = $prefix;
             if ($level === 0) {
                 $currPrefix .= $k;
             } else {
                 $currPrefix .= '|' . $k;
             }
             if (is_array($v)) {
                 $level++;
                 $markers = array_merge($markers, $this->getValueMarkers($v, $level, $currPrefix));
                 $v = implode($arrayValueSeparator, $v);
                 $level--;
             }
             $v = trim($v);
             $markers['###' . $currPrefix . '###'] = $v;
             $markers['###' . strtoupper($currPrefix) . '###'] = $v;
         }
     }
     return $markers;
 }
コード例 #28
0
 /**
  * Returns current UID to use for updating the DB.
  * @return int UID
  */
 protected function getUpdateUid()
 {
     $uid = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'key_value');
     if (!$uid) {
         $uid = $this->gp[$this->key];
     }
     if (!$uid) {
         $uid = $this->gp['inserted_uid'];
     }
     return $uid;
 }
コード例 #29
0
 /**
  * Parses a list of file names or field names set in TypoScript and overrides it with setting in plugin record if set.
  *
  * @param array $settings The settings array containing the mail settings
  * @param string $type admin|user
  * @param string $key The key to parse in the settings array
  * @return string
  */
 private function parseFilesList($settings, $type, $key)
 {
     if (isset($settings[$key . '.']) && is_array($settings[$key . '.'])) {
         $parsed = Tx_Formhandler_StaticFuncs::getSingle($settings, $key);
         $parsed = t3lib_div::trimExplode(',', $parsed);
     } elseif ($settings[$key]) {
         $files = t3lib_div::trimExplode(',', $settings[$key]);
         $parsed = array();
         $sessionFiles = Tx_Formhandler_Globals::$session->get('files');
         foreach ($files as $idx => $file) {
             if (isset($sessionFiles[$file])) {
                 foreach ($sessionFiles[$file] as $subIdx => $uploadedFile) {
                     array_push($parsed, $uploadedFile['uploaded_path'] . $uploadedFile['uploaded_name']);
                 }
             } else {
                 array_push($parsed, $file);
             }
         }
     }
     return $parsed;
 }
コード例 #30
0
 /**
  * Read JavaScript file(s) set in TypoScript. If set add to header data
  *
  * @return void
  * @author	Reinhard Führicht <*****@*****.**>
  */
 protected function addJS()
 {
     $jsFile = $this->settings['jsFile'];
     $jsFiles = array();
     if ($this->settings['jsFile.']) {
         foreach ($this->settings['jsFile.'] as $idx => $file) {
             if (strpos($idx, '.') === FALSE) {
                 $file = Tx_Formhandler_StaticFuncs::getSingle($this->settings['jsFile.'], $idx);
                 $jsFiles[] = $file;
             }
         }
     } elseif (strlen($jsFile) > 0) {
         $jsFiles[] = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'jsFile');
     }
     foreach ($jsFiles as $idx => $file) {
         // set stylesheet
         $GLOBALS['TSFE']->additionalHeaderData[$this->configuration->getPackageKeyLowercase()] .= '<script type="text/javascript" src="' . Tx_Formhandler_StaticFuncs::resolveRelPathFromSiteRoot($file) . '"></script>' . "\n";
     }
 }