private function analyseBrowserId($id) {
			$browser = Data\BrowserIds::identify('android', $id);
			if ($browser) {
				if (!isset($this->browser->name)) {
					$this->browser->name = $browser;
				}
				else {
					if (substr($this->browser->name, 0, strlen($browser)) != $browser) {
						$this->browser->name = $browser;
						$this->browser->version = null;
						$this->browser->stock = false;
					}
					else {
						$this->browser->name = $browser;
					}
				}
			}

			/* The X-Requested-With header is send by the WebView, so our browser name is Chrome it is probably the Chromium WebView which is sometimes misidentified. */
			if (isset($this->browser->name) && $this->browser->name == 'Chrome') {
				$this->browser->stock = true;
				$this->browser->name = null;
				$this->browser->version = null;
				$this->browser->channel = null;
			}

			/* The X-Requested-With header is only send from Android devices */
			if (!isset($this->os->name) || ($this->os->name != 'Android' && (!isset($this->os->family) || $this->os->family->getName() != 'Android'))) {
				$this->os->name = 'Android';
				$this->os->alias = null;
				$this->os->version = null;

				$this->device->manufacturer = null;
				$this->device->model = null;
				$this->device->identified = Constants\Id::NONE;

				if ($this->device->type != Constants\DeviceType::MOBILE && $this->device->type != Constants\DeviceType::TABLET) {
					$this->device->type = Constants\DeviceType::MOBILE;
				}
			}

			/* The X-Requested-With header is send by the WebKit or Chromium Webview */
			if (!isset($this->engine->name) || ($this->engine->name != 'Webkit' && $this->engine->name != 'Blink')) {
				$this->engine->name = 'Webkit';
				$this->engine->version = null;
			}
		}
Ejemplo n.º 2
0
 public function __construct($header, &$data)
 {
     if ($header == 'XMLHttpRequest') {
         return;
     }
     $this->data =& $data;
     /* The X-Requested-With header is send by the WebView, so our browser name is Chrome it is probably the Chromium WebView which is sometimes misidentified. */
     if (isset($this->data->browser->name) && $this->data->browser->name == 'Chrome') {
         $version = $this->data->browser->getVersion();
         $this->data->browser->reset();
         $this->data->browser->using = new Using(['name' => 'Chromium WebView', 'version' => new Version(['value' => explode('.', $version)[0]])]);
     }
     /* Detect the correct browser based on the header */
     $browser = Data\BrowserIds::identify($header);
     if ($browser) {
         if (!isset($this->data->browser->name)) {
             $this->data->browser->name = $browser;
         } else {
             if (substr($this->data->browser->name, 0, strlen($browser)) != $browser) {
                 $this->data->browser->name = $browser;
                 $this->data->browser->version = null;
                 $this->data->browser->stock = false;
             } else {
                 $this->data->browser->name = $browser;
             }
         }
     }
     /* The X-Requested-With header is only send from Android devices */
     if (!isset($this->data->os->name) || $this->data->os->name != 'Android' && (!isset($this->data->os->family) || $this->data->os->family->getName() != 'Android')) {
         $this->data->os->name = 'Android';
         $this->data->os->alias = null;
         $this->data->os->version = null;
         $this->data->device->manufacturer = null;
         $this->data->device->model = null;
         $this->data->device->identified = Constants\Id::NONE;
         if ($this->data->device->type != Constants\DeviceType::MOBILE && $this->data->device->type != Constants\DeviceType::TABLET) {
             $this->data->device->type = Constants\DeviceType::MOBILE;
         }
     }
     /* The X-Requested-With header is send by the WebKit or Chromium Webview */
     if (!isset($this->data->engine->name) || $this->data->engine->name != 'Webkit' && $this->data->engine->name != 'Blink') {
         $this->data->engine->name = 'Webkit';
         $this->data->engine->version = null;
     }
 }