function _ip_ban_validate_ips in IP Ban 7
Same name and namespace in other branches
- 8 ip_ban.admin.inc \_ip_ban_validate_ips()
Custom validation function for valid IP addresses.
Custom validation function for the list of additional IP addresses to either ban or mark as read-only. We convert the textarea into an array of IP addresses, then check if each address is valid. If any one line is invalid, we set the entire form element to invalid.
1 call to _ip_ban_validate_ips()
- ip_ban_validate in ./
ip_ban.admin.inc - Custom form validation function.
File
- ./
ip_ban.admin.inc, line 158 - Administration functions for the IP Ban module.
Code
function _ip_ban_validate_ips($form_element, $form_value) {
if (!empty($form_value)) {
$ip_array = explode(PHP_EOL, $form_value);
foreach ($ip_array as $ip) {
if (filter_var(trim($ip), FILTER_VALIDATE_IP) == FALSE) {
form_set_error($form_element, t('You have entered one or more incorrect IPV4 addresses.'));
}
}
}
}