'desktop', 'group' => '', ); // Get Browscap information about the current user agent #$user_agent = browscap_get_browser(); // added tmp function for quick fix function tmp_browscap_get_browser($user_agent = NULL) { // Determine the current user agent if a user agent was not specified if ($user_agent != NULL) { $user_agent = check_plain(trim($user_agent)); } elseif ($user_agent == NULL && isset($_SERVER['HTTP_USER_AGENT'])) { $user_agent = check_plain(trim($_SERVER['HTTP_USER_AGENT'])); } else { $user_agent = 'Default Browser'; } // 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 if (!empty($cache) && ($cache->created > time() - 60 * 60 * 24)) { $user_agent_properties = $cache->data; } else { // 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 $user_agent_properties = db_fetch_object(db_query_range("SELECT * from {browscap} WHERE '%s' LIKE useragent ORDER BY LENGTH(useragent) DESC", $user_agent, 0, 1)); // 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 $properties = array(); // 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 $properties = unserialize($user_agent_properties->data); // 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' $properties['useragent'] = 'unrecognized'; $properties['browser_name_pattern'] = strtr('unrecognized', '%_', '*?'); } return $properties; } // Get Browscap information about the current user agent // tmp fix function $user_agent = tmp_browscap_get_browser(); // Check the browscap information to see if the current user agent is flagged // as a mobile device if (isset($user_agent['ismobiledevice']) && $user_agent['ismobiledevice'] == TRUE) { $device_information['type'] = 'mobile'; } // Get the currently defined device groups $groups = mt_browscap_device_groups_info(); // Check if the current user agent name can be found within the list of // device groups if (isset($user_agent['browser']) && in_array($user_agent['browser'], $groups)) { $device_information['group'] = array_search($user_agent['browser'], $groups); } return $device_information; } /** * Implementatation of hook_device_groups_info(). */ function mt_browscap_device_groups_info() { return array( 'android' => 'Android', 'blackberry' => 'BlackBerry', 'ipad' => 'iPad', 'iphone' => 'iPhone', 'ipod' => 'iPod', 'opera_mini' => 'Opera Mini', 'windows_phone' => 'Windows Phone', ); }