function visitors_exit in Visitors 7.2
Same name and namespace in other branches
- 8 visitors.exit.inc \visitors_exit()
- 7 visitors.exit.inc \visitors_exit()
- 7.0 visitors.exit.inc \visitors_exit()
Implements hook_exit().
File
- ./
visitors.exit.inc, line 224 - Implements hook_exit().
Code
function visitors_exit() {
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
drupal_load('module', 'user');
global $user;
$not_admin = !in_array('administrator', $user->roles);
$log_admin = !variable_get('visitors_exclude_administer_users', 0);
if ($log_admin || $not_admin) {
$ip_str = visitors_get_ip_str();
$user_agent = visitors_get_user_agent();
$fields = array(
'visitors_uid' => $user->uid,
'visitors_ip' => $ip_str,
'visitors_date_time' => time(),
'visitors_url' => visitors_get_url(),
'visitors_referer' => visitors_get_referer(),
'visitors_path' => visitors_get_path(),
'visitors_title' => visitors_get_title(),
'visitors_user_agent' => $user_agent,
);
if (module_exists('visitors_geoip')) {
if (!isset($_SESSION['visitors_geoip'][$ip_str])) {
$_SESSION['visitors_geoip'][$ip_str] = visitors_get_geoip_data($ip_str);
}
$geoip_data = $_SESSION['visitors_geoip'][$ip_str];
$fields = array_merge($fields, $geoip_data);
}
visitors_browscap_save_user_agent($user_agent);
db_insert('visitors')
->fields($fields)
->execute();
}
}