function browscap_exit in Browscap 5
Same name and namespace in other branches
- 6 browscap.module \browscap_exit()
- 7 browscap.module \browscap_exit()
Implementation of hook_exit().
Keep tabs on browsers that visit
File
- ./
browscap.module, line 87 - Replacement for PHP's get_browser() function
Code
function browscap_exit() {
// If monitoring is enabled, record the browser
if (variable_get('browscap_monitor', FALSE)) {
$browser = browscap_get_browser();
$browserstring = substr(trim($browser['parent']), 0, 255);
if ($browserstring == '' or $browserstring == 'Default Browser') {
$browserstring = trim($_SERVER['HTTP_USER_AGENT']);
}
db_query("UPDATE {browscap_statistics} SET counter = counter + 1, is_crawler=%d " . "WHERE parent='%s'", $browser['crawler'], $browserstring);
// If we affected 0 rows, this is the first time we've seen this browser
if (!db_affected_rows()) {
// We must create a new row to store counters for the new browser.
db_query('INSERT INTO {browscap_statistics} (parent,counter,is_crawler) ' . "VALUES('%s', 1, %d)", $browserstring, $browser['crawler']);
}
}
}