You are here

function system_ip_blocking_form_validate in Drupal 7

1 string reference to 'system_ip_blocking_form_validate'
system_ip_blocking_form in modules/system/system.admin.inc
Define the form for blocking IP addresses.

File

modules/system/system.admin.inc, line 1444
Admin page callbacks for the system module.

Code

function system_ip_blocking_form_validate($form, &$form_state) {
  $ip = trim($form_state['values']['ip']);
  if (db_query("SELECT * FROM {blocked_ips} WHERE ip = :ip", array(
    ':ip' => $ip,
  ))
    ->fetchField()) {
    form_set_error('ip', t('This IP address is already blocked.'));
  }
  elseif ($ip == ip_address()) {
    form_set_error('ip', t('You may not block your own IP address.'));
  }
  elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) == FALSE) {
    form_set_error('ip', t('Enter a valid IP address.'));
  }
}