You are here

function comment_spam_scan in Spam 6

Scan comment content before it is posted into the database.

1 string reference to 'comment_spam_scan'
comment_spamapi_form_alter in content/spam_content_comment.inc
Form alter gets its own function so we can reference &$form without causing errors in PHP4 installations. (If we use spamapi, we have to set a default, which PHP4 doesn't support.)

File

content/spam_content_comment.inc, line 410
Include file for integration with comments.

Code

function comment_spam_scan($form, &$form_state) {

  // not all modes need this
  if ($form_state['clicked_button']['#value'] == t('Save') && in_array(variable_get('spam_visitor_action', SPAM_ACTION_PREVENT), array(
    SPAM_ACTION_PREVENT_SILENT,
    SPAM_ACTION_PREVENT,
  ))) {
    $comment = $form['#post'];
    if (!empty($comment->comment)) {
      $_SESSION['spam_form'] = $form;
      spam_scan($comment, 'comment');
    }
  }

  // spam_form is used if we catch spam in spam_scan, we can now free it
  if (isset($_SESSION['spam_form'])) {
    unset($_SESSION['spam_form']);
  }
}