function spamicide_validate in Spamicide 5
Same name and namespace in other branches
- 8 spamicide.module \spamicide_validate()
- 6 spamicide.module \spamicide_validate()
- 7 spamicide.module \spamicide_validate()
Implementation of hook_validate
Parameters
$form_values:
Return value
none
1 string reference to 'spamicide_validate'
- spamicide_form_alter in ./
spamicide.module - Implementation of hook_form_alter
File
- ./
spamicide.module, line 395 - This module provides yet another tool to eliminate spam.
Code
function spamicide_validate($form_values) {
$form_id = $form_values['#post']['form_id'];
$spamicide_field = _spamicide_get_field($form_id);
if (!$spamicide_field) {
return;
}
else {
if (empty($form_values['#post'][$spamicide_field])) {
return;
}
else {
// update attempt counter
variable_set('spamicide_attempt_counter', variable_get('spamicide_attempt_counter', 0) + 1);
// log to watchdog if needed
if (variable_get('spamicide_log_attempts', FALSE)) {
watchdog('Spamicide', t('%form_id post blocked by Spamicide module: their IP address is "%ipaddress".', array(
'%form_id' => $form_id,
'%ipaddress' => $_SERVER['REMOTE_ADDR'],
)), WATCHDOG_NOTICE);
}
// If Spamicide was on a login form: stop validating, quit the current request
// and forward to the current page (like a reload) to prevent logging in.
// We do that because the log in procedure, which happens after
// spamicide_validate(), does not check error conditions of extra form
// elements like the Spamicide.
if ($form_id == 'user_login' || $form_id == 'user_login_block') {
drupal_goto($_GET['q']);
}
else {
drupal_goto($form_values['#post']['destination']);
}
}
}
}