You are here

function ip_anon_cron in IP Anonymize 5

Same name and namespace in other branches
  1. 8 ip_anon.module \ip_anon_cron()
  2. 6 ip_anon.module \ip_anon_cron()
  3. 7 ip_anon.module \ip_anon_cron()

Implementation of hook_cron().

Anonymize IP addresses which have exceeded the retention period.

File

./ip_anon.module, line 31
Establishes an IP address retention policy.

Code

function ip_anon_cron() {
  if (variable_get('ip_anon_policy', 0)) {
    foreach (ip_anon_tables() as $table => $columns) {
      if (db_table_exists($table)) {
        db_query("UPDATE {{$table}} SET {$columns['hostname']} = '%s' WHERE {$columns['timestamp']} < %d", 0, time() - variable_get('ip_anon_period_' . $table, 10800));
      }
    }
  }
}