function autoban_settings_form in Automatic IP ban (Autoban) 7
Autoban settings form.
1 string reference to 'autoban_settings_form'
- autoban_menu in ./
autoban.module - Implements hook_menu().
File
- ./
autoban.admin.inc, line 837 - Configuration for autoban module.
Code
function autoban_settings_form($form, &$form_state) {
$modules_list = array(
'ip_ranges',
'blocked_ips_expire',
);
$modules_items = array();
foreach ($modules_list as $name) {
$module_status = module_exists($name) ? t('Installed') : t('Not installed');
$module_url = l($name, url('https://drupal.org/project/' . $name), array(
'html' => TRUE,
));
$modules_items[] = t('Module') . ' ' . t('!name: @status', array(
'!name' => $module_url,
'@status' => $module_status,
));
}
$form['autoban_modules_info'] = array(
'#markup' => theme('item_list', array(
'title' => t('Modules'),
'items' => $modules_items,
)),
);
$form['autoban_cron_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Cron mode'),
'#default_value' => variable_get('autoban_cron_enable', TRUE),
'#description' => t('If checked, Autoban will enabled IP ban by cron.'),
);
$form['autoban_force_enable'] = array(
'#type' => 'checkbox',
'#title' => t('Forced mode'),
'#default_value' => variable_get('autoban_force_enable', FALSE),
'#description' => t('If checked, Autoban will do IP ban at the end of most regular page requests.'),
);
$form['autoban_thresholds'] = array(
'#type' => 'textfield',
'#title' => t('Thresholds'),
'#required' => TRUE,
'#default_value' => variable_get('autoban_thresholds', '1,2,3,5,10,20,50,100,200,500,1000'),
'#description' => t('Thresholds list, comma delimited.'),
);
$form['autoban_query_mode'] = array(
'#type' => 'radios',
'#title' => t('Query mode'),
'#options' => array(
t('LIKE'),
t('REGEXP'),
),
'#default_value' => variable_get('autoban_query_mode', 0),
'#description' => t('Use REGEXP option if your SQL engine supports REGEXP syntax.'),
);
$form['autoban_use_wildcards'] = array(
'#type' => 'checkbox',
'#title' => t('Use wildcards'),
'#default_value' => variable_get('autoban_use_wildcards', FALSE),
'#description' => t('If not checked, Autoban will add % to begin and end of message patterns.'),
);
$form['autoban_dblog_type_exclude'] = array(
'#type' => 'textfield',
'#title' => t('Exclude dblog types'),
'#default_value' => variable_get('autoban_dblog_type_exclude', 'autoban,cron,php,system,user'),
'#description' => t('Exclude dblog types events from ban, analyze and force mode.'),
);
$form['autoban_whitelist_domains'] = array(
'#type' => 'textfield',
'#title' => t('IP addresses whitelist by domains'),
'#default_value' => variable_get('autoban_whitelist_domains', ''),
'#description' => t('Enter a list of whitelist domains, e.x. "google.com, googlebot.com", comma delimited.'),
);
$form['autoban_whitelist_source'] = array(
'#type' => 'radios',
'#title' => t('IP addresses whitelist source'),
'#options' => array(
AUTOBAN_WHITELIST_SOURCE_VARIABLE => t('Manual entry'),
AUTOBAN_WHITELIST_SOURCE_FILE => t('File'),
),
'#default_value' => variable_get('autoban_whitelist_source', AUTOBAN_WHITELIST_SOURCE_VARIABLE),
);
$form['autoban_whitelist'] = array(
'#type' => 'textarea',
'#title' => t('Manual IP addresses whitelist'),
'#default_value' => variable_get('autoban_whitelist', ''),
'#description' => t('Enter a list of IP addresses. Format: CIDR "aa.bb.cc.dd/ee" or "aa.bb.cc.dd". # symbol use as a comment. The rows beginning with # are comments and are ignored.'),
'#rows' => 10,
'#cols' => 30,
'#states' => array(
'visible' => array(
'input[name="autoban_whitelist_source"]' => array(
'value' => 0,
),
),
),
);
$form['autoban_whitelist_file'] = array(
'#type' => 'textfield',
'#title' => t('IP addresses whitelist file path'),
'#default_value' => variable_get('autoban_whitelist_file', ''),
'#description' => t('A local file system path to a text file of IP addresses. Format: CIDR "aa.bb.cc.dd/ee" or "aa.bb.cc.dd". # symbol use as a comment. This file must exist and be readable by Drupal. It may be an absolute path, or a relative path (relative to the Drupal installation directory). Drupal schemes such as "private://" are supported.'),
'#states' => array(
'visible' => array(
'input[name="autoban_whitelist_source"]' => array(
'value' => 1,
),
),
),
);
$form['autoban_large_list'] = array(
'#type' => 'select',
'#title' => t('Number rows for large lists.'),
'#multiple' => FALSE,
'#options' => drupal_map_assoc(array(
50,
100,
150,
200,
500,
1000,
1000000,
)),
'#default_value' => variable_get('autoban_large_list', 150),
'#description' => t('The number of rows for which the list is large. To speed up, large lists have limited functionality.'),
);
$form['autoban_gethostbyaddr_function'] = array(
'#type' => 'select',
'#title' => t('Function for getting Internet host.'),
'#multiple' => FALSE,
'#options' => array(
'gethostbyaddr' => t('PHP gethostbyaddr()'),
'_autoban_digexec' => t('Autoban exec(dig)'),
'ipstack' => t('Ipstack (need API key)'),
),
'#default_value' => variable_get('autoban_gethostbyaddr_function', 'gethostbyaddr'),
'#description' => t('Choose the function for getting the Internet host name corresponding to a given IP address. Use alternate function when gethostbyaddr() is slow.'),
);
$form['autoban_ipstack_apikey'] = array(
'#type' => 'textfield',
'#title' => t('Ipstack.com Access Key'),
'#default_value' => variable_get('autoban_ipstack_apikey', ''),
'#description' => t('Get Access Key by register at <a href="https://ipstack.com" rel="nofollow" target="_new">Ipstack.com</a>'),
);
return system_settings_form($form);
}