public function applyRecoveryMatch() { // At this point, a recovery match is really no match at all. $this->match_type = 'none'; $this->match = false; if (TeraWurflConfig::$SIMPLE_DESKTOP_ENGINE_ENABLE === false && SimpleDesktopUserAgentMatcher::isDesktopBrowserHeavyDutyAnalysis($this->wurfl->httpRequest)) { return WurflConstants::GENERIC_WEB_BROWSER; } if ($this->userAgent->contains('CoreMedia')) { return 'apple_iphone_coremedia_ver1'; } if ($this->userAgent->contains('Windows CE')) { return 'generic_ms_mobile'; } if ($this->userAgent->contains('UP.Browser/7.2')) { return 'opwv_v72_generic'; } if ($this->userAgent->contains('UP.Browser/7')) { return 'opwv_v7_generic'; } if ($this->userAgent->contains('UP.Browser/6.2')) { return 'opwv_v62_generic'; } if ($this->userAgent->contains('UP.Browser/6')) { return 'opwv_v6_generic'; } if ($this->userAgent->contains('UP.Browser/5')) { return 'upgui_generic'; } if ($this->userAgent->contains('UP.Browser/4')) { return 'uptext_generic'; } if ($this->userAgent->contains('UP.Browser/3')) { return 'uptext_generic'; } //Series 60 if ($this->userAgent->contains('Series60')) { return 'nokia_generic_series60'; } // Access/Net Front if ($this->userAgent->contains(array('NetFront/3.0', 'ACS-NF/3.0'))) { return 'generic_netfront_ver3'; } if ($this->userAgent->contains(array('NetFront/3.1', 'ACS-NF/3.1'))) { return 'generic_netfront_ver3_1'; } if ($this->userAgent->contains(array('NetFront/3.2', 'ACS-NF/3.2'))) { return 'generic_netfront_ver3_2'; } if ($this->userAgent->contains(array('NetFront/3.3', 'ACS-NF/3.3'))) { return 'generic_netfront_ver3_3'; } if ($this->userAgent->contains('NetFront/3.4')) { return 'generic_netfront_ver3_4'; } if ($this->userAgent->contains('NetFront/3.5')) { return 'generic_netfront_ver3_5'; } if ($this->userAgent->contains('NetFront/4.0')) { return 'generic_netfront_ver4_0'; } // Contains Mozilla/, but not at the beginning of the UA // ie: MOTORAZR V8/R601_G_80.41.17R Mozilla/4.0 (compatible; MSIE 6.0 Linux; MOTORAZR V88.50) Profile/MIDP-2.0 Configuration/CLDC-1.1 Opera 8.50[zh] if ($this->userAgent->indexOf('Mozilla/') > 0) { return WurflConstants::GENERIC_XHTML; } if ($this->userAgent->contains(array('Obigo', 'AU-MIC/2', 'AU-MIC-', 'AU-OBIGO/', 'Teleca Q03B1'))) { return WurflConstants::GENERIC_XHTML; } // DoCoMo if ($this->userAgent->startsWith(array('DoCoMo', 'KDDI'))) { return 'docomo_generic_jap_ver1'; } return WurflConstants::NO_MATCH; }
/** * Detects the capabilities from a given request object ($_SERVER) * @param array $request_headers Request object ($_SERVER contains this data) * @return boolean Match */ public function getDeviceCapabilitiesFromRequest($request_headers = null) { $this->httpRequest = $request_headers instanceof TeraWurflHttpRequest ? $request_headers : new TeraWurflHttpRequest($request_headers); $this->db->numQueries = 0; $this->matchData = array("num_queries" => 0, "match_type" => '', "matcher" => '', "match" => false, "lookup_time" => 0); $this->lookup_start = microtime(true); $this->foundInCache = false; $this->capabilities = array(); // Use the ultra high performance SimpleDesktopMatcher if enabled if (TeraWurflConfig::$SIMPLE_DESKTOP_ENGINE_ENABLE) { require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/SimpleDesktopUserAgentMatcher.php'); if (SimpleDesktopUserAgentMatcher::isDesktopBrowserHeavyDutyAnalysis($this->httpRequest)) { $this->httpRequest->user_agent->set(WurflConstants::SIMPLE_DESKTOP_UA); } } // Check cache for device if (TeraWurflConfig::$CACHE_ENABLE) { $cacheData = $this->db->getDeviceFromCache($this->httpRequest->user_agent->cleaned); // Found in cache if ($cacheData !== false) { $this->capabilities = $cacheData; $this->foundInCache = true; $deviceID = $cacheData['id']; } } if (!$this->foundInCache) { require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/SimpleDesktopUserAgentMatcher.php'); // Find appropriate user agent matcher $this->userAgentMatcher = UserAgentMatcherFactory::createUserAgentMatcher($this, $this->httpRequest); // Find the best matching WURFL ID $deviceID = $this->getDeviceIDFromRequestLoose(); // Get the capabilities of this device and all its ancestors $this->getFullCapabilities($deviceID); // Now add in the Tera-WURFL results array $this->lookup_end = microtime(true); $this->matchData['num_queries'] = $this->db->numQueries; $this->matchData['lookup_time'] = $this->lookup_end - $this->lookup_start; // Add the match data to the capabilities array so it gets cached $this->addCapabilities(array($this->matchDataKey => $this->matchData)); } if (TeraWurflConfig::$CACHE_ENABLE == true && !$this->foundInCache) { // Since this device was not cached, cache it now. $this->db->saveDeviceInCache($this->httpRequest->user_agent->cleaned, $this->capabilities); } return $this->capabilities[$this->matchDataKey]['match']; }