$this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Linux Mint/u', $ua)) { $this->data->os->name = 'Linux Mint'; if (preg_match('/Linux Mint ([0-9\.]+)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Mandriva Linux/u', $ua)) { $this->data->os->name = 'Mandriva'; if (preg_match('/Mandriva Linux\/[0-9\.\-]+mdv([0-9]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Mageia/u', $ua)) { $this->data->os->name = 'Mageia'; if (preg_match('/Mageia\/[0-9\.\-]+mga([0-9]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } if (preg_match('/Mageia ([0-9\.]+)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Mandriva/u', $ua)) { $this->data->os->name = 'Mandriva'; if (preg_match('/Mandriva\/[0-9\.\-]+mdv([0-9]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/moonOS/u', $ua)) { $this->data->os->name = 'moonOS'; if (preg_match('/moonOS\/([0-9.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Red Hat/u', $ua)) { $this->data->os->name = 'Red Hat'; if (preg_match('/Red Hat[^\/]*\/[0-9\.\-]+el([0-9_]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => str_replace('_', '.', $match[1]) ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Slackware/u', $ua)) { $this->data->os->name = 'Slackware'; if (preg_match('/Slackware[ \/](1[0-9.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/SUSE/u', $ua)) { $this->data->os->name = 'SUSE'; if (preg_match('/SUSE\/([0-9]\.[0-9]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } if (preg_match('/openSUSE ([0-9\.]+)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Turbolinux/u', $ua)) { $this->data->os->name = 'Turbolinux'; if (preg_match('/Turbolinux\/([0-9]\.[0-9]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Ubuntu/u', $ua)) { $this->data->os->name = 'Ubuntu'; if (preg_match('/Ubuntu\/([0-9.]*)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } if (preg_match('/Ubuntu ([0-9\.]+)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1], 'details' => 2 ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/《붉은별》\/([0-9.]*)/iu', $ua, $match)) { $this->data->os->name = 'Red Star'; $this->data->os->version = new Version([ 'value' => $match[1] ]); $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Fedora\/[0-9\.\-]+rs([0-9\.]+)/u', $ua, $match)) { $this->data->os->name = 'Red Star'; $this->data->os->version = new Version([ 'value' => str_replace('_', '.', $match[1]) ]); $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Linux\/X2\/R1/u', $ua)) { $this->data->os->name = 'LiMo'; $this->data->device->type = Constants\DeviceType::MOBILE; } if (preg_match('/Linux\/SLP\/([0-9.]+)/u', $ua, $match)) { $this->data->os->name = 'Linux SLP'; $this->data->os->version = new Version([ 'value' => $match[1] ]); $this->data->device->type = Constants\DeviceType::MOBILE; } if (preg_match('/LinuxOS\//u', $ua) && preg_match('/Software\/R5/u', $ua)) { $this->data->os->name = 'EZX Linux'; $this->data->device->type = Constants\DeviceType::MOBILE; } } if (preg_match('/elementary OS/u', $ua)) { $this->data->os->name = 'elementary OS'; if (preg_match('/elementary OS ([A-Za-z]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'alias' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/\(Ubuntu; (Mobile|Tablet)/u', $ua)) { $this->data->os->name = 'Ubuntu Touch'; if (preg_match('/\(Ubuntu; Mobile/u', $ua)) { $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; } } } } }