+ function getOS() {
+ if (!isset($this->uadata['os'])) {
+ $this->uadata['os'] = null;
+ if ($this->hasEngine('gecko')) {
+ if (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); rv:([^\);]+)\)|', $this->uastring, $regs)) {
+ $this->uadata['os'] = $regs[2];
+ $this->uadata['lang'] = $regs[3];
+ $this->uadata['eng_version'] = $regs[4];
+ }
+ elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^;]+); m([^\);]+)\)|', $this->uastring, $regs)) {
+ $this->uadata['os'] = $regs[2];
+ $this->uadata['lang'] = $regs[3];
+ $this->uadata['eng_version'] = 'M'.$regs[4];
+ }
+ elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) {
+ $this->uadata['os'] = $regs[2];
+ $this->uadata['lang'] = $regs[3];
+ $this->uadata['eng_version'] = null;
+ }
+ elseif (preg_match('|Mozilla/5.0 \(([^;]+); [^;]+; ([^\);]+)\)|', $this->uastring, $regs)) {
+ $this->uadata['os'] = $regs[2];
+ $this->uadata['lang'] = null;
+ $this->uadata['eng_version'] = null;
+ }
+ elseif (preg_match('|Mozilla/5.0 Galeon/[^\(]+ \(([^;]+); ([^;]+);[^\)]+\)|', $this->uastring, $regs)) {
+ $this->uadata['os'] = $regs[2];
+ $this->uadata['lang'] = null;
+ $this->uadata['eng_version'] = null;
+ }
+ elseif (preg_match('|Debian/|', $this->uastring, $regs)) {
+ $this->uadata['os'] = 'Debian Linux';
+ $this->uadata['lang'] = null;
+ $this->uadata['eng_version'] = null;
+ }
+ }
+ elseif ($this->hasEngine('trident') || $this->hasEngine('tasman')) {
+ if (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE ([^;]+)[^\)]*; ?((?:Mac|Win)[^;]+)[^\)]*\)/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = $regs[1];
+ $this->uadata['os'] = $regs[2];
+ $this->uadata['lang'] = null;
+ }
+ elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; MSIE ([^;]+)[^\)]*\)/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = $regs[1];
+ $this->uadata['os'] = null;
+ $this->uadata['lang'] = null;
+ }
+ }
+ elseif ($this->hasEngine('khtml')) {
+ if (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^;]+); ([^;]+); ([^;]+); ([^\);]+)\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = strlen($regs[6])?$regs[6]:$regs[1];
+ $this->uadata['os'] = $regs[2];
+ $this->uadata['lang'] = $regs[5];
+ }
+ elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; Konqueror\/([^;]+); ([^\);]+)[^\)]*\)(?: KHTML\/([0-9a-zA-Z\.+]+))?/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = strlen($regs[3])?$regs[3]:$regs[1];
+ $this->uadata['os'] = $regs[2];
+ $this->uadata['lang'] = null;
+ }
+ elseif (preg_match('|Mozilla/5.0 \(([^;]+); U; ([^;]+); ([^\);]+)\)|', $this->uastring, $regs)) {
+ $this->uadata['os'] = $regs[2];
+ $this->uadata['lang'] = $regs[3];
+ $this->uadata['eng_version'] = null;
+ }
+ elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; [^;]+; ([^\);]+)\)/i', $this->uastring, $regs)) {
+ $this->uadata['os'] = $regs[1];
+ $this->uadata['lang'] = null;
+ $this->uadata['eng_version'] = null;
+ }
+ }
+ elseif ($this->hasEngine('presto')) {
+ if (preg_match('/Opera\/[^\(]+ \(([^;]+)[^\)]+\) +\[([a-z_-]+)\]/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = $this->getVersion();
+ $this->uadata['os'] = $regs[1];
+ $this->uadata['lang'] = $regs[2];
+ }
+ elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; .+; ([^;]+)\) Opera [^ ]+ \[([a-z_-]+)\]/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = $this->getVersion();
+ $this->uadata['os'] = $regs[1];
+ $this->uadata['lang'] = $regs[2];
+ }
+ elseif (preg_match('/Mozilla\/[^\(]+ \(([^;]+);.+\) Opera [^ ]+ \[([a-z_-]+)\]/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = $this->getVersion();
+ $this->uadata['os'] = $regs[1];
+ $this->uadata['lang'] = $regs[2];
+ }
+ // Opera 8
+ elseif (preg_match('/Opera\/[^\(]+ \(([^;]+); [^\)]+; ([a-z_-]+)\)/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = $this->getVersion();
+ $this->uadata['os'] = $regs[1];
+ $this->uadata['lang'] = $regs[2];
+ }
+ elseif (preg_match('/Mozilla\/[^\(]+ \(compatible; .+; ([^;]+); ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = $this->getVersion();
+ $this->uadata['os'] = $regs[1];
+ $this->uadata['lang'] = $regs[2];
+ }
+ elseif (preg_match('/Mozilla\/[^\(]+ \(([^;]+);.+; ([a-z_-]+)\) Opera [^ ]+/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = $this->getVersion();
+ $this->uadata['os'] = $regs[1];
+ $this->uadata['lang'] = $regs[2];
+ }
+ }
+ elseif ($this->hasEngine('nscp')) {
+ if (preg_match('/Mozilla\/([0-9a-zA-Z\.+]+) (?:\[([a-z_-]+)\][^\(]+)?\(([^;]+);[^\)]+\)/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = $regs[1];
+ $this->uadata['os'] = $regs[3];
+ $this->uadata['lang'] = $regs[2];
+ }
+ }
+ elseif ($this->hasEngine('gzilla')) {
+ $this->uadata['eng_version'] = $this->getVersion();
+ $this->uadata['os'] = null;
+ $this->uadata['lang'] = null;
+ }
+ elseif ($this->hasEngine('links')) {
+ if (preg_match('/E?Links[^\(]+\([^;]+; ([^;]+)[^\)]+\)/i', $this->uastring, $regs)) {
+ $this->uadata['eng_version'] = null;
+ $this->uadata['os'] = $regs[1];
+ $this->uadata['lang'] = null;
+ }
+ }
+ else {
+ $this->uadata['eng_version'] = null;
+ $this->uadata['lang'] = null;
+ if (preg_match('/AmigaOS/i', $this->uastring, $regs)) {
+ $this->uadata['os'] = 'AmigaOS';
+ }
+ elseif (preg_match('/curl\/[^\(]+\(([^\);]+)/i', $this->uastring, $regs)) {
+ $this->uadata['os'] = $regs[1];
+ }
+ elseif (preg_match('/NCSA[_ ]Mosaic\/[^\(]+\((?:.*;)?([^\);]+)/i', $this->uastring, $regs)) {
+ $this->uadata['os'] = trim($regs[1]);
+ }
+ elseif (preg_match('/iCab.*(Mac[^\);]+).*?\)/i', $this->uastring, $regs)) {
+ $this->uadata['os'] = trim($regs[1]);
+ }
+ elseif (preg_match('/SymbianOS\/([^ ]+)/i', $this->uastring, $regs)) {
+ $this->uadata['os'] = 'SymbianOS '.$regs[1];
+ }