You are here

function antispam_webform_check in AntiSpam 7

Webform: Check submitted values for spam.

1 string reference to 'antispam_webform_check'
antispam_form_alter in ./antispam.module
Implements hook_form_alter().

File

./antispam.module, line 711
Primary hook implementations for the Antispam module.

Code

function antispam_webform_check($form, &$form_state) {
  if (variable_get('antispam_webform_enabled', FALSE)) {
    foreach ($form_state['values']['submitted'] as $value) {
      if (is_string($value) && !is_numeric($value) && strlen($value) > 5 && antispam_api_cmd_spam_check($value) === ANTISPAM_API_RESULT_IS_SPAM) {
        watchdog('spam detected', "Spam detected in webform value '%value'", array(
          '%value' => $value,
        ), WATCHDOG_NOTICE);
        form_error($form_state['clicked_button'], t('Invalid input'));
        return;
      }
    }
  }
}