You are here

function httpbl_request_whitelist_validate in http:BL 5

Same name and namespace in other branches
  1. 6.2 httpbl.module \httpbl_request_whitelist_validate()
  2. 6 httpbl.module \httpbl_request_whitelist_validate()
  3. 7 httpbl.module \httpbl_request_whitelist_validate()

File

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

Code

function httpbl_request_whitelist_validate($form_id, $form_values) {
  $ip = _httpbl_ip_address();
  $iplink = _httpbl_iplink($ip);
  if ($form_values['block'] || $form_values['leave']) {
    if (variable_get('httpbl_dbcache', TRUE)) {
      _httpbl_cache_update($ip, 1, 86400);
      if (variable_get('httpbl_log', 1)) {
        watchdog('httpbl', t('%ip failed session whitelist request, blacklisted for 24 hours.', array(
          '%ip' => $ip,
        )), WATCHDOG_WARNING, $iplink);
      }
      print t('Whitelist request failed; your IP has been blacklisted for 24 hours.');
      exit;
    }
    else {
      if (variable_get('httpbl_log', 1)) {
        watchdog('httpbl', t('%ip failed session whitelist request.', array(
          '%ip' => $ip,
        )), WATCHDOG_WARNING, $iplink);
      }
      print t('Whitelist request failed.');
      exit;
    }
  }
  if (variable_get('httpbl_log', 1)) {
    watchdog('httpbl', t('%ip tried a whitelist request', array(
      '%ip' => $ip,
    )), WATCHDOG_NOTICE, $iplink);
  }
}