You are here

function httpbl_admin_settings in http:BL 6.2

Same name and namespace in other branches
  1. 5 httpbl.module \httpbl_admin_settings()
  2. 6 httpbl.module \httpbl_admin_settings()
  3. 7 httpbl.admin.inc \httpbl_admin_settings()

Implementation of hook_settings().

1 string reference to 'httpbl_admin_settings'
httpbl_menu in ./httpbl.module
Implementation of hook_menu().

File

./httpbl.module, line 232
Implementation of http:BL for Drupal. It provides IP-based blacklisting through http:BL and allows linking to a honeypot.

Code

function httpbl_admin_settings() {
  if (!$_POST && (!variable_get('httpbl_accesskey', NULL) || !variable_get('httpbl_check', HTTPBL_CHECK_NONE))) {
    drupal_set_message(t('Blacklist lookups are currently disabled; enter your access key below and enable checks to enable blacklist lookups.'), 'error');
  }
  $form['core'] = array(
    '#type' => 'fieldset',
    '#title' => t('http:BL'),
    '#description' => t('For more information about http:BL, see the <a href="http://www.projecthoneypot.org/httpbl.php">http:BL homepage</a>.'),
    '#collapsible' => TRUE,
  );
  $form['core']['httpbl_accesskey'] = array(
    '#type' => 'textfield',
    '#title' => t('http:BL Access Key'),
    '#default_value' => variable_get('httpbl_accesskey', NULL),
    '#description' => t('Your http:BL <a href="http://www.projecthoneypot.org/httpbl_configure.php">Access Key</a>.'),
    '#size' => 20,
    '#maxlength' => 12,
  );
  $form['core']['httpbl_check'] = array(
    '#type' => 'radios',
    '#title' => t('Blacklist checks'),
    '#default_value' => variable_get('httpbl_check', HTTPBL_CHECK_NONE),
    '#options' => array(
      t('Disabled'),
      t('Only on comment submissions'),
      t('On all page requests'),
    ),
    '#description' => t('At what times the blacklist should be checked.'),
  );
  $form['honeypot'] = array(
    '#type' => 'fieldset',
    '#title' => t('Honeypot'),
    '#description' => t('Your Honeypot (spam trap) settings. For more information, see the <a href="http://www.projecthoneypot.org/">Project Honey Pot homepage</a>.'),
    '#collapsible' => TRUE,
  );
  $form['honeypot']['httpbl_footer'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add link to footer'),
    '#default_value' => variable_get('httpbl_footer', FALSE),
    '#description' => t('Whether to add your honeypot link to the footer of every page.'),
  );
  $form['honeypot']['httpbl_link'] = array(
    '#type' => 'textfield',
    '#title' => t('Honeypot link'),
    '#default_value' => variable_get('httpbl_link', NULL),
    '#description' => t('Your Honeypot (spam trap) link. This can be one of your <a href="http://www.projecthoneypot.org/manage_honey_pots.php">own Honey Pots</a> or a <a href="http://www.projecthoneypot.org/manage_quicklink.php">QuickLink</a>.'),
  );
  $form['honeypot']['httpbl_word'] = array(
    '#type' => 'textfield',
    '#title' => t('Link word'),
    '#default_value' => variable_get('httpbl_word', 'randomness'),
    '#description' => t('A random word which will be used as a link.'),
  );
  $form['advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['advanced']['httpbl_log'] = array(
    '#type' => 'checkbox',
    '#title' => t('Positive watchdog logging'),
    // Not really all that verbose
    '#default_value' => variable_get('httpbl_log', FALSE),
    '#description' => t('Logs all positive lookups in the watchdog.'),
  );
  $form['advanced']['httpbl_stats'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable statistics'),
    '#default_value' => variable_get('httpbl_stats', TRUE),
    '#description' => t('Whether to enable counting of positive lookups. Statistics are show on the Drupal <a href="@statusreport">Status report page</a>.', array(
      '@statusreport' => url('admin/reports/status'),
    )),
  );
  $form['advanced']['httpbl_cache'] = array(
    '#type' => 'radios',
    '#title' => t('Caching'),
    '#default_value' => variable_get('httpbl_cache', HTTPBL_CACHE_DBDRUPAL),
    '#options' => array(
      t('Off'),
      t('Database cache'),
      t('Database cache and Drupal access table'),
    ),
    '#description' => t('Whether to enable database-based caching. Note that when this is disabled, IPs that fail the session whitelist test cannot be banned. The Drupal access table allows visitors to be blocked in the early stages of the bootstrap.'),
  );
  $blacklist_threshold_options = drupal_map_assoc(array(
    50,
    55,
    60,
    65,
    70,
    75,
    80,
    85,
    90,
    95,
    100,
    200,
    255,
  ));
  $form['advanced']['httpbl_black_threshold'] = array(
    '#type' => 'select',
    '#title' => t('Blacklisting Threshhold'),
    '#default_value' => variable_get('httpbl_black_threshold', HTTPBL_THRESHOLD_BLACK),
    '#options' => $blacklist_threshold_options,
    '#description' => t('Threshold above which a user is blacklisted.  Use this to fine-tune the Honeypot threat-levels for Black-listing. Note that threat levels at 100 or more effectively turns off Blacklisting (they are extremely rare).  If you want to stop blacklisting altogether, set this to 255.'),
  );
  $form['advanced']['httpbl_message_black'] = array(
    '#type' => 'textarea',
    '#title' => t('Blacklist message'),
    '#default_value' => variable_get('httpbl_message_black', "Sorry, %ip has been blacklisted by <a href=\"%ipurl\">http:BL</a>.\n%honeypot"),
    '#description' => t("The message visitors will see when their IP is blacklisted. <em>%ip</em> will be replaced with the visitor's IP, <em>%ipurl</em> with a link to the Project Honeypot information page for that IP, <em>%honeypot</em> with your Honeypot link."),
  );
  $greylist_threshold_options = drupal_map_assoc(array(
    1,
    2,
    3,
    4,
    5,
    10,
    15,
    20,
    25,
    30,
    35,
    40,
    45,
  ));
  $form['advanced']['httpbl_grey_threshold'] = array(
    '#type' => 'select',
    '#title' => t('Greylisting Threshhold'),
    '#default_value' => variable_get('httpbl_grey_threshold', HTTPBL_THRESHOLD_GREY),
    '#options' => $greylist_threshold_options,
    '#description' => t('Threshold at which a user is allowed, above which a user is greylisted.  Use this to fine-tune the Honeypot threat-levels that you are willing to permit for access to your site.'),
  );
  $form['advanced']['httpbl_message_grey'] = array(
    '#type' => 'textarea',
    '#title' => t('Greylist message'),
    '#default_value' => variable_get('httpbl_message_grey', "Sorry, %ip has been greylisted by <a href=\"%ipurl\">http:BL</a>.\nYou may try whitelisting on <a href=\"%whitelisturl\">%whitelisturl</a>.\n%honeypot"),
    '#description' => t("The message visitors will see when their IP is greylisted. <em>%ip</em> will be replaced with the visitor's IP, <em>%ipurl</em> with a link to the Project Honeypot information page for that IP, <em>%honeypot</em> with your Honeypot link, <em>%whitelisturl</em> with the internal whitelist request URL."),
  );
  $cache_period = drupal_map_assoc(array(
    10800,
    21600,
    32400,
    43200,
    86400,
    172800,
    259200,
    604800,
    1209600,
    2419200,
  ), 'format_interval');
  $form['advanced']['httpbl_safe_offset'] = array(
    '#type' => 'select',
    '#title' => t('Safe Visitor Cache Expires in...'),
    '#default_value' => variable_get('httpbl_safe_offset', 10800),
    '#options' => $cache_period,
    '#description' => t('How long to keep safe or white-listed IPs in cache.'),
  );
  $cache_period2 = drupal_map_assoc(array(
    43200,
    86400,
    172800,
    259200,
    604800,
    1209600,
    1814400,
    2419200,
  ), 'format_interval');
  $form['advanced']['httpbl_greylist_offset'] = array(
    '#type' => 'select',
    '#title' => t('Grey Listed Visitor Cache Expires in...'),
    '#default_value' => variable_get('httpbl_greylist_offset', 86400),
    '#options' => $cache_period2,
    '#description' => t('How long to keep grey-listed IPs in cache.'),
  );
  $cache_period3 = drupal_map_assoc(array(
    604800,
    1209600,
    1814400,
    2419200,
    7257600,
    15724800,
    31536000,
    63072000,
    94608000,
  ), 'format_interval');
  $form['advanced']['httpbl_blacklist_offset'] = array(
    '#type' => 'select',
    '#title' => t('Black Listed Visitor Cache Expires in...'),
    '#default_value' => variable_get('httpbl_blacklist_offset', 31536000),
    '#options' => $cache_period3,
    '#description' => t('How long to keep black-listed IPs in cache (and also banned in Access table, when applicable).'),
  );
  return system_settings_form($form);
}