You are here

function httpbl_boot in http:BL 6

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

Implementation of hook_boot().

File

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

Code

function httpbl_boot() {

  // Only continue when checks are enabled
  if (variable_get('httpbl_check', HTTPBL_CHECK_NONE) != HTTPBL_CHECK_ALL) {
    return;
  }
  $result = httpbl_check();
  if ($result) {
    if ($result == HTTPBL_LIST_GREY) {
      if ($_GET['q'] == 'httpbl/whitelist') {
        return;
      }
      $message = 'Sorry, %ip has been greylisted by <a href="%ipurl">http:BL</a>.<br>You may try whitelisting on <a href="%whitelisturl">%whitelisturl</a>.%honeypot';
    }
    else {
      if ($result == HTTPBL_LIST_BLACK) {
        $message = 'Sorry, %ip has been blacklisted by <a href="%ipurl">http:BL</a>.%honeypot';
      }
    }
    if ($link = variable_get('httpbl_link', NULL)) {
      $word = variable_get('httpbl_word', 'randomness');
      $link = httpbl_honeylink($link, $word);
    }
    $message = strtr($message, array(
      '%ip' => ip_address(),
      '%ipurl' => _httpbl_ipdata(ip_address(), FALSE),
      '%honeypot' => $link,
      '%whitelisturl' => _httpbl_url('/httpbl/whitelist'),
    ));
    header('HTTP/1.1 403 Forbidden');
    echo $message;
    exit;
  }
}