You are here

function _httpbl_cache_set in http:BL 6

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

Write status value into cache table

1 call to _httpbl_cache_set()
httpbl_check in ./httpbl.module
Check if an IP should be banned

File

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

Code

function _httpbl_cache_set($ip, $status, $offset = 0) {

  // DELETE and then INSERT leads to race conditions [#723358].
  // INSERT IGNORE could work as well, but neither have PostgreSQL alternatives.
  // db_query("DELETE FROM {httpbl} WHERE hostname = '%s'", $ip);
  db_query("REPLACE {httpbl} (hostname, status, expire) VALUES ('%s', %d, %d)", $ip, $status, time() + $offset);
  if ($status == HTTPBL_LIST_BLACK && variable_get('httpbl_cache', HTTPBL_CACHE_DBDRUPAL)) {
    db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $ip, 'host', 0);
  }
}