ip_anon.inc in IP Anonymize 7
Same filename and directory in other branches
Page callbacks and utility functions for IP Anonymize module.
File
ip_anon.incView source
<?php
/**
* @file
* Page callbacks and utility functions for IP Anonymize module.
*/
/**
* Anonymize IP addresses which have exceeded the retention period.
*/
function ip_anon_scrub() {
foreach (ip_anon_tables() as $table => $columns) {
db_update($table)
->fields(array(
$columns['hostname'] => 0,
))
->condition($columns['timestamp'], REQUEST_TIME - variable_get("ip_anon_period_{$table}", 21600), '<')
->execute();
}
}
/**
* Configuration options for IP Anonymize.
*/
function ip_anon_settings() {
$form = array();
$form['ip_anon_policy'] = array(
'#type' => 'radios',
'#title' => t('Retention policy'),
'#options' => array(
t('Preserve IP addresses'),
t('Anonymize IP addresses'),
),
'#description' => t('This setting may be used to temporarily disable IP anonymization.'),
'#default_value' => variable_get('ip_anon_policy', 0),
);
$form['ip_anon_period'] = array(
'#type' => 'fieldset',
'#title' => t('Retention period'),
'#description' => t('IP addresses older than the retention period will be anonymized.'),
);
$options = drupal_map_assoc(array(
0,
30,
60,
120,
180,
300,
600,
900,
1800,
2700,
3600,
5400,
7200,
10800,
21600,
32400,
43200,
64800,
86400,
172800,
259200,
345600,
432000,
518400,
604800,
1209600,
1814400,
2419200,
2592000,
4838400,
5184000,
7776000,
9676800,
15552000,
23328000,
31536000,
2147483647,
), 'format_interval');
foreach (ip_anon_tables() as $table => $columns) {
$schema = drupal_get_schema($table);
$schema = drupal_get_schema_unprocessed($schema['module'], $table);
$form['ip_anon_period']['ip_anon_period_' . $table] = array(
'#type' => 'select',
'#title' => t('@table table', array(
'@table' => $table,
)),
'#options' => $options,
'#default_value' => variable_get('ip_anon_period_' . $table, 21600),
'#description' => isset($schema['description']) ? check_plain($schema['description']) : '',
);
}
return system_settings_form($form);
}
/**
* Default array of hostname and timestamp columns.
*/
function ip_anon_columns() {
return drupal_map_assoc(array(
'hostname',
'timestamp',
));
}
/**
* Array of tables and columns which store hostnames and timestamps.
*
* Modules may add tables by implementing hook_ip_anon_alter().
*/
function ip_anon_tables() {
$tables = array(
'sessions' => ip_anon_columns(),
);
drupal_alter('ip_anon', $tables);
return $tables;
}
/**
* Implements hook_ip_anon_alter() for comment module.
*/
function comment_ip_anon_alter(&$tables) {
$tables['comment'] = array(
'hostname' => 'hostname',
'timestamp' => 'changed',
);
}
/**
* Implements hook_ip_anon_alter() for Commerce order module.
*/
function commerce_order_ip_anon_alter(&$tables) {
$tables['commerce_order'] = array(
'hostname' => 'hostname',
'timestamp' => 'changed',
);
}
/**
* Implements hook_ip_anon_alter() for dblog module.
*/
function dblog_ip_anon_alter(&$tables) {
$tables['watchdog'] = ip_anon_columns();
}
/**
* Implements hook_ip_anon_alter() for Login Activity module.
*/
function login_activity_ip_anon_alter(&$tables) {
$tables['login_activity'] = ip_anon_columns();
}
/**
* Implements hook_ip_anon_alter() for Login History module.
*/
function login_history_ip_anon_alter(&$tables) {
$tables['login_history'] = array(
'hostname' => 'hostname',
'timestamp' => 'login',
);
}
/**
* Implements hook_ip_anon_alter() for statistics module.
*/
function statistics_ip_anon_alter(&$tables) {
$tables['accesslog'] = ip_anon_columns();
}
/**
* Implements hook_ip_anon_alter() for Ubercart order module.
*/
function uc_order_ip_anon_alter(&$tables) {
$tables['uc_orders'] = array(
'hostname' => 'host',
'timestamp' => 'modified',
);
}
/**
* Implements hook_ip_anon_alter() for User IP Log module.
*/
function uiplog_ip_anon_alter(&$tables) {
$tables['uiplog'] = array(
'hostname' => 'ip',
'timestamp' => 'timestamp',
);
}
/**
* Implements hook_ip_anon_alter() for user_stats module.
*/
function user_stats_ip_anon_alter(&$tables) {
$tables['user_stats_ips'] = array(
'hostname' => 'ip_address',
'timestamp' => 'first_seen_timestamp',
);
}
/**
* Implements hook_ip_anon_alter() for Voting API module.
*/
function votingapi_ip_anon_alter(&$tables) {
$tables['votingapi_vote'] = array(
'hostname' => 'vote_source',
'timestamp' => 'timestamp',
);
}
/**
* Implements hook_ip_anon_alter() for webform module.
*/
function webform_ip_anon_alter(&$tables) {
$tables['webform_submissions'] = array(
'hostname' => 'remote_addr',
'timestamp' => 'submitted',
);
}
Functions
Name | Description |
---|---|
comment_ip_anon_alter | Implements hook_ip_anon_alter() for comment module. |
commerce_order_ip_anon_alter | Implements hook_ip_anon_alter() for Commerce order module. |
dblog_ip_anon_alter | Implements hook_ip_anon_alter() for dblog module. |
ip_anon_columns | Default array of hostname and timestamp columns. |
ip_anon_scrub | Anonymize IP addresses which have exceeded the retention period. |
ip_anon_settings | Configuration options for IP Anonymize. |
ip_anon_tables | Array of tables and columns which store hostnames and timestamps. |
login_activity_ip_anon_alter | Implements hook_ip_anon_alter() for Login Activity module. |
login_history_ip_anon_alter | Implements hook_ip_anon_alter() for Login History module. |
statistics_ip_anon_alter | Implements hook_ip_anon_alter() for statistics module. |
uc_order_ip_anon_alter | Implements hook_ip_anon_alter() for Ubercart order module. |
uiplog_ip_anon_alter | Implements hook_ip_anon_alter() for User IP Log module. |
user_stats_ip_anon_alter | Implements hook_ip_anon_alter() for user_stats module. |
votingapi_ip_anon_alter | Implements hook_ip_anon_alter() for Voting API module. |
webform_ip_anon_alter | Implements hook_ip_anon_alter() for webform module. |