more module updates
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
* Replacement for PHP's get_browser() function.
|
||||
*/
|
||||
|
||||
// Include browscap data import and user agent recording functions
|
||||
include_once('import.inc');
|
||||
// Include browscap data import and user agent recording functions.
|
||||
include_once 'import.inc';
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
@@ -24,7 +24,7 @@ function browscap_permission() {
|
||||
function browscap_menu() {
|
||||
$items['admin/config/system/browscap'] = array(
|
||||
'title' => 'Browscap',
|
||||
'description' => 'Configure user agent monitoring and browscap information settings.',
|
||||
'description' => 'View the current browscap data version and configure automatic update settings.',
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('browscap_settings_form'),
|
||||
'access arguments' => array('administer browscap'),
|
||||
@@ -40,7 +40,7 @@ function browscap_menu() {
|
||||
function browscap_help($path, $arg) {
|
||||
switch ($path) {
|
||||
case 'admin/config/system/browscap':
|
||||
return '<p>' . t('Settings for user agent detection and the log that Browscap will keep about user agents that visit the site. See <a href="@statistics">user agent statistics</a> for the actual information.', array('@statistics' => url('admin/reports/browscap'))) . '</p>';
|
||||
return '<p>' . t('View the current browscap data version and configure automatic update settings.') . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,19 +49,19 @@ function browscap_help($path, $arg) {
|
||||
*/
|
||||
function browscap_cron() {
|
||||
if (variable_get('browscap_enable_automatic_updates', TRUE) == TRUE) {
|
||||
// Check the current update timer
|
||||
// Check the current update timer.
|
||||
$automatic_update_timer = variable_get('browscap_automatic_updates_timer', 604800);
|
||||
|
||||
// Check when the last update occurred
|
||||
// Check when the last update occurred.
|
||||
$last_imported = variable_get('browscap_imported', REQUEST_TIME);
|
||||
|
||||
// Update the browscap data if the amount of time specified by the update
|
||||
// timer has passed
|
||||
// timer has passed.
|
||||
if (($last_imported + $automatic_update_timer) < REQUEST_TIME) {
|
||||
// Update the browscap information
|
||||
// Update the browscap information.
|
||||
_browscap_import();
|
||||
|
||||
// Record when the browscap information was updated
|
||||
// Record when the browscap information was updated.
|
||||
variable_set('browscap_imported', REQUEST_TIME);
|
||||
}
|
||||
}
|
||||
@@ -71,12 +71,14 @@ function browscap_cron() {
|
||||
* Provide data about a user agent string or the current user agent.
|
||||
*
|
||||
* @param string $user_agent
|
||||
* Optional user agent string to test. If empty, use the value from the current request.
|
||||
* Optional user agent string to test. If empty, use the value from the
|
||||
* current request.
|
||||
*
|
||||
* @return array
|
||||
* An array of information about the user agent.
|
||||
*/
|
||||
function browscap_get_browser($user_agent = NULL) {
|
||||
// Determine the current user agent if a user agent was not specified
|
||||
// Determine the current user agent if a user agent was not specified.
|
||||
if ($user_agent != NULL) {
|
||||
$user_agent = check_plain(trim($user_agent));
|
||||
}
|
||||
@@ -87,40 +89,40 @@ function browscap_get_browser($user_agent = NULL) {
|
||||
$user_agent = 'Default Browser';
|
||||
}
|
||||
|
||||
// Check the cache for user agent data
|
||||
// Check the cache for user agent data.
|
||||
$cache = cache_get($user_agent, 'cache_browscap');
|
||||
|
||||
// Attempt to find a cached user agent
|
||||
// Otherwise store the user agent data in the cache
|
||||
// Attempt to find a cached user agent.
|
||||
// Otherwise store the user agent data in the cache.
|
||||
if (!empty($cache) && ($cache->created > REQUEST_TIME - 60 * 60 * 24)) {
|
||||
$user_agent_properties = $cache->data;
|
||||
}
|
||||
else {
|
||||
// Find the user agent's properties
|
||||
// Find the user agent's properties.
|
||||
// The useragent column contains the wildcarded pattern to match against our
|
||||
// full-length string while the ORDER BY chooses the most-specific matching
|
||||
// pattern
|
||||
// pattern.
|
||||
$user_agent_properties = db_query("SELECT * FROM {browscap} WHERE :useragent LIKE useragent ORDER BY LENGTH(useragent) DESC", array(':useragent' => $user_agent))
|
||||
->fetchObject();
|
||||
|
||||
// Store user agent data in the cache
|
||||
// Store user agent data in the cache.
|
||||
cache_set($user_agent, $user_agent_properties, 'cache_browscap');
|
||||
}
|
||||
|
||||
// Create an array to hold the user agent's properties
|
||||
// Create an array to hold the user agent's properties.
|
||||
$properties = array();
|
||||
|
||||
// Return an array of user agent properties
|
||||
// Return an array of user agent properties.
|
||||
if (isset($user_agent_properties) && isset($user_agent_properties->data)) {
|
||||
// Unserialize the user agent data found in the cache or the database
|
||||
// Unserialize the user agent data found in the cache or the database.
|
||||
$properties = unserialize($user_agent_properties->data);
|
||||
|
||||
// Set the user agent name and name pattern
|
||||
// Set the user agent name and name pattern.
|
||||
$properties['useragent'] = $user_agent;
|
||||
$properties['browser_name_pattern'] = strtr($user_agent_properties->useragent, '%_', '*?');
|
||||
}
|
||||
else {
|
||||
// Set the user agent name and name pattern to 'unrecognized'
|
||||
// Set the user agent name and name pattern to 'unrecognized'.
|
||||
$properties['useragent'] = 'unrecognized';
|
||||
$properties['browser_name_pattern'] = strtr('unrecognized', '%_', '*?');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user