You are here

function _httpbl_cache_set in http:BL 6.2

Same name and namespace in other branches
  1. 5 httpbl.module \_httpbl_cache_set()
  2. 6 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 734
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) {

  // http://stackoverflow.com/questions/1109061/insert-on-duplicate-update-postgresql/6527838#6527838
  db_query("UPDATE {httpbl} SET hostname= '%s', status= %d, expire= %d WHERE hostname= '%s'", $ip, $status, time() + $offset);
  db_query("INSERT INTO {httpbl} (hostname, status, expire) SELECT '%s', %d, %d FROM (SELECT 1) AS foo WHERE NOT EXISTS (SELECT 1 FROM {httpbl} WHERE hostname = '%s')", $ip, $status, time() + $offset, $ip);
  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);
  }
}