function autoban_form_submit in Automatic IP ban (Autoban) 7
Form submission for autoban_form().
File
- ./
autoban.admin.inc, line 350 - Configuration for autoban module.
Code
function autoban_form_submit($form, &$form_state) {
$type = filter_xss(trim($form_state['values']['type']));
$message = filter_xss(trim($form_state['values']['message']));
$threshold = intval($form_state['values']['threshold']);
$user_type = $form_state['values']['user_type'];
$referer = $form_state['values']['referer'];
$ip_type = $form_state['values']['ip_type'];
$rid = $form_state['values']['rule_id'];
$fields = array(
'type' => $type,
'message' => $message,
'threshold' => $threshold,
'user_type' => $user_type,
'referer' => $referer,
'ip_type' => $ip_type,
'changed' => REQUEST_TIME,
);
if ($rid) {
// Update record.
db_update('autoban')
->fields($fields)
->condition('rid', $rid)
->execute();
$message = t('Autoban rule @rid was updated.', array(
'@rid' => $rid,
));
}
else {
// Insert record.
$fields['created'] = REQUEST_TIME;
db_insert('autoban')
->fields($fields)
->execute();
$message = t('New autoban rule was inserted.');
}
drupal_set_message($message);
// Redirect to autoban base url.
if (current_path() != AUTOBAN_BASE_URL) {
$form_state['redirect'] = AUTOBAN_BASE_URL;
}
// Reset stored rules.
drupal_static_reset('autoban_get_rules');
}