function check(&$aInputs) { $oChecker = $this->_oChecker; $iErrors = 0; // check CSRF token if it's needed. if (getParam('sys_security_form_token_enable') == 'on' && $this->_bFormCsrfChecking === true && ($mixedCsrfTokenSys = BxDolForm::getCsrfToken()) !== false) { $mixedCsrfTokenUsr = BxDolForm::getSubmittedValue('csrf_token', $this->_sFormMethod, $this->_aSpecificValues); unset($aInputs['csrf_token']); if ($mixedCsrfTokenUsr === false || $mixedCsrfTokenSys != $mixedCsrfTokenUsr) { return false; } } $sSubmitName = false; foreach ($aInputs as $k => $a) { if (isset($a['visible_for_levels']) && !BxDolForm::isVisible($a)) { continue; } if (empty($a['name']) || 'submit' == $a['type'] || 'reset' == $a['type'] || 'button' == $a['type'] || 'value' == $a['type']) { if (isset($a['type']) && 'submit' == $a['type']) { $sSubmitName = $k; } continue; } if ('input_set' == $a['type']) { foreach ($a as $r) { if (isset($r['type']) && 'submit' == $r['type']) { $sSubmitName = $k; } } } $a['name'] = str_replace('[]', '', $a['name']); $val = BxDolForm::getSubmittedValue($a['name'], $this->_sFormMethod, $this->_aSpecificValues); if (isset(BxDolForm::$TYPES_FILE[$a['type']])) { $val = isset($_FILES[$a['name']]['name']) ? $_FILES[$a['name']]['name'] : ''; } if (!isset($a['checker'])) { if (isset(BxDolForm::$TYPES_CHECKBOX[$a['type']])) { $aInputs[$k]['checked'] = isset($aInputs[$k]['value']) && $aInputs[$k]['value'] == $val; } elseif (!isset(BxDolForm::$TYPES_FILE[$a['type']])) { $aInputs[$k]['value'] = bx_process_input($val); } continue; } $sCheckFunction = array($oChecker, 'check' . bx_gen_method_name($a['checker']['func'])); if (is_callable($sCheckFunction)) { $bool = call_user_func_array($sCheckFunction, !empty($a['checker']['params']) ? array_merge(array($val), $a['checker']['params']) : array($val)); } else { $bool = true; } if (is_string($bool)) { ++$iErrors; $aInputs[$k]['error'] = $bool; } elseif (!$bool) { ++$iErrors; $aInputs[$k]['error'] = $a['checker']['error']; } if (isset(BxDolForm::$TYPES_CHECKBOX[$a['type']])) { $aInputs[$k]['checked'] = $aInputs[$k]['value'] == $val; } elseif (!isset(BxDolForm::$TYPES_FILE[$a['type']])) { $aInputs[$k]['value'] = bx_process_input($val); } } // check for spam if (!$iErrors) { foreach ($aInputs as $k => $a) { if ($a['type'] != 'textarea') { continue; } $a['name'] = str_replace('[]', '', $a['name']); $val = BxDolForm::getSubmittedValue($a['name'], $this->_sFormMethod, $this->_aSpecificValues); if (!$val) { continue; } if (!$oChecker->checkIsSpam($val)) { continue; } ++$iErrors; $sErr = _t('_sys_spam_detected'); if (BxDolRequest::serviceExists('bx_contact', 'get_contact_page_url') && ($sUrl = BxDolService::call('bx_contact', 'get_contact_page_url'))) { $sErr = _t('_sys_spam_detected_contact', $sUrl); } $aInputs[$k]['error'] = $sErr; } } // add error message near submit button if ($iErrors && $sSubmitName) { $aInputs[$sSubmitName]['error'] = _t('_sys_txt_form_submission_error'); } return $iErrors ? false : true; }