static function ThemekeyBrowserDetection::getOs in ThemeKey 7.3
Same name and namespace in other branches
- 7 modules/themekey_browser_detection.php \ThemekeyBrowserDetection::getOs()
- 7.2 modules/themekey_browser_detection.php \ThemekeyBrowserDetection::getOs()
Get operating system
@static @access public
Parameters
string user agent:
Return value
string os name and version or 'unknown' in unrecognized os
1 call to ThemekeyBrowserDetection::getOs()
- themekey_dummy2user_os in modules/
themekey.system.inc - ThemeKey mapping function to set a ThemeKey property's value (destination) with the aid of another ThemeKey property (source).
File
- modules/
themekey_browser_detection.php, line 161 - Derived from Browser Detection Class by Dragan Dinic <dragan@dinke.net> and modified to fit the needs of ThemeKey Properties.
Class
- ThemekeyBrowserDetection
- Browser Detection class contains common static method for getting browser version and OS
Code
static function getOs($useragent) {
$useragent = drupal_strtolower($useragent);
//check for (aaargh) most popular first
//winxp
if (strpos($useragent, 'windows nt 5.1') !== FALSE) {
return 'Windows XP';
}
elseif (strpos($useragent, 'windows nt 6.1') !== FALSE) {
return 'Windows 7';
}
elseif (strpos($useragent, 'windows nt 6.0') !== FALSE) {
return 'Windows Vista';
}
elseif (strpos($useragent, 'windows 98') !== FALSE) {
return 'Windows 98';
}
elseif (strpos($useragent, 'windows nt 5.0') !== FALSE) {
return 'Windows 2000';
}
elseif (strpos($useragent, 'windows nt 5.2') !== FALSE) {
return 'Windows 2003 server';
}
elseif (strpos($useragent, 'windows nt') !== FALSE) {
return 'Windows NT';
}
elseif (strpos($useragent, 'win 9x 4.90') !== FALSE && strpos($useragent, 'win me')) {
return 'Windows ME';
}
elseif (strpos($useragent, 'win ce') !== FALSE) {
return 'Windows CE';
}
elseif (strpos($useragent, 'win 9x 4.90') !== FALSE) {
return 'Windows ME';
}
elseif (strpos($useragent, 'windows phone') !== FALSE) {
return 'Windows Phone';
}
elseif (strpos($useragent, 'iphone') !== FALSE) {
return 'iPhone';
}
elseif (strpos($useragent, 'ipad') !== FALSE) {
return 'iPad';
}
elseif (strpos($useragent, 'webos') !== FALSE) {
return 'webOS';
}
elseif (strpos($useragent, 'symbian') !== FALSE) {
return 'Symbian';
}
elseif (strpos($useragent, 'android') !== FALSE) {
return 'Android';
}
elseif (strpos($useragent, 'blackberry') !== FALSE) {
return 'Blackberry';
}
elseif (strpos($useragent, 'mac os x') !== FALSE) {
return 'Mac OS X';
}
elseif (strpos($useragent, 'macintosh') !== FALSE) {
return 'Macintosh';
}
elseif (strpos($useragent, 'linux') !== FALSE) {
return 'Linux';
}
elseif (strpos($useragent, 'freebsd') !== FALSE) {
return 'Free BSD';
}
elseif (strpos($useragent, 'symbian') !== FALSE) {
return 'Symbian';
}
else {
return 'unknown';
}
}