You are here

function ip_ranges_form in IP Ranges 7

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

Defines the form for banning IP addresses.

See also

ip_ranges_form_submit()

1 string reference to 'ip_ranges_form'
ip_ranges_page in ./ip_ranges.admin.inc
Menu callback. Displays banned IP ranges.

File

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

Code

function ip_ranges_form($form, $form_state) {
  $form['ip_start'] = array(
    '#prefix' => t('<strong>Note that your own IP-Address is currently <i>' . ip_address() . '</i>. Be carefull not to lock yourself out!<br />' . l('Click here to whitelist your own IP-address.', 'admin/config/people/ip-ranges/whitelist_own') . '</strong>'),
    '#title' => t('IP range start / Single IP-address'),
    '#type' => 'textfield',
    '#size' => 48,
    '#required' => TRUE,
    '#maxlength' => 15,
    '#description' => t('Enter IP-address (100.100.100.100). If range end is specified, it will be used as start of the range, otherwise as a single IP-address.'),
  );
  $form['ip_end'] = array(
    '#title' => t('IP range end (optional)'),
    '#type' => 'textfield',
    '#size' => 48,
    '#required' => FALSE,
    '#maxlength' => 15,
    '#description' => t('If entered, the banned ip will be treated as a range.'),
  );
  $form['type'] = array(
    '#title' => t('List type'),
    '#type' => 'select',
    '#multiple' => FALSE,
    '#options' => array(
      'blacklist' => 'blacklist',
      'whitelist' => 'whitelist',
    ),
    '#default_value' => 'blacklist',
    '#required' => TRUE,
    '#description' => t('Choose list type.'),
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add'),
  );
  $form['#validate'][] = 'ip_ranges_form_validate';
  $form['#submit'][] = 'ip_ranges_form_submit';
  return $form;
}