Constants\DeviceType::TELEVISION; $this->data->device->identified |= Constants\Id::MATCH_UA; $this->data->device->generic = false; } /* Chrome OS */ if (preg_match('/CrOS/u', $ua)) { $this->data->os->name = 'Chrome OS'; $this->data->device->type = Constants\DeviceType::DESKTOP; } } /* Open TV */ private function detectOpenTV($ua) { if (preg_match('/OpenTV/ui', $ua, $match)) { $this->data->device->type = Constants\DeviceType::TELEVISION; $this->data->os->name = 'OpenTV'; $this->data->os->version = null; if (preg_match('/OpenTV Build\/([0-9\.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } if (preg_match('/OpenTV ([0-9\.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } if (preg_match('/Opentv([0-9]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } if (preg_match('/OTV([0-9\.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } } } /* Qtopia */ private function detectQtopia($ua) { if (preg_match('/Qtopia/u', $ua)) { $this->data->os->name = 'Qtopia'; if (preg_match('/Qtopia\/([0-9.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } } } /* Unix */ private function detectUnix($ua) { if (!preg_match('/(UNIX|OSF|ULTRIX|HP-UX|SunOS|Solaris|AIX|IRIX|NEWS-OS|GENIX)/ui', $ua)) { return; } /* Unix */ if (preg_match('/Unix/iu', $ua)) { $this->data->os->name = 'Unix'; } /* Unix System V */ if (preg_match('/(?:UNIX_System_V|UNIX_SV) ([0-9.]*)/u', $ua, $match)) { $this->data->os->name = 'UNIX System V'; $this->data->os->family = new Family([ 'name' => 'UNIX' ]); $this->data->os->version = new Version([ 'value' => $match[1] ]); $this->data->device->type = Constants\DeviceType::DESKTOP; } /* Digital Unix */ if (preg_match('/OSF1?[ _]/u', $ua)) { $this->data->os->name = 'Digital Unix'; $this->data->os->family = new Family([ 'name' => 'UNIX' ]); if (preg_match('/OSF1?[ _]V?([0-9.]*)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } /* Digital ULTRIX */ if (preg_match('/ULTRIX/u', $ua)) { $this->data->os->name = 'ULTRIX'; $this->data->os->family = new Family([ 'name' => 'BSD' ]); if (preg_match('/ULTRIX ([0-9.]*)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } /* HP-UX */ if (preg_match('/HP-UX/u', $ua)) { $this->data->os->name = 'HP-UX'; $this->data->os->family = new Family([ 'name' => 'UNIX' ]); if (preg_match('/HP-UX [A-Z].0?([1-9][0-9.]*)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } /* Solaris */ if (preg_match('/SunOS/u', $ua)) { $this->data->os->name = 'Solaris'; $this->data->os->family = new Family([ 'name' => 'UNIX' ]); if (preg_match('/SunOS ([1234]\.[0-9\.]+)/u', $ua, $match)) { $this->data->os->name = 'SunOS'; $this->data->os->version = new Version([ 'value' => $match[1] ]); $this->data->os->family = new Family([ 'name' => 'BSD' ]); if (preg_match('/SunOS 4\.1\.([1234])/u', $ua, $match)) { $this->data->os->name = 'Solaris'; switch ($match[1]) { case '1': $this->data->os->version = new Version([ 'value' => '1.0' ]); break; case '2': $this->data->os->version = new Version([ 'value' => '1.0.1' ]); break; case '3': $this->data->os->version = new Version([ 'value' => '1.1' ]); break; case '4': $this->data->os->version = new Version([ 'value' => '1.1.2' ]); break; } } } if (preg_match('/SunOS 5\.([123456](?:\.[0-9\.]*)?) /u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => '2.' . $match[1] ]); } elseif (preg_match('/SunOS 5\.([0-9\.]*)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Solaris(?: ([0-9\.]+))?;/u', $ua, $match)) { $this->data->os->name = 'Solaris'; $this->data->os->family = new Family([ 'name' => 'UNIX' ]); if (preg_match('/Solaris ([0-9\.]+);/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } /* AIX */ if (preg_match('/AIX/u', $ua)) { $this->data->os->name = 'AIX'; $this->data->os->family = new Family([ 'name' => 'UNIX' ]); if (preg_match('/AIX ([0-9.]*)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } /* IRIX */ if (preg_match('/IRIX/u', $ua)) { $this->data->os->name = 'IRIX'; $this->data->os->family = new Family([ 'name' => 'UNIX' ]); if (preg_match('/IRIX ([0-9.]*)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } if (preg_match('/IRIX;?(?:64|32) ([0-9.]*)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } /* Sony NEWS OS */ if (preg_match('/NEWS-OS ([0-9\.]+)/u', $ua, $match)) { $this->data->os->name = 'NEWS OS'; $this->data->os->version = new Version([ 'value' => $match[1] ]); $this->data->os->family = new Family([ 'name' => 'BSD' ]); if (preg_match('/NEWS-OS [56]/u', $ua)) { $this->data->os->family = new Family([ 'name' => 'UNIX' ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } /* NEC EWS-UX */ if (preg_match('/EWS-UNIX rev ([0-9\.]+)/u', $ua, $match)) { $this->data->os->name = 'EWS-UX'; $this->data->os->version = new Version([ 'value' => $match[1] ]); $this->data->os->family = new Family([ 'name' => 'UNIX' ]); $this->data->device->type = Constants\DeviceType::DESKTOP; } /* National Semiconductors GENIX */ if (preg_match('/GENIX ([0-9\.]+)/u', $ua, $match)) { $this->data->os->name = 'GENIX'; $this->data->os->version = new Version([ 'value' => $match[1] ]); $this->data->os->family = new Family([ 'name' => 'BSD' ]); $this->data->device->type = Constants\DeviceType::DESKTOP; } } /* BSD */ private function detectBsd($ua) { if (!preg_match('/(BSD|DragonFly)/ui', $ua)) { return; } if (preg_match('/X11/u', $ua)) { $this->data->device->type = Constants\DeviceType::DESKTOP; } /* BSD/OS */ if (preg_match('/BSD\/386/u', $ua)) { $this->data->os->name = 'BSD/OS'; $this->data->os->family = new Family([ 'name' => 'BSD' ]); } if (preg_match('/BSD\/OS/u', $ua)) { $this->data->os->name = 'BSD/OS'; $this->data->os->family = new Family([ 'name' => 'BSD' ]); if (preg_match('/BSD\/OS ([0-9.]*)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } } /* FreeBSD */ if (preg_match('/FreeBSD/iu', $ua)) { $this->data->os->name = 'FreeBSD'; $this->data->os->family = new Family([ 'name' => 'BSD' ]); if (preg_match('/FreeBSD[ -\/]?([0-9.]*)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } } /* OpenBSD */ if (preg_match('/OpenBSD/iu', $ua)) { $this->data->os->name = 'OpenBSD'; $this->data->os->family = new Family([ 'name' => 'BSD' ]); if (preg_match('/OpenBSD ?([0-9.]*)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } } /* NetBSD */ if (preg_match('/NetBSD/iu', $ua)) { $this->data->os->name = 'NetBSD'; $this->data->os->family = new Family([ 'name' => 'BSD' ]); if (preg_match('/NetBSD ?([0-9.]*)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } } /* DragonFly */ if (preg_match('/DragonFly/iu', $ua)) { $this->data->os->name = 'DragonFly BSD'; $this->data->os->family = new Family([ 'name' => 'BSD' ]); } } /* Linux */ private function detectLinux($ua) { if (preg_match('/Linux/u', $ua)) { $this->data->os->name = 'Linux'; if (preg_match('/X11/u', $ua)) { $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Antergos Linux/u', $ua)) { $this->data->os->name = 'Antergos Linux'; $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Arch ?Linux/u', $ua)) { $this->data->os->name = 'Arch Linux'; $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Black Lab Linux/u', $ua)) { $this->data->os->name = 'Black Lab Linux'; if (preg_match('/Black Lab Linux ([0-9\.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/CentOS/u', $ua)) { $this->data->os->name = 'CentOS'; if (preg_match('/CentOS\/[0-9\.\-]+el([0-9_]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => str_replace('_', '.', $match[1]) ]); } if (preg_match('/CentOS Linux release ([0-9\.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1], 'details' => 2 ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Debian/u', $ua)) { $this->data->os->name = 'Debian'; if (preg_match('/Debian\/([0-9.]*)/iu', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } if (preg_match('/Debian GNU\/Linux ([0-9\.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Fedora/u', $ua)) { $this->data->os->name = 'Fedora'; if (preg_match('/Fedora\/[0-9\.\-]+fc([0-9]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => str_replace('_', '.', $match[1]) ]); } if (preg_match('/Fedora release ([0-9\.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Gentoo/u', $ua)) { $this->data->os->name = 'Gentoo'; if (preg_match('/Gentoo Base System release ([0-9\.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/gNewSense/u', $ua)) { $this->data->os->name = 'gNewSense'; if (preg_match('/gNewSense\/[^\(]+\(([0-9\.]+)/u', $ua, $match)) { $this->data->os->version = new Version([ 'value' => $match[1] ]); } $this->data->device->type = Constants\DeviceType::DESKTOP; } if (preg_match('/Kubuntu/u', $ua)) { $this->data->os->name = 'Kubuntu'; if (preg_match('/Kubuntu[ \/]([0-9.]*)/iu', $ua, $match)) { $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; } } } } }