You are here

function ip_ranges_form_validate in IP Ranges 7

Same name and namespace in other branches
  1. 7.2 ip_ranges.admin.inc \ip_ranges_form_validate()

Form validation handler for ip_ranges_form().

1 string reference to 'ip_ranges_form_validate'
ip_ranges_form in ./ip_ranges.admin.inc
Defines the form for banning IP addresses.

File

./ip_ranges.admin.inc, line 80
Page callback file for the ip ranges module.

Code

function ip_ranges_form_validate($form, &$form_state) {
  $ip_start = trim($form_state['values']['ip_start']);
  $ip_end = isset($form_state['values']['ip_end']) ? trim($form_state['values']['ip_end']) : FALSE;
  if (filter_var($ip_start, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) == FALSE) {
    form_set_error('ip_start', t("IP(/range start) is not a valid IP address."));
  }
  elseif ($ip_end && filter_var($ip_end, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) == FALSE) {
    form_set_error('ip_end', t("IP range end is not a valid IP address."));
  }
  elseif ($ip_start == ip_address() || $ip_end && ip_ranges_check_range($ip_start . '-' . $ip_end, ip_address())) {

    // This fires if users own IP is in the selected range. Currently we wont do anything in that case.
  }
}