You are here

function httpbl_cron in http:BL 6.2

Same name and namespace in other branches
  1. 8 httpbl.module \httpbl_cron()
  2. 5 httpbl.module \httpbl_cron()
  3. 6 httpbl.module \httpbl_cron()
  4. 7 httpbl.module \httpbl_cron()

Implementation of hook_cron().

Cleans old results from the cache table and also Drupal access table if appropriate.

File

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

Code

function httpbl_cron() {

  // Only continue when caching is enabled
  if (variable_get('httpbl_cache', HTTPBL_CACHE_OFF)) {
    if (variable_get('httpbl_cache', HTTPBL_CACHE_OFF) == HTTPBL_CACHE_DBDRUPAL) {

      // Also check status so that we do not accidentally delete the site's custom access rules.
      db_query("DELETE FROM {access} WHERE mask IN (SELECT hostname FROM {httpbl} WHERE status > 0 AND expire <= %d)", time());
    }
    db_query("DELETE FROM {httpbl} WHERE expire <= %d", time());
  }
}