You are here

function _ip_login_user_form_validate in IP Login 7.2

Callback for hook_form_alter().

1 string reference to '_ip_login_user_form_validate'
ip_login_form_alter in ./ip_login.module
Implementation of hook_form_alter().

File

./ip_login.module, line 286
Allow user login by IP addresses, ranges or wildcards.

Code

function _ip_login_user_form_validate($form, &$form_state) {

  //TODO: replace with regexp ideally

  // validate: replace all non-numeric but legal IP range chars with '|'
  $value = $form['ip_login_matches']['ip_login_match']['#value'];
  $ip_login_addresses = strtr($value, ' ,.-*', '|||||');
  foreach (explode('|', $ip_login_addresses) as $quad) {
    if (!empty($quad) && !is_numeric($quad)) {

      // bad entry, warn & bail
      form_set_error('ip_login_matches', t('Only numbers, spaces, commas, dots, asterisks and hyphens allowed in IP ranges.'));
    }
  }
}