function badbehavior_settings_form_validate in Bad Behavior 6.2
Same name and namespace in other branches
- 6 badbehavior.admin.inc \badbehavior_settings_form_validate()
- 7.2 badbehavior.admin.inc \badbehavior_settings_form_validate()
Settings admimistration form field validation
Parameters
$form:
$form_state:
File
- ./
badbehavior.admin.inc, line 229 - Admin page callbacks for the badbehavior module.
Code
function badbehavior_settings_form_validate($form, &$form_state) {
$values = $form_state['values'];
if (!empty($values['badbehavior_httpbl_quicklink'])) {
if (!valid_url($values['badbehavior_httpbl_quicklink'], $absolute = TRUE)) {
form_set_error('badbehavior_httpbl_quicklink', t('You must enter a valid Project Honey Pot QuickLink URL, or leave the field blank.'));
}
}
if (!preg_match("/^[a-zA-Z0-9 -]+\$/", $values['badbehavior_httpbl_quicklinktext'])) {
form_set_error('badbehavior_httpbl_quicklinktext', t('You must enter only alphanumeric characters, dashes, and spaces in the Project Honey Pot QuickLink Hidden Text field. (no special characters or symbols)'));
}
if (!preg_match("/^[a-zA-Z0-9 -_]+\$/", $values['badbehavior_reverse_proxy_header'])) {
form_set_error('badbehavior_reverse_proxy_header', t('You must enter only alphanumeric characters, dashes, underscores, and spaces in the Reverse Proxy Header field. (no special characters or symbols)'));
}
if (!empty($values['badbehavior_httpbl_key'])) {
if (!preg_match("/^[a-zA-Z]{12}\$/", $values['badbehavior_httpbl_key'])) {
form_set_error('badbehavior_httpbl_key', t('You must enter a valid Project Honey Pot http:BL Key, which can only be exactly 12 alphabetic characters. (no numbers or symbols) Leave the field blank to disable this function.'));
}
}
if (!valid_email_address($values['badbehavior_mail'])) {
form_set_error('badbehavior_mail', t('The e-mail address %mail is not valid.', array(
'%mail' => $values['badbehavior_mail'],
)));
}
if (!is_numeric($values['badbehavior_httpbl_threat']) || $values['badbehavior_httpbl_threat'] < 0 || $values['badbehavior_httpbl_threat'] >= 256) {
form_set_error('badbehavior_httpbl_threat', t('You must enter only a number from 0 to 255 for the http:BL Threat Level.'));
}
if (!is_numeric($values['badbehavior_httpbl_age']) || $values['badbehavior_httpbl_age'] <= 0 || $values['badbehavior_httpbl_age'] >= 61) {
form_set_error('badbehavior_httpbl_age', t('You must enter only a number from 1 to 60 for the http:BL Maximum Threat Age.'));
}
}