$this->data->device->type = Constants\DeviceType::MOBILE; } if (preg_match('/\(Ubuntu; Tablet/u', $ua)) { $this->data->device->type = Constants\DeviceType::TABLET; } } if (preg_match('/(?:\(|; )Ubuntu ([0-9.]+) like Android/u', $ua, $match)) { $this->data->os->name = 'Ubuntu Touch'; $this->data->os->version = new Version([ 'value' => $match[1] ]); $this->data->device->type = Constants\DeviceType::MOBILE; } if (preg_match('/Lindows ([0-9.]+)/u', $ua, $match)) { $this->data->os->name = 'Lindows'; $this->data->os->version = new Version([ 'value' => $match[1] ]); $this->data->device->type = Constants\DeviceType::DESKTOP; } } /* Brew */ private function detectBrew($ua) { if (preg_match('/REX; U/ui', $ua) || preg_match('/REXL4/ui', $ua)) { $this->data->os->name = 'REX'; $this->data->device->type = Constants\DeviceType::MOBILE; if (preg_match('/REX; U; [^;]+; ([^;]+); ([^;\/]+)[^;]*; NetFront/u', $ua, $match)) { $this->data->device->manufacturer = Data\Manufacturers::identify(Constants\DeviceType::MOBILE, $match[1]); $this->data->device->model = $match[2]; $this->data->device->identified = Constants\Id::PATTERN; $device = Data\DeviceModels::identify('brew', $match[2]); if ($device->identified) { $device->identified |= $this->data->device->identified; $this->data->device = $device; } } } if (preg_match('/[\(\s\-;]BREW[\s\/\-;]/ui', $ua) || preg_match('/BMP( [0-9.]*)?; U/u', $ua) || preg_match('/B(?:rew)?MP\/([0-9.]*)/u', $ua)) { $this->data->os->name = 'Brew'; if (preg_match('/BREW MP/iu', $ua) || preg_match('/B(rew)?MP/iu', $ua)) { $this->data->os->name = 'Brew MP'; } if (preg_match('/; Brew ([0-9.]+);/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } elseif (preg_match('/BREW; U; ([0-9.]+)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } elseif (preg_match('/[\(;]BREW[\/ ]([0-9.]+)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } elseif (preg_match('/BREW MP ([0-9.]*)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } elseif (preg_match('/BMP ([0-9.]*); U/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } elseif (preg_match('/B(?:rew)?MP\/([0-9.]*)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::MOBILE; if (preg_match('/(?:Brew MP|BREW|BMP) [^;]+; U; [^;]+; ([^;]+); NetFront[^\)]+\) [^\s]+ ([^\s]+)/u', $ua, $match)) { $this->data->device->manufacturer = Data\Manufacturers::identify(Constants\DeviceType::MOBILE, $match[1]); $this->data->device->model = $match[2]; $this->data->device->identified = Constants\Id::PATTERN; $device = Data\DeviceModels::identify('brew', $match[2]); if ($device->identified) { $device->identified |= $this->data->device->identified; $this->data->device = $device; } } if (preg_match('/\(([^;]+);U;REX\/[^;]+;BREW\/[^;]+;(?:.*;)?[0-9]+\*[0-9]+(?:;CTC\/2.0)?\)/u', $ua, $match)) { $this->data->device->model = $match[1]; $this->data->device->identified = Constants\Id::PATTERN; $device = Data\DeviceModels::identify('brew', $match[1]); if ($device->identified) { $device->identified |= $this->data->device->identified; $this->data->device = $device; } } if (preg_match('/\(BREW [^;]+; U; [^;]+; [^;]+; ([^;]+); (Polaris|Netfront)\/[0-9\.]+\/(WAP|AMB|INT)\)/ui', $ua, $match)) { $this->data->device->model = $match[1]; $this->data->device->identified = Constants\Id::PATTERN; $device = Data\DeviceModels::identify('brew', $match[1]); if ($device->identified) { $device->identified |= $this->data->device->identified; $this->data->device = $device; } } if (preg_match('/\(BREW [^;]+; U; [^;]+; [^;]+; Opera Mobi; Presto\/[0-9\.]+\/(?:WAP|AMB|INT)\) ([^\/]+) [^\/]+\//ui', $ua, $match)) { $this->data->device->model = $match[1]; $this->data->device->identified = Constants\Id::PATTERN; $device = Data\DeviceModels::identify('brew', $match[1]); if ($device->identified) { $device->identified |= $this->data->device->identified; $this->data->device = $device; } } } } /* Remaining operating systems */ private function detectRemainingOperatingSystems($ua) { if (!preg_match('/(BeOS|Haiku|AmigaOS|MorphOS|AROS|VMS|RISC|Joli|OS\/2|Inferno|Syllable|Grid|MTK|MRE|MAUI|Nucleus|QNX|VRE|SpreadTrum|ThreadX)/ui', $ua)) { return; } $patterns = [ [ 'name' => 'BeOS', 'regexp' => [ '/BeOS/iu' ], 'type' => Constants\DeviceType::DESKTOP ], [ 'name' => 'Haiku', 'regexp' => [ '/Haiku/iu' ], 'type' => Constants\DeviceType::DESKTOP ], [ 'name' => 'AmigaOS', 'regexp' => [ '/AmigaOS ?([0-9.]+)/iu', '/AmigaOS/iu' ], 'type' => Constants\DeviceType::DESKTOP ], [ 'name' => 'MorphOS', 'regexp' => [ '/MorphOS(?: ([0-9.]*))?/iu' ], 'type' => Constants\DeviceType::DESKTOP ], [ 'name' => 'AROS', 'regexp' => [ '/AROS/iu' ], 'type' => Constants\DeviceType::DESKTOP ], [ 'name' => 'OpenVMS', 'regexp' => [ '/OpenVMS V([0-9.]+)/iu', '/OpenVMS/iu' ], 'type' => Constants\DeviceType::DESKTOP ], [ 'name' => 'RISC OS', 'regexp' => [ '/RISC OS(?:-NC)? ([0-9.]*)/iu', '/RISC OS/iu' ], 'type' => Constants\DeviceType::DESKTOP ], [ 'name' => 'Joli OS', 'regexp' => [ '/Joli OS\/([0-9.]*)/iu' ], 'type' => Constants\DeviceType::DESKTOP ], [ 'name' => 'OS/2', 'regexp' => [ '/OS\/2;(?: (?:U; )?Warp ([0-9.]*))?/iu' ], 'type' => Constants\DeviceType::DESKTOP ], [ 'name' => 'Inferno', 'regexp' => [ '/Inferno/iu' ], 'type' => Constants\DeviceType::DESKTOP ], [ 'name' => 'Syllable', 'regexp' => [ '/Syllable/iu' ], 'type' => Constants\DeviceType::DESKTOP ], [ 'name' => 'Grid OS', 'regexp' => [ '/Grid OS ([0-9.]*)/iu' ], 'type' => Constants\DeviceType::TABLET ], [ 'name' => 'MRE', 'regexp' => [ '/\(MTK;/iu', '/\/MTK /iu' ], 'type' => Constants\DeviceType::MOBILE ], [ 'name' => 'MRE', 'regexp' => [ '/MRE\\\\/iu' ], 'type' => Constants\DeviceType::MOBILE ], [ 'name' => 'MRE', 'regexp' => [ '/MAUI[-_ ](?:Browser|Runtime)/iu' ], 'type' => Constants\DeviceType::MOBILE ], [ 'name' => 'MRE', 'regexp' => [ '/Browser\/MAUI/iu' ], 'type' => Constants\DeviceType::MOBILE ], [ 'name' => 'MRE', 'regexp' => [ '/Nucleus RTOS\//iu' ], 'type' => Constants\DeviceType::MOBILE ], [ 'name' => 'MRE', 'regexp' => [ '/\/Nucleus/iu' ], 'type' => Constants\DeviceType::MOBILE ], [ 'name' => 'MRE', 'regexp' => [ '/Nucleus\//iu' ], 'type' => Constants\DeviceType::MOBILE ], [ 'name' => 'QNX', 'regexp' => [ '/QNX/iu' ], 'type' => Constants\DeviceType::MOBILE ], [ 'name' => 'VRE', 'regexp' => [ '/\(VRE;/iu' ], 'type' => Constants\DeviceType::MOBILE ], [ 'name' => 'SpreadTrum', 'regexp' => [ '/\(SpreadTrum;/iu' ], 'type' => Constants\DeviceType::MOBILE ], [ 'name' => 'ThreadX', 'regexp' => [ '/ThreadX(?:_OS)?\/([0-9.]*)/iu' ] ], ]; $count = count($patterns); for ($b = 0; $b < $count; $b++) { for ($r = 0; $r < count($patterns[$b]['regexp']); $r++) { if (preg_match($patterns[$b]['regexp'][$r], $ua, $match)) { $this->data->os->name = $patterns[$b]['name']; if (isset($match[1]) && $match[1]) { $this->data->os->version = new Version([ 'value' => $match[1], 'details' => isset($patterns[$b]['details']) ? $patterns[$b]['details'] : null ]); } else { $this->data->os->version = null; } if (isset($patterns[$b]['type'])) { $this->data->device->type = $patterns[$b]['type']; } break; } } } } }