function httpbl_admin_settings_validate in http:BL 5
Same name and namespace in other branches
- 6.2 httpbl.module \httpbl_admin_settings_validate()
- 6 httpbl.module \httpbl_admin_settings_validate()
- 7 httpbl.admin.inc \httpbl_admin_settings_validate()
Form API callback to validate the httpbl settings form.
File
- ./
httpbl.module, line 219 - Implementation of http:BL for Drupal. It provides IP-based blacklisting through http:BL and allows linking to a honeypot.
Code
function httpbl_admin_settings_validate($form_id, $form_values) {
$key = $form_values['httpbl_accesskey'];
if ($form_values['httpbl_check'] && !$key) {
form_set_error('httpbl_accesskey', t('You must enter an access key to enable blacklist checks.'));
}
if ($form_values['httpbl_footer'] && !$form_values['httpbl_link']) {
form_set_error('httpbl_link', t('You must enter a link to be able to add it to the footer.'));
}
if (!is_numeric($form_values['httpbl_threatlevel']) || $form_values['httpbl_threatlevel'] > 255 || $form_values['httpbl_threatlevel'] < 0) {
form_set_error('httpbl_threatlevel', t('Threat level threshold should be a numeric value between 0 to 255.'));
}
if ($key) {
// key should be 12 lowercase alpha characters
if (ereg('[^a-z]', $key) || strlen($key) != 12) {
form_set_error('httpbl_accesskey', t('Your access key is formatted incorrectly.'));
}
else {
if (!count(form_get_errors())) {
// look up 127.80.1.1 as a test
$lookup = httpbl_dnslookup('127.1.80.1', $key);
if (!$lookup && $lookup['threat'] == 80) {
form_set_error('httpbl_accesskey', t('Testcase failed. This either means that your access key is incorrect or that there is a problem in your DNS system.'));
}
else {
drupal_set_message('http:BL test completed succesfully.');
}
}
}
}
}