-1) { $version = substr($version, 0, strpos($version, ';')); } // Beautify version format $version = str_replace('_', '.', $version); } elseif (preg_match('/Darwin/i', $ua)) { $title = 'Mac OS Darwin'; } else { $title = 'Macintosh'; } } elseif (preg_match('/[^A-Za-z]Arch/i', $ua)) { $title = 'Arch Linux'; $code = 'Arch-Linux'; } elseif (preg_match('/BlackBerry/i', $ua)) { $title = 'BlackBerryOS'; } elseif (preg_match('/CentOS/i', $ua)) { $title = 'CentOS'; if (preg_match('/.el([.0-9a-zA-Z]+).centos/i', $ua, $regmatch)) { $version = $regmatch[1]; } } elseif (preg_match('/CrOS/i', $ua)) { $title = 'Google Chrome OS'; $code = 'Chrome-OS'; } elseif (preg_match('/Debian/i', $ua)) { $title = 'Debian GNU/Linux'; $code = 'Debian'; } elseif (preg_match('/Fedora/i', $ua)) { $title = 'Fedora'; if (preg_match('/.fc([.0-9a-zA-Z]+)/i', $ua, $regmatch)) { $version = $regmatch[1]; } } elseif (preg_match('/FreeBSD/i', $ua)) { $title = 'FreeBSD'; } elseif (preg_match('/OpenBSD/i', $ua)) { $title = 'OpenBSD'; } elseif (preg_match('/Oracle/i', $ua)) { $title = 'Oracle'; $code = 'Oracle-Linux'; if (preg_match('/.el([._0-9a-zA-Z]+)/i', $ua, $regmatch)) { $title .= ' Enterprise Linux'; $version = str_replace('_', '.', $regmatch[1]); } else { $title .= ' Linux'; } } elseif (preg_match('/Red\ Hat/i', $ua) || preg_match('/RedHat/i', $ua)) { $title = 'Red Hat'; $code = 'Red-Hat'; if (preg_match('/.el([._0-9a-zA-Z]+)/i', $ua, $regmatch)) { $title .= ' Enterprise Linux'; $version = str_replace('_', '.', $regmatch[1]); } } elseif (preg_match('/Solaris/i', $ua) || preg_match('/SunOS/i', $ua)) { $title = 'Solaris'; } elseif (preg_match('/Symb[ian]?[OS]?/i', $ua)) { $title = 'SymbianOS'; if (preg_match('/Symb[ian]?[OS]?\/([.0-9a-zA-Z]+)/i', $ua, $regmatch)) { $version = $regmatch[1]; } } elseif (preg_match('/Ubuntu/i', $ua)) { $title = 'Ubuntu'; if (preg_match('/Ubuntu[\/|\ ]([.0-9]+[.0-9a-zA-Z]+)/i', $ua, $regmatch)) { $version = $regmatch[1]; } } elseif (preg_match('/Linux/i', $ua)) { $title = 'GNU/Linux'; $code = 'Linux'; } elseif (preg_match('/J2ME\/MIDP/i', $ua)) { $title = 'J2ME/MIDP Device'; $code = 'Java'; } // No OS match else { $title = 'Other System'; $code = 'Others'; } // Check x64 architecture if (preg_match('/x86_64/i', $ua)) { // If version isn't null append 64 bit, otherwise set it to x64 $version = (is_null($version)) ? 'x64' : "$version x64"; } elseif ((preg_match('/Windows/i', $ua) || preg_match('/WinNT/i', $ua) || preg_match('/Win32/i', $ua)) && (preg_match('/Win64/i', $ua) || preg_match('/x64/i', $ua) || preg_match('/WOW64/i', $ua)) ) { $version .= ' x64 Edition'; } if (is_null($code)) { $code = $title; } // Append version to title if (isset($version)) { $title .= " $version"; } $result['code'] = $code; $result['title'] = $title; return $result; }