[FEATURE] Remove fields from global settings in extension manager 28/29328/3
authortritum_rz <ralf.zimmermann@tritum.de>
Thu, 10 Apr 2014 08:16:43 +0000 (10:16 +0200)
committerRalf Zimmermann <ralf.zimmermann@tritum.de>
Thu, 10 Apr 2014 08:18:17 +0000 (10:18 +0200)
Resolves: #57523
Releases: 6.1, 4.7, 4.5
Change-Id: I25ccec9cab9899ff2e83c7ee7fc2de5b48a79ae4
Reviewed-on: https://review.typo3.org/29328
Reviewed-by: Ralf Zimmermann
Tested-by: Ralf Zimmermann
19 files changed:
Classes/Extensions/class.tx_wtspamshield_comments.php
Classes/Extensions/class.tx_wtspamshield_defaultmailform.php
Classes/Extensions/class.tx_wtspamshield_ke_userregister.php
Classes/Extensions/class.tx_wtspamshield_pbsurvey.php
Classes/Extensions/class.tx_wtspamshield_powermail.php
Classes/Extensions/class.tx_wtspamshield_powermail2.php
Classes/Extensions/class.tx_wtspamshield_ve_guestbook.php
Classes/Methodes/class.tx_wtspamshield_method_akismet.php
Classes/Methodes/class.tx_wtspamshield_method_honeypot.php
Classes/Methodes/class.tx_wtspamshield_method_httpcheck.php
Classes/Methodes/class.tx_wtspamshield_method_namecheck.php
Classes/Methodes/class.tx_wtspamshield_method_session.php
Classes/Methodes/class.tx_wtspamshield_method_unique.php
Classes/System/class.tx_wtspamshield_div.php
Classes/System/class.tx_wtspamshield_log.php
Classes/System/class.tx_wtspamshield_mail.php
Configuration/TypoScript/constants.txt
Configuration/TypoScript/setup.txt
ext_conf_template.txt [deleted file]

index 4bd81ef..68b6485 100644 (file)
@@ -92,15 +92,11 @@ class tx_wtspamshield_comments extends tslib_pibase {
                $markers = $params['markers'];
 
                if ( $this->getDiv()->isActivated( $this->tsKey ) ) {
-
-                               // 1. check Extension Manager configuration
-                       $this->getDiv()->getExtConf();
-
-                               // 2. Session check - generate session entry
+                               // Session check - generate session entry
                        $methodSessionInstance = t3lib_div::makeInstance('tx_wtspamshield_method_session');
                        $methodSessionInstance->setSessionTime();
 
-                               // 3. Honeypot check - generate honeypot Input field
+                               // Honeypot check - generate honeypot Input field
                        $methodHoneypotInstance = t3lib_div::makeInstance('tx_wtspamshield_method_honeypot');
                        $methodHoneypotInstance->additionalValues = $this->additionalValues['honeypotCheck'];
                        $markers['###JS_USER_DATA###'] = $methodHoneypotInstance->createHoneypot() . $markers['###JS_USER_DATA###'];
index 9d7dcc9..4acffc3 100644 (file)
@@ -89,7 +89,6 @@ class tx_wtspamshield_defaultmailform extends tslib_pibase {
         */
        public function generateSession($content, array $configuration = NULL) {
                if ( $this->getDiv()->isActivated($this->tsKey) ) {
-                       $this->getDiv()->getExtConf();
                        $forceValue = !(isset($configuration['ifOutdated']) && $configuration['ifOutdated']);
 
                                // Set session on form create
index 691a1b2..d5ed42f 100644 (file)
@@ -85,14 +85,11 @@ class tx_wtspamshield_ke_userregister extends tslib_pibase {
         */
        public function additionalMarkers(&$markerArray, $pObj, $errors) {
                if ( $this->getDiv()->isActivated($this->tsKey) ) {
-                               // 1. check Extension Manager configuration
-                       $this->getDiv()->getExtConf();
-
-                               // 2. Session check - generate session entry
+                               // Session check - generate session entry
                        $methodSessionInstance = t3lib_div::makeInstance('tx_wtspamshield_method_session');
                        $methodSessionInstance->setSessionTime();
 
-                               // 3. Honeypot check - generate honeypot Input field
+                               // Honeypot check - generate honeypot Input field
                        $methodHoneypotInstance = t3lib_div::makeInstance('tx_wtspamshield_method_honeypot');
                        $methodHoneypotInstance->additionalValues = $this->additionalValues['honeypotCheck'];
                        $pObj->templateCode = str_replace('</form>', $methodHoneypotInstance->createHoneypot() . '</form>', $pObj->templateCode);
@@ -130,7 +127,7 @@ class tx_wtspamshield_ke_userregister extends tslib_pibase {
                if ( $this->getDiv()->isActivated($this->tsKey) ) {
 
                        $error = $this->validate($validateArray);
-                               // 2c. Error message
+                               // Error message
                        if ($error) {
                                        // Workaround: create field via TS and put it in HTML
                                        // template of ke_userregister
index 8707127..bad3365 100644 (file)
@@ -84,14 +84,13 @@ class tx_wtspamshield_pbsurvey extends tslib_pibase {
         */
        public function hookItemProcessor($arrItem, &$pObj) {
                $strOutput = '';
-               if ($this->getDiv()->isActivated($this->tsKey)) {
-                       $this->getDiv()->getExtConf();
 
-                               // 2. Session check - generate session entry
+               if ($this->getDiv()->isActivated($this->tsKey)) {
+                               // Session check - generate session entry
                        $methodSessionInstance = t3lib_div::makeInstance('tx_wtspamshield_method_session');
                        $methodSessionInstance->setSessionTime();
 
-                               // 3. Honeypot check - generate honeypot Input field
+                               // Honeypot check - generate honeypot Input field
                        $methodHoneypotInstance = t3lib_div::makeInstance('tx_wtspamshield_method_honeypot');
                        $methodHoneypotInstance->additionalValues = $this->additionalValues['honeypotCheck'];
                        $strOutput = $methodHoneypotInstance->createHoneypot();
@@ -109,43 +108,45 @@ class tx_wtspamshield_pbsurvey extends tslib_pibase {
         * @return string $strOutput
         */
        public function validateForm($arrValidation, $piVars, &$arrError, &$pObj) {
-               $stringTypes = array(2,4,5,10,12,13,14,15);
+               if ($this->getDiv()->isActivated($this->tsKey)) {
+                       $stringTypes = array(2,4,5,10,12,13,14,15);
 
-               $validationFieds = array();
+                       $validationFieds = array();
 
-               $honeypotInputName = $this->additionalValues['honeypotCheck']['honeypotInputName'];
-               $honeypotInputValue = $piVars[$honeypotInputName];
-               $validationFieds[$honeypotInputName] = $honeypotInputValue;
+                       $honeypotInputName = $this->additionalValues['honeypotCheck']['honeypotInputName'];
+                       $honeypotInputValue = $piVars[$honeypotInputName];
+                       $validationFieds[$honeypotInputName] = $honeypotInputValue;
 
-               foreach($arrValidation as $intKey => $arrQuestionValidation) {
-                       if (isset($piVars[$intKey])) {
-                               $strTotalValue = '';
+                       foreach($arrValidation as $intKey => $arrQuestionValidation) {
+                               if (isset($piVars[$intKey])) {
+                                       $strTotalValue = '';
 
-                               foreach($piVars[$intKey] as $intRow => $arrRowValue) {
-                                       if (!is_array($arrRowValue)) {
-                                               $intRow = $arrRowValue;
-                                               $arrRowValue = array(0 => $arrRowValue);
-                                       }
-                                       foreach ($arrRowValue as $intColumn => $strValue) {
-                                               if (in_array($arrQuestionValidation['type'], $stringTypes)
-                                                       && !empty($strValue)
-                                               ) {
-                                                       $strTotalValue = $strValue;
+                                       foreach($piVars[$intKey] as $intRow => $arrRowValue) {
+                                               if (!is_array($arrRowValue)) {
+                                                       $intRow = $arrRowValue;
+                                                       $arrRowValue = array(0 => $arrRowValue);
                                                }
-
-                                               if ($arrQuestionValidation['type'] == 7) {
-                                                       $strTotalValue .= ' ' . $strValue;
+                                               foreach ($arrRowValue as $intColumn => $strValue) {
+                                                       if (in_array($arrQuestionValidation['type'], $stringTypes)
+                                                               && !empty($strValue)
+                                                       ) {
+                                                               $strTotalValue = $strValue;
+                                                       }
+
+                                                       if ($arrQuestionValidation['type'] == 7) {
+                                                               $strTotalValue .= ' ' . $strValue;
+                                                       }
                                                }
                                        }
+                                       $validationFieds[$intKey] = $strTotalValue;
                                }
-                               $validationFieds[$intKey] = $strTotalValue;
                        }
-               }
 
-               $error = $this->validate($validationFieds);
+                       $error = $this->validate($validationFieds);
 
-               if (strlen($error) > 0) {
-                       $arrError[] = $error;
+                       if (strlen($error) > 0) {
+                               $arrError[] = $error;
+                       }
                }
        }
 
index 799e55d..7225e5f 100644 (file)
@@ -87,14 +87,11 @@ class tx_wtspamshield_powermail extends tslib_pibase {
        public function PM_FormWrapMarkerHook($outerMarkerArray, &$subpartArray, $conf, $obj) {
 
                if ( $this->getDiv()->isActivated($this->tsKey) ) {
-                               // 1. check Extension Manager configuration
-                       $this->getDiv()->getExtConf();
-
-                               // 2. Set session on form create
+                               // Set session on form create
                        $methodSessionInstance = t3lib_div::makeInstance('tx_wtspamshield_method_session');
                        $methodSessionInstance->setSessionTime();
 
-                               // 3. Add Honeypot
+                               // Add Honeypot
                        $methodHoneypotInstance = t3lib_div::makeInstance('tx_wtspamshield_method_honeypot');
                        $methodHoneypotInstance->additionalValues = $this->additionalValues['honeypotCheck'];
                        $subpartArray['###POWERMAIL_CONTENT###'] .= $methodHoneypotInstance->createHoneypot();
@@ -119,7 +116,7 @@ class tx_wtspamshield_powermail extends tslib_pibase {
 
                        $error = $this->validate($sessiondata);
 
-                               // 2c. Return Error message if exists
+                               // Return Error message if exists
                        if (strlen($error) > 0) {
                                return '<div class="wtspamshield-errormsg">' . $error . '</div>';
                        }
index 494f303..330aa67 100644 (file)
@@ -79,25 +79,27 @@ class tx_wtspamshield_powermail2 extends Tx_Powermail_Domain_Validator_CustomVal
         * @return void
         */
        function validate($fields, $controller) {
-               $availableValidators = 
-                       array(
-                               'akismetCheck',
-                       );
+               if ( $this->getDiv()->isActivated($this->tsKey) ) {
+                       $availableValidators = 
+                               array(
+                                       'akismetCheck',
+                               );
 
-               $tsValidators = $this->getDiv()->commaListToArray($this->tsConf['validators.'][$this->tsKey . '.']['enable']);
+                       $tsValidators = $this->getDiv()->commaListToArray($this->tsConf['validators.'][$this->tsKey . '.']['enable']);
 
-               $processor = $this->getDiv()->getProcessor();
-               $processor->tsKey = $this->tsKey;
-               $processor->fieldValues = $fields;
-               $processor->additionalValues = $this->additionalValues;
-               $processor->failureRate = intval($this->tsConf['validators.'][$this->tsKey . '.']['how_many_validators_can_fail']);
-               $processor->methodes = array_intersect($tsValidators, $availableValidators);
+                       $processor = $this->getDiv()->getProcessor();
+                       $processor->tsKey = $this->tsKey;
+                       $processor->fieldValues = $fields;
+                       $processor->additionalValues = $this->additionalValues;
+                       $processor->failureRate = intval($this->tsConf['validators.'][$this->tsKey . '.']['how_many_validators_can_fail']);
+                       $processor->methodes = array_intersect($tsValidators, $availableValidators);
 
-               $error = $processor->validate();
+                       $error = $processor->validate();
 
-               if (strlen($error) > 0) {
-                       $controller->addError('spam_details', 50 . '%');
-                       $controller->isValid = FALSE;
+                       if (strlen($error) > 0) {
+                               $controller->addError('spam_details', 50 . '%');
+                               $controller->isValid = FALSE;
+                       }
                }
        }
 }
index dc1b0b5..3f06c86 100644 (file)
@@ -90,14 +90,11 @@ class tx_wtspamshield_ve_guestbook extends tslib_pibase {
                        $obj->code == 'FORM' &&
                        $this->getDiv()->isActivated($this->tsKey)
                ) {
-                               // 1. check Extension Manager configuration
-                       $this->getDiv()->getExtConf();
-
-                               // 2. Session check - generate session entry
+                               // Session check - generate session entry
                        $methodSessionInstance = t3lib_div::makeInstance('tx_wtspamshield_method_session');
                        $methodSessionInstance->setSessionTime();
 
-                               // 3. Honeypot check - generate honeypot Input field
+                               // Honeypot check - generate honeypot Input field
                        $methodHoneypotInstance = t3lib_div::makeInstance('tx_wtspamshield_method_honeypot');
                        $methodHoneypotInstance->additionalValues = $this->additionalValues['honeypotCheck'];
                        $obj->templateCode = str_replace('</form>', $methodHoneypotInstance->createHoneypot() . '</form>', $obj->templateCode);
index 274254a..b35203f 100644 (file)
@@ -53,34 +53,29 @@ class tx_wtspamshield_method_akismet extends tx_wtspamshield_method_abstract {
         * @return string $error Return errormessage if error exists
         */
        public function validate() {
-               $extConf = $this->getDiv()->getExtConf();
                $error = '';
 
-               if (isset($extConf)) {
-                       if ($extConf['AkismetKey']) {
-                               $akismetArray = array();
-                               $tsConf = $this->getDiv()->getTsConf();
+               $akismetArray = array();
+               $tsConf = $this->getDiv()->getTsConf();
 
-                                       // Get field mapping from TS
-                               $fields = $tsConf['fields.'][$this->tsKey . '.'];
-                               foreach ($fields as $key => $value) {
-                                       if ($value && array_key_exists($value, $this->fieldValues)) {
-                                               $akismetArray[$key] = $this->fieldValues[$value];
-                                       }
-                               }
+                       // Get field mapping from TS
+               $fields = $tsConf['fields.'][$this->tsKey . '.'];
+               foreach ($fields as $key => $value) {
+                       if ($value && array_key_exists($value, $this->fieldValues)) {
+                               $akismetArray[$key] = $this->fieldValues[$value];
+                       }
+               }
 
-                               $akismetArray += array(
-                                       'user_ip' => t3lib_div::getIndpEnv('REMOTE_ADDR'),
-                                       'user_agent' => t3lib_div::getIndpEnv('HTTP_USER_AGENT')
-                               );
+               $akismetArray += array(
+                       'user_ip' => t3lib_div::getIndpEnv('REMOTE_ADDR'),
+                       'user_agent' => t3lib_div::getIndpEnv('HTTP_USER_AGENT')
+               );
 
-                               $akismet = new tx_wtspamshield_akismet('http://' . t3lib_div::getIndpEnv('HTTP_HOST') . '/',
-                                                                                                               $extConf['AkismetKey'], $akismetArray);
+               $akismet = new tx_wtspamshield_akismet('http://' . t3lib_div::getIndpEnv('HTTP_HOST') . '/',
+                                                                                               $tsConf['akismetCheck.']['akismetKey'], $akismetArray);
 
-                               if (!$akismet->isError() && $akismet->isSpam()) {
-                                       $error = $this->renderCobj($tsConf['errors.'], 'akismet');
-                               }
-                       }
+               if (!$akismet->isError() && $akismet->isSpam()) {
+                       $error = $this->renderCobj($tsConf['errors.'], 'akismet');
                }
 
                if (isset($error)) {
index b3bafb6..5920d1b 100644 (file)
@@ -52,28 +52,21 @@ class tx_wtspamshield_method_honeypot extends tx_wtspamshield_method_abstract {
         * @return string $code Return form field (honeypot)
         */
        public function createHoneypot() {
-               $extConf = $this->getDiv()->getExtConf();
+               $tsConf = $this->getDiv()->getTsConf();
+               $cObjType = $tsConf['honeypot.']['explanation'];
+               $cObjvalues = $tsConf['honeypot.']['explanation.'];
+               $lll = $cObjvalues['value'];
+               $cObjvalues['value'] = $this->getL10n($lll);
+               $code = $this->cObj->cObjGetSingle($cObjType, $cObjvalues);
 
-               if (isset($extConf)) {
-                       if ($extConf['honeypotCheck']) {
-                               $tsConf = $this->getDiv()->getTsConf();
-                               $cObjType = $tsConf['honeypot.']['explanation'];
-                               $cObjvalues = $tsConf['honeypot.']['explanation.'];
-                               $lll = $cObjvalues['value'];
-                               $cObjvalues['value'] = $this->getL10n($lll);
-                               $code = $this->cObj->cObjGetSingle($cObjType, $cObjvalues);
+               $code .= '<input type="text" autocomplete="off" name="';
+               $code .= $this->additionalValues['prefixInputName'] . '[' . $this->additionalValues['honeypotInputName'] . ']"';
+               $code .= ' ' . $tsConf['honeypot.']['css.']['inputStyle'];
+               $code .= ' value=""';
+               $code .= ' ' . $tsConf['honeypot.']['css.']['inputClass'];
+               $code .= ' />';
 
-                               $code .= '<input type="text" autocomplete="off" name="';
-                               $code .= $this->additionalValues['prefixInputName'] . '[' . $this->additionalValues['honeypotInputName'] . ']"';
-                               $code .= ' ' . $tsConf['honeypot.']['css.']['inputStyle'];
-                               $code .= ' value=""';
-                               $code .= ' ' . $tsConf['honeypot.']['css.']['inputClass'];
-                               $code .= ' />';
-
-                               return $code;
-                       }
-               }
-               return '';
+               return $code;
        }
 
        /**
@@ -82,12 +75,8 @@ class tx_wtspamshield_method_honeypot extends tx_wtspamshield_method_abstract {
         * @return string $error Return errormessage if error exists
         */
        public function validate() {
-               $extConf = $this->getDiv()->getExtConf();
 
-               if (strlen($this->fieldValues[$this->additionalValues['honeypotInputName']]) > 0
-                       && isset($extConf)
-                       && $extConf['honeypotCheck']
-               ) {
+               if (strlen($this->fieldValues[$this->additionalValues['honeypotInputName']]) > 0) {
                        $tsConf = $this->getDiv()->getTsConf();
                        return $this->renderCobj($tsConf['errors.'], 'honeypot');
                }
index b6405b7..0a004ff 100644 (file)
@@ -57,41 +57,37 @@ class tx_wtspamshield_method_httpcheck extends tx_wtspamshield_method_abstract {
         * @return string $error Return errormessage if error exists
         */
        public function validate() {
-               $extConf = $this->getDiv()->getExtConf();
+               if (isset($this->fieldValues)) {
+                       $noOfErrors = 0;
+                       $tsConf = $this->getDiv()->getTsConf();
+                       $error = $this->renderCobj($tsConf['errors.'], 'httpCheck');
+                       $error = sprintf($error, intval($tsConf['httpCheck.']['maximumLinkAmount']));
 
-               if (isset($extConf) && isset($this->fieldValues)) {
-                       if ($extConf['usehttpCheck'] >= 0) {
+                       foreach ((array) $this->fieldValues as $key => $value) {
+                               if (!is_array($value)) {
 
-                               $noOfErrors = 0;
-                               $tsConf = $this->getDiv()->getTsConf();
-                               $error = $this->renderCobj($tsConf['errors.'], 'httpCheck');
-                               $error = sprintf($error, $extConf['usehttpCheck']);
-
-                               foreach ((array) $this->fieldValues as $key => $value) {
-                                       if (!is_array($value)) {
-
-                                               $result = array();
-                                               preg_match_all('@' . $this->searchstring . '@', $value, $result);
-                                               if (isset($result[0])) {
-                                                       $noOfErrors += count($result[0]);
-                                               }
-                                       } else {
-                                               if (!is_array($value2)) {
-                                                       foreach ((array) $this->fieldValues[$key] as $key2 => $value2 ) {
-                                                               $result = array();
-                                                               preg_match_all('@' . $this->searchstring . '@', $value2, $result);
-                                                               if (isset($result[0])) {
-                                                                       $noOfErrors += count($result[0]);
-                                                               }
+                                       $result = array();
+                                       preg_match_all('@' . $this->searchstring . '@', $value, $result);
+                                       if (isset($result[0])) {
+                                               $noOfErrors += count($result[0]);
+                                       }
+                               } else {
+                                       if (!is_array($value2)) {
+                                               foreach ((array) $this->fieldValues[$key] as $key2 => $value2 ) {
+                                                       $result = array();
+                                                       preg_match_all('@' . $this->searchstring . '@', $value2, $result);
+                                                       if (isset($result[0])) {
+                                                               $noOfErrors += count($result[0]);
                                                        }
                                                }
                                        }
                                }
+                       }
 
-                               if ($noOfErrors > $extConf['usehttpCheck']) {
-                                       return $error;
-                               }
+                       if ($noOfErrors > intval($tsConf['httpCheck.']['maximumLinkAmount'])) {
+                               return $error;
                        }
+
                }
                return '';
        }
index 09d207d..93a6a1e 100644 (file)
@@ -52,22 +52,15 @@ class tx_wtspamshield_method_namecheck extends tx_wtspamshield_method_abstract {
         * @return string $error Return errormessage if error exists
         */
        public function validate() {
-               $extConf = $this->getDiv()->getExtConf();
+               if ($this->additionalValues['name1'] === $this->additionalValues['name2'] && $this->additionalValues['name1']) {
+                       $tsConf = $this->getDiv()->getTsConf();
+                       $error = $this->renderCobj($tsConf['errors.'], 'nameCheck');
+               }
 
-               if (isset($extConf)) {
-                       if ($extConf['useNameCheck'] == 1) {
-                               if ($this->additionalValues['name1'] === $this->additionalValues['name2'] && $this->additionalValues['name1']) {
-                                       $tsConf = $this->getDiv()->getTsConf();
-                                       $error = $this->renderCobj($tsConf['errors.'], 'nameCheck');
-                               }
-                               if (isset($error)) {
-                                       return $error;
-                               }
-                       }
+               if (isset($error)) {
+                       return $error;
                }
-               return '';
        }
-
 }
 
 if (defined('TYPO3_MODE')
index 4ece555..29800fb 100644 (file)
@@ -54,17 +54,17 @@ class tx_wtspamshield_method_session extends tx_wtspamshield_method_abstract {
         * @return void
         */
        public function setSessionTime($forceValue = TRUE) {
-               $extConf = $this->getDiv()->getExtConf();
+               $tsConf = $this->getDiv()->getTsConf();
 
-               if (isset($extConf)) {
-                       $timeStamp = intval($GLOBALS['TSFE']->fe_user->getKey('ses', 'wt_spamshield_form_tstamp'));
-                       $isOutdated = ($timeStamp + $extConf['SessionEndTime'] < time());
+               $sessionEndTime = intval($tsConf['sessionCheck.']['sessionEndTime']);
+               $timeStamp = intval($GLOBALS['TSFE']->fe_user->getKey('ses', 'wt_spamshield_form_tstamp'));
+               $isOutdated = ($timeStamp + $sessionEndTime < time());
 
-                       if ($forceValue || $isOutdated) {
-                               $GLOBALS['TSFE']->fe_user->setKey('ses', 'wt_spamshield_form_tstamp', time());
-                               $GLOBALS['TSFE']->storeSessionData();
-                       }
+               if ($forceValue || $isOutdated) {
+                       $GLOBALS['TSFE']->fe_user->setKey('ses', 'wt_spamshield_form_tstamp', time());
+                       $GLOBALS['TSFE']->storeSessionData();
                }
+
        }
 
        /**
@@ -86,26 +86,24 @@ class tx_wtspamshield_method_session extends tx_wtspamshield_method_abstract {
         * @return string $error Return errormessage if error exists
         */
        public function validate() {
-               $extConf = $this->getDiv()->getExtConf();
                $error = '';
 
-               if (isset($extConf)) {
-                       if ($extConf['useSessionCheck'] == 1) {
-                               $sessTstamp = intval($GLOBALS['TSFE']->fe_user->getKey('ses', 'wt_spamshield_form_tstamp'));
-                               $tsConf = $this->getDiv()->getTsConf();
-
-                               if ($sessTstamp > 0) {
-                                       if ((($sessTstamp + $extConf['SessionEndTime']) < time()) && ($extConf['SessionEndTime'] > 0)) {
-                                               $error = $this->renderCobj($tsConf['errors.'], 'session_error_1');
-                                       } elseif ( (($sessTstamp + $extConf['SessionStartTime']) > time())
-                                                               && ($extConf['SessionStartTime'] > 0)
-                                       ) {
-                                               $error = $this->renderCobj($tsConf['errors.'], 'session_error_2');
-                                       }
-                               } else {
-                                       $error = $this->renderCobj($tsConf['errors.'], 'session_error_3');
-                               }
+               $sessTstamp = intval($GLOBALS['TSFE']->fe_user->getKey('ses', 'wt_spamshield_form_tstamp'));
+               $tsConf = $this->getDiv()->getTsConf();
+
+               $sessionStartTime = intval($tsConf['sessionCheck.']['sessionStartTime']);
+               $sessionEndTime = intval($tsConf['sessionCheck.']['sessionEndTime']);
+
+               if ($sessTstamp > 0) {
+                       if ((($sessTstamp + $sessionEndTime) < time()) && ($sessionEndTime > 0)) {
+                               $error = $this->renderCobj($tsConf['errors.'], 'session_error_1');
+                       } elseif ( (($sessTstamp + $sessionStartTime) > time())
+                                               && ($sessionStartTime > 0)
+                       ) {
+                               $error = $this->renderCobj($tsConf['errors.'], 'session_error_2');
                        }
+               } else {
+                       $error = $this->renderCobj($tsConf['errors.'], 'session_error_3');
                }
 
                return $error;
index 916d48c..f6b62eb 100644 (file)
@@ -55,31 +55,26 @@ class tx_wtspamshield_method_unique extends tx_wtspamshield_method_abstract {
                $found = 0;
                $wholearray = array();
 
-               $extConf = $this->getDiv()->getExtConf();
-               if (isset($extConf)) {
-                       if ($extConf['notUnique']) {
-                               $tsConf = $this->getDiv()->getTsConf();
-                               $error = $this->renderCobj($tsConf['errors.'], 'uniquecheck');
+               $tsConf = $this->getDiv()->getTsConf();
+               $error = $this->renderCobj($tsConf['errors.'], 'uniquecheck');
 
-                               $myFieldArray = t3lib_div::trimExplode(';', $extConf['notUnique'], 1);
-                               if (is_array($myFieldArray)) {
-                                       foreach ($myFieldArray as $myKey => $myValue) {
-                                               $wholearray = array();
-                                               $fieldarray = t3lib_div::trimExplode(',', $myValue, 1);
+               $myFieldArray = t3lib_div::trimExplode(';', $tsConf['uniqueCheck.']['fields'], 1);
+               if (is_array($myFieldArray)) {
+                       foreach ($myFieldArray as $myKey => $myValue) {
+                               $wholearray = array();
+                               $fieldarray = t3lib_div::trimExplode(',', $myValue, 1);
 
-                                               if (is_array($fieldarray)) {
-                                                       foreach ($fieldarray as $key => $value) {
-                                                               if ($this->fieldValues[$value]) {
-                                                                       $wholearray[] = $this->fieldValues[$value];
-                                                               }
-                                                       }
-                                               }
-
-                                               if (count($wholearray) != count(array_unique($wholearray))) {
-                                                       $found = 1;
+                               if (is_array($fieldarray)) {
+                                       foreach ($fieldarray as $key => $value) {
+                                               if ($this->fieldValues[$value]) {
+                                                       $wholearray[] = $this->fieldValues[$value];
                                                }
                                        }
                                }
+
+                               if (count($wholearray) != count(array_unique($wholearray))) {
+                                       $found = 1;
+                               }
                        }
                }
 
index f624a02..2364dd9 100644 (file)
@@ -135,26 +135,51 @@ class tx_wtspamshield_div extends tslib_pibase {
        public function getTsConf() {
                if (!isset($this->tsConf)) {
                        $this->tsConf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['wt_spamshield.'];
+                       $this->mergeWithExtConf();
                }
                return $this->tsConf;
        }
 
        /**
-        * getExtConf
-        *
-        * @return mixed
+        * merge typoscript with ext conf
+        * 
+        * lookup for deprecated ext_conf_template settings
+        * we remove this lookup in the next Version!
+        * 
+        * @return void
         */
-       public function getExtConf() {
-               if (!isset($this->extConf)) {
-                       $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
-                       if ( !is_array($extConf) ) {
-                               echo $this->msg('Please open ' . $this->extKey . ' in the Extension Manager, scroll down and click "Update"');
-                               $this->extConf = NULL;
-                       } else {
-                               $this->extConf = $extConf;
+       public function mergeWithExtConf() {
+               $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
+
+               if ( is_array($extConf) ) {
+                       if ($this->tsConf['httpCheck.']['maximumLinkAmount'] == '') {
+                               $this->tsConf['httpCheck.']['maximumLinkAmount'] = $extConf['usehttpCheck'];
+                       }
+
+                       if ($this->tsConf['uniqueCheck.']['fields'] == '') {
+                               $this->tsConf['uniqueCheck.']['fields'] = $extConf['notUnique'];
+                       }
+
+                       if ($this->tsConf['sessionCheck.']['sessionStartTime'] == '') {
+                               $this->tsConf['sessionCheck.']['sessionStartTime'] = $extConf['SessionStartTime'];
+                       }
+
+                       if ($this->tsConf['sessionCheck.']['sessionEndTime'] == '') {
+                               $this->tsConf['sessionCheck.']['sessionEndTime'] = $extConf['SessionEndTime'];
+                       }
+
+                       if ($this->tsConf['akismetCheck.']['akismetKey'] == '') {
+                               $this->tsConf['akismetCheck.']['akismetKey'] = $extConf['AkismetKey'];
+                       }
+
+                       if ($this->tsConf['logging.']['notificationAddress'] == '') {
+                               $this->tsConf['logging.']['notificationAddress'] = $extConf['email_notify'];
+                       }
+
+                       if ($this->tsConf['logging.']['pid'] == '') {
+                               $this->tsConf['logging.']['pid'] = $extConf['pid'];
                        }
                }
-               return $this->extConf;
        }
 
        /**
index a5e283d..6e32533 100644 (file)
@@ -51,15 +51,16 @@ class tx_wtspamshield_log extends tslib_pibase {
         * @return string
         */
        public function dbLog($ext, $points, $errorMessages, $formArray) {
-               $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
+               $div = t3lib_div::makeInstance('tx_wtspamshield_div');
+               $tsConf = $div->getTsConf();
 
-               if (isset($conf) && $this->dbInsert) {
-                       if ($conf['pid'] == -1) {
+               if ($this->dbInsert) {
+                       if ($tsConf['logging.']['pid'] == -1) {
                                return FALSE;
                        }
 
-                       if ($conf['pid'] == -2) {
-                               $conf['pid'] = $GLOBALS['TSFE']->id;
+                       if ($tsConf['logging.']['pid'] == -2) {
+                               $tsConf['logging.']['pid'] = $GLOBALS['TSFE']->id;
                        }
 
                        $title = date('d.m.Y H:i:s', time()) . ' - ' .
@@ -69,7 +70,7 @@ class tx_wtspamshield_log extends tslib_pibase {
                        $errorMessage = 'Score: ' . $points;
 
                        $dbValues = array (
-                               'pid' => intval($conf['pid']),
+                               'pid' => intval($tsConf['logging.']['pid']),
                                'tstamp' => time(),
                                'crdate' => time(),
                                'title' => $title,
index 38bd198..beac003 100644 (file)
@@ -52,95 +52,95 @@ class tx_wtspamshield_mail extends tslib_pibase {
         * @return void
         */
        public function sendEmail($ext, $points, $errorMessages, $formArray, $sendPlain = 1) {
-               $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
+               $div = t3lib_div::makeInstance('tx_wtspamshield_div');
+               $tsConf = $div->getTsConf();
 
                $t3Version = class_exists('t3lib_utility_VersionNumber')
                        ? t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version)
                        : t3lib_div::int_from_ver(TYPO3_version);
 
-               if (isset($conf)) {
-                       $errorMessages['points'] = 'Score: ' . $points;
-                       $errorMessages = strip_tags(implode(' / ', $errorMessages));
+               $errorMessages['points'] = 'Score: ' . $points;
+               $errorMessages = strip_tags(implode(' / ', $errorMessages));
 
-                       if (t3lib_div::validEmail($conf['email_notify'])) {
-                               if (!$sendPlain) {
-                                               // Prepare mail
-                                       $mailtext = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-                                               <html>
-                                                       <head>
-                                                       </head>
-                                                       <body>
-                                                               <table>
-                                                                       <tr>
-                                                                               <td><strong>Extension:</strong></td>
-                                                                               <td>' . $ext . '</td>
-                                                                       </tr>
-                                                                       <tr>
-                                                                               <td><strong>PID:</strong></td>
-                                                                               <td>' . $GLOBALS['TSFE']->id . '</td>
-                                                                       </tr>
-                                                                       <tr>
-                                                                               <td><strong>URL:</strong></td>
-                                                                               <td>' . t3lib_div::getIndpEnv('HTTP_HOST') . '</td>
-                                                                       </tr>
-                                                                       <tr>
-                                                                               <td><strong>Error:</strong></td>
-                                                                               <td>' . $errorMessages . '</td>
-                                                                       </tr>
-                                                                       <tr>
-                                                                               <td><strong>IP:</strong></td>
-                                                                               <td>' . t3lib_div::getIndpEnv('REMOTE_ADDR') . '</td>
-                                                                       </tr>
-                                                                       <tr>
-                                                                               <td><strong>Useragent:</strong></td>
-                                                                               <td>' . t3lib_div::getIndpEnv('HTTP_USER_AGENT') . '</td>
-                                                                       </tr>
-                                                                       <tr>
-                                                                               <td valign=top><strong>Form values:</strong></td>
-                                                                               <td>' . $formValues . '</td>
-                                                                       </tr>
-                                                               </table>
-                                                       </body>
-                                               </html>
-                                       ';
+               if (t3lib_div::validEmail($tsConf['logging.']['notificationAddress'])) {
+                       if (!$sendPlain) {
+                                       // Prepare mail
+                               $mailtext = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+                                       <html>
+                                               <head>
+                                               </head>
+                                               <body>
+                                                       <table>
+                                                               <tr>
+                                                                       <td><strong>Extension:</strong></td>
+                                                                       <td>' . $ext . '</td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td><strong>PID:</strong></td>
+                                                                       <td>' . $GLOBALS['TSFE']->id . '</td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td><strong>URL:</strong></td>
+                                                                       <td>' . t3lib_div::getIndpEnv('HTTP_HOST') . '</td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td><strong>Error:</strong></td>
+                                                                       <td>' . $errorMessages . '</td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td><strong>IP:</strong></td>
+                                                                       <td>' . t3lib_div::getIndpEnv('REMOTE_ADDR') . '</td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td><strong>Useragent:</strong></td>
+                                                                       <td>' . t3lib_div::getIndpEnv('HTTP_USER_AGENT') . '</td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td valign=top><strong>Form values:</strong></td>
+                                                                       <td>' . $formValues . '</td>
+                                                               </tr>
+                                                       </table>
+                                               </body>
+                                       </html>
+                               ';
 
-                                               // Send mail
-                                       $this->htmlMail = t3lib_div::makeInstance('t3lib_htmlmail');
-                                       $this->htmlMail->start();
-                                       $this->htmlMail->recipient = $conf['email_notify'];
-                                       $this->htmlMail->subject = 'Spam recognized in ' . $ext . ' on ' . t3lib_div::getIndpEnv('HTTP_HOST');
-                                       $this->htmlMail->from_email = $conf['email_notify'];
-                                       $this->htmlMail->from_name = 'Spamshield';
-                                       $this->htmlMail->returnPath = $conf['email_notify'];
-                                       $this->htmlMail->setHTML($mailtext);
-                                       if ($this->sendEmail) {
-                                               $this->htmlMail->send($conf['email_notify']);
-                                       }
-                               } else {
-                                       $info = array(
-                                               'Extension' => $ext,
-                                               'PID' => $GLOBALS['TSFE']->id,
-                                               'URL' => t3lib_div::getIndpEnv('HTTP_HOST'),
-                                               'Error' => $errorMessages,
-                                               'IP' => t3lib_div::getIndpEnv('REMOTE_ADDR'),
-                                               'Useragent' => t3lib_div::getIndpEnv('HTTP_USER_AGENT'),
-                                       );
-                                       foreach ($info as $key => $value) {
-                                               $mailtext .= $key . ': ' . $value . chr(10);
-                                       }
-                                       $mailtext .= chr(10) . 'Form values:' . chr(10);
-                                       foreach ($formArray as $key => $value) {
-                                               $mailtext .= ' * ' . $key . ': ' . $value . chr(10);
-                                       }
-
-                                       $to = $conf['email_notify'];
-                                       $from = '"Spamshield" <' . $conf['email_notify'] . '>';
-                                       $subject = 'Spam recognized in ' . $ext . ' on ' . t3lib_div::getIndpEnv('HTTP_HOST');
-                                       $headers = 'From: ' . $from;
-                                       mail($to, $subject, $mailtext, $headers);
+                                       // Send mail
+                               $this->htmlMail = t3lib_div::makeInstance('t3lib_htmlmail');
+                               $this->htmlMail->start();
+                               $this->htmlMail->recipient = $tsConf['logging.']['notificationAddress'];
+                               $this->htmlMail->subject = 'Spam recognized in ' . $ext . ' on ' . t3lib_div::getIndpEnv('HTTP_HOST');
+                               $this->htmlMail->from_email = $tsConf['logging.']['notificationAddress'];
+                               $this->htmlMail->from_name = 'Spamshield';
+                               $this->htmlMail->returnPath = $tsConf['logging.']['notificationAddress'];
+                               $this->htmlMail->setHTML($mailtext);
+                               if ($this->sendEmail) {
+                                       $this->htmlMail->send($tsConf['logging.']['notificationAddress']);
+                               }
+                       } else {
+                               $info = array(
+                                       'Extension' => $ext,
+                                       'PID' => $GLOBALS['TSFE']->id,
+                                       'URL' => t3lib_div::getIndpEnv('HTTP_HOST'),
+                                       'Error' => $errorMessages,
+                                       'IP' => t3lib_div::getIndpEnv('REMOTE_ADDR'),
+                                       'Useragent' => t3lib_div::getIndpEnv('HTTP_USER_AGENT'),
+                               );
+                               foreach ($info as $key => $value) {
+                                       $mailtext .= $key . ': ' . $value . chr(10);
+                               }
+                               $mailtext .= chr(10) . 'Form values:' . chr(10);
+                               foreach ($formArray as $key => $value) {
+                                       $mailtext .= ' * ' . $key . ': ' . $value . chr(10);
                                }
+
+                               $to = $tsConf['logging.']['notificationAddress'];
+                               $from = '"Spamshield" <' . $tsConf['logging.']['notificationAddress'] . '>';
+                               $subject = 'Spam recognized in ' . $ext . ' on ' . t3lib_div::getIndpEnv('HTTP_HOST');
+                               $headers = 'From: ' . $from;
+                               mail($to, $subject, $mailtext, $headers);
                        }
                }
+
        }
 }
 
index 4c05608..7747e15 100644 (file)
@@ -3,6 +3,12 @@
 ##
 
 plugin.wt_spamshield {
+  # cat=wt_spamshield main//0005; type=boolean; label= Logging:  Enter an email address if you would like to receive an email if spam was recognized (e.g. email@domain.org).
+  logging.notificationAddress =
+
+  # cat=wt_spamshield main//0005; type=boolean; label= Logging: Enter a PID for saving spam log entries (-2 for current page, -1 deactivates logging, 0 for root page, 1 for PID 1 etc.).
+  logging.pid =
+
   # cat=wt_spamshield main//0010; type=boolean; label= Protect comments: Enable spamshield for comments
   comments = 0
 
@@ -96,6 +102,21 @@ plugin.wt_spamshield {
   # cat=wt_spamshield main//0210; type=text; label= ve_guestbook Redirect: Redirect PID for ve_guestbook
   redirect_ve_guestbook =
 
+  # cat=wt_spamshield main//0300; type=text; label= httpCheck: Set the maximum number of links (http, https, ftp) within a message. If you want to allow 3 links enter "3". If you want no links at all enter "0".
+  httpCheck.maximumLinkAmount =
+
+  # cat=wt_spamshield main//0310; type=text; label= uniqueCheck: Enter different field names (separated by comma) which should not be equal. Example for powermail: uid1 = first name and uid2 = last name -> "uid1,uid2". You can add more than one condition by splitting them with semicolons. Example for powermail: uid1 = first name, uid2 = last name, uid3 = address, uid1 and uid3 should not be equal as well as uid2 and uid3 should not be equal but uid1 and uid2 can be equal -> "uid1,uid3[semicolon]uid2,uid3".
+  uniqueCheck.fields =
+
+  # cat=wt_spamshield main//0320; type=text; label= akismetCheck: Enter your Akismet key to activate Akismet check (signup at https://akismet.com/signup/).
+  akismetCheck.akismetKey =
+
+  # cat=wt_spamshield main//0330; type=text; label= Session start time (s): Minimum time frame between entering the form page and submiting the form. 0 for disable.
+  sessionCheck.sessionStartTime =
+
+  # cat=wt_spamshield main//0340; type=text; label= Session end time (s): Maximum time frame between entering the form page and submiting the form. 0 for disable.
+  sessionCheck.sessionEndTime =
+
   # cat=wt_spamshield main//0400; type=text; label= CSS styles honeypot: CSS style for honeypot input field
   honeypot.css.inputStyle = style="position:absolute; margin:0 0 0 -999em;"
 
index 96bc59f..d500958 100644 (file)
@@ -1,5 +1,10 @@
 plugin.wt_spamshield {
 
+  logging {
+    notificationAddress = {$plugin.wt_spamshield.logging.notificationAddress}
+    pid = {$plugin.wt_spamshield.logging.pid}
+  }
+
   validators {
     standardMailform_new {
       enable = {$plugin.wt_spamshield.validators.standardMailform_new.enable}
@@ -60,6 +65,23 @@ plugin.wt_spamshield {
     ve_guestbook = {$plugin.wt_spamshield.redirect_ve_guestbook}
   }
 
+  httpCheck {
+    maximumLinkAmount = {$plugin.wt_spamshield.httpCheck.maximumLinkAmount}
+  }
+
+  uniqueCheck {
+    fields = {$plugin.wt_spamshield.uniqueCheck.fields}
+  }
+
+  akismetCheck {
+    akismetKey = {$plugin.wt_spamshield.akismetCheck.akismetKey}
+  }
+
+  sessionCheck {
+    sessionStartTime = {$plugin.wt_spamshield.sessionCheck.sessionStartTime}
+    sessionEndTime = {$plugin.wt_spamshield.sessionCheck.sessionEndTime}
+  }
+
   honeypot {
     css {
       inputStyle = {$plugin.wt_spamshield.honeypot.css.inputStyle}
@@ -172,10 +194,10 @@ plugin.wt_spamshield {
       permalink =
     }
     powermail2 {
-      author = 1
-      email = 2
-      homepage = 3
-      body = 5
+      author =
+      email =
+      homepage =
+      body =
       permalink = 
     }
     t3_blog {
diff --git a/ext_conf_template.txt b/ext_conf_template.txt
deleted file mode 100644 (file)
index dd973bf..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-TSConstantEditor.basic { 
-  description = <div style="position:absolute;top:10px;right:10px; width:300px;"><div class="typo3-message message-warning"><div class="message-header">Impotant Notice</div><div class="message-body">If you're updating from<br>wt_spamshield < 1.0.0 you have to do the following:<ul><li>Press the <b>Update button</b> (T3 = 4.x) or the <b>Save icon</b> (T3 >= 6.0) again!</li><li>Otherwise some functions (like the honeypot) will not work.</li><li>Check your XClassing. We have changed some paths.</li><ul></div></div></div>
-}
-
-# cat=basic//010; type=boolean; label= Use Name Check: Enable or disable name check. Simple comparison of first and last name. If the values are equal the post vars will be ignored.
-useNameCheck = 1
-
-# cat=basic//020; type=int [0-100]; label= Use Link Check: Set the maximum number of links (http, https, ftp) within a message. If you want to allow 3 links enter "3". If you want no links at all enter "0". "-1" disables this check completely.
-usehttpCheck = 3
-
-# cat=basic//030; type=text; label= Use Unique Check: Enter different field names (separated by comma) which should not be equal. Example for powermail: uid1 = first name and uid2 = last name -> "uid1,uid2". You can add more than one condition by splitting them with semicolons. Example for powermail: uid1 = first name, uid2 = last name, uid3 = address, uid1 and uid3 should not be equal as well as uid2 and uid3 should not be equal but uid1 and uid2 can be equal -> "uid1,uid3[semicolon]uid2,uid3".
-notUnique = 
-
-# cat=basic//040; type=boolean; label= Use Honeypot Check: A non-visible input field is added to your form. If the field is filled the message is handled as spam.
-honeypotCheck = 1
-
-# cat=basic//050; type=boolean; label= Use Session Check: Enable or disable session check. As soon as a form is generated a timestamp is stored in the session. Only if this timestamp is available during the submit process the database entry will follow (avoids POST values from outside your website).
-useSessionCheck = 1
-
-# cat=basic//060; type=int [0-3600]; label= Session start time (s): Minimum time frame between entering the form page and submiting the form. 0 for disable.
-SessionStartTime = 10
-
-# cat=basic//070; type=int [0-3600]; label= Session end time (s): Maximum time frame between entering the form page and submiting the form. 0 for disable.
-SessionEndTime = 600
-
-# cat=basic//080; type=text; label= Akismet Key: Enter your Akismet key to activate Akismet check (signup at https://akismet.com/signup/).
-AkismetKey =
-
-# cat=basic//090; type=text; label= Send email if spam: Enter an email address if you would like to receive an email if spam was recognized (e.g. email@domain.org).
-email_notify =
-
-# cat=basic//100; type=int; label= PID for logs: Enter a PID for saving spam log entries (-2 for current page, -1 deactivates logging, 0 for root page, 1 for PID 1 etc.).
-pid = 0