/**
  * Creates Generic Request from the given HTTP Request (normally $_SERVER)
  * @param array $request HTTP Request
  * @param bool $override_sideloaded_browser_ua
  * @return WURFL_Request_GenericRequest
  */
 public function createRequest($request, $override_sideloaded_browser_ua = true)
 {
     $userAgent = WURFL_WURFLUtils::getUserAgent($request, $override_sideloaded_browser_ua);
     $userAgentProfile = WURFL_WURFLUtils::getUserAgentProfile($request);
     $isXhtmlDevice = WURFL_WURFLUtils::isXhtmlRequester($request);
     return new WURFL_Request_GenericRequest($request, $userAgent, $userAgentProfile, $isXhtmlDevice);
 }
 /**
  * Creates Generic Request from the given HTTP Request (normally $_SERVER)
  * @param array $request HTTP Request
  * @return WURFL_Request_GenericRequest
  */
 public function createRequest($request)
 {
     $userAgent = WURFL_WURFLUtils::getUserAgent($request);
     $userAgentProfile = WURFL_WURFLUtils::getUserAgentProfile($request);
     $isXhtmlDevice = WURFL_WURFLUtils::isXhtmlRequester($request);
     return new WURFL_Request_GenericRequest($userAgent, $userAgentProfile, $isXhtmlDevice);
 }
	/**
	 * Verifies the correctness of the wurfl devices
	 *
	 * @param array $devicesMap
	 */
	public static function verify(array $devicesMap) {
				
		$devicesMapByUserAgent = array ();
		$hierarchyVerifiedDeviceIds = array ();
		
		// Verifiy the existance of the Generic Device
		self::verifyGenericDeviceExistance ( $devicesMap );
		
		$genericDevice = $devicesMap [WURFL_Constants::GENERIC];
		
		foreach ($devicesMap as $deviceId => $device) {		
			if(!WURFL_WURFLUtils::isGeneric($deviceId)) {						
				self::verifyUserAgentUniqueness ( $devicesMapByUserAgent, $device->userAgent );
				$devicesMapByUserAgent [$device->userAgent] = $device;
				
				//self::verifyHierarchy($devicesMap, $hierarchyVerifiedDeviceIds, $device);
				//$hierarchyVerifiedDeviceIds[] = $device->id;
				

				self::verifyGroups ( $genericDevice, $device );
				
				self::verifyCapabilities ( $genericDevice, $device );
			
			}
		
		}
	
	}
Пример #4
0
 /**
  * Patch an existing $device with a $patchingDevice
  * @param WURFL_Xml_ModelDevice $device
  * @param WURFL_Xml_ModelDevice $patchingDevice
  * @return WURFL_Xml_ModelDevice Patched device
  */
 public function patch($device, $patchingDevice)
 {
     if (!$this->haveSameId($device, $patchingDevice)) {
         return $patchingDevice;
     }
     $groupIdCapabilitiesMap = WURFL_WURFLUtils::array_merge_recursive_unique($device->getGroupIdCapabilitiesMap(), $patchingDevice->getGroupIdCapabilitiesMap());
     return new WURFL_Xml_ModelDevice($device->id, $device->userAgent, $device->fallBack, $device->actualDeviceRoot, $device->specific, $groupIdCapabilitiesMap);
 }
Пример #5
0
 /**
  * Creates GenericRequest Object from
  * a $_SERVER object
  *
  * @param $_SERVER $request
  * @return GenericRequest
  */
 public function createRequest($request)
 {
     $userAgent = WURFL_WURFLUtils::getUserAgent($request);
     $this->checkUserAgent($userAgent);
     $userAgent = $this->_userAgentNormalizer->normalize($userAgent);
     $userAgentProfile = WURFL_WURFLUtils::getUserAgentProfile($request);
     $isXhtmlDevice = WURFL_WURFLUtils::isXhtmlRequester($request);
     return new WURFL_Request_GenericRequest($userAgent, $userAgentProfile, $isXhtmlDevice);
 }
	/**
	 * Pathces a single device with a device from the patch file
	 *
	 * @param WURFL_Xml_ModelDevice $device
	 * @param WURFL_Xml_ModelDevice $patchingDevice
	 * @return WURFL_Xml_ModelDevice
	 */
	private function patchSingleDevice($device, $patchingDevice) {
		if (strcmp($patchingDevice->userAgent, $device->userAgent) !== 0) {
			$message = "Patch Device : " .$patchingDevice->id . " can't ovveride user agent " . $device->userAgent . " with " . $patchingDevice->userAgent;
			throw new WURFL_WURFLException($message);
		}
		
		$groupIdCapabilitiesMap = WURFL_WURFLUtils::array_merge_recursive_unique($device->getGroupIdCapabilitiesMap(), $patchingDevice->getGroupIdCapabilitiesMap());
		
		return new WURFL_Xml_ModelDevice($device->id, $device->userAgent, $device->fallBack, $device->actualDeviceRoot, $groupIdCapabilitiesMap);

	}
	private function init() {
		
		$this->_logger = WURFL_Logger_LoggerFactory::create();
		
		$this->_logger->info ( "START: WURFL LOADING PROCESS: " );
		if (! $this->isWURFLLoaded ()) {
			set_time_limit ( WURFL_Xml_XMLResourceManager::WURFL_TIMEOUT );

			$memRequired = WURFL_WURFLUtils::return_bytes ( WURFL_Xml_XMLResourceManager::WURFL_MEMORY_LIMIT );
			$memAvailable = ini_get ( 'memory_limit' );
			if ( !$memAvailable || $memAvailable < $memRequired ) {
				ini_set ( 'memory_limit', WURFL_Xml_XMLResourceManager::WURFL_MEMORY_LIMIT );
			}
			
			$wurflFile = $this->_config->wurflFile;
			$wurflFile = WURFL_Xml_Utils::getXMLFile ( $wurflFile );
			
			$devicesMap = $this->_wurflParser->parse ( $wurflFile );
			
			WURFL_Xml_WURFLConsistencyVerifier::verify ( $devicesMap);
						
			$devicesMap = $this->applyPatches ( $devicesMap );
			
			$this->_logger->info ( "START: PERSISTING DEVICES" );
			$this->updateAndSaveDataStuctures ( $devicesMap );
			$this->setWURFLLoaded ();
			$this->_logger->info ( "END: PERSISTING DEVICES" );
		}
		$this->_logger->info ( "END: WURFL LOADING PROCESS" );
	}