Obtain visitor browser and operating system
- $useragent=$useragent=$_SERVER['HTTP_USER_AGENT'];
- /*Get the client browser version*/
- function browser($ua) {
- if (stripos($ ua, "Googlebot")) {
- $browser = "Google Spider";
- }
- elseif(stripos($ua, "Baiduspider") !== false) {
- $browser = "Baiduspider";
- }
- elseif (stripos($ua, "Yahoo!") !== false) {
- $browser = "Yahoo Spider";
- }
- elseif(stripos($ua, "bingbot")) {
- $browser = "Bingbot" ";
- }
- elseif(stripos($ua, "YRSpider")) {
- $browser = "YRSpider";
- }
- elseif(stripos($ua, "Yeti") !== false) {
- $ browser = "Naver Spider";
- }
- elseif(stripos($ua, "Maxthon")) {
- if (stripos($ua, "AppleWebKit")) {
- $browser = "Maxthon Browser (Extreme Speed Mode)" ;
- }
- elseif(stripos($ua, "Trident")) {
- $browser = "訨游 browser (compatibility mode)";
- }
- elseif(stripos($ua, "MAXTHON 2.0")) {
- $ browser = "欧游 browser 2.0";
- }
- }
- elseif(stripos($ua, "Firefox")) {
- $browser = "Firefox Browser";
- }
- elseif(stripos($ua, "Opera" ) == 0 && stripos($ua, "Presto")) {
- $browser = "Opera";
- }
- elseif(stripos($ua, "BIDUBrowser")) {
- if (stripos($ua, "Trident ")) {
- $browser = "Baidu Browser (Compatibility Mode)";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "Baidu Browser (Extreme Speed Mode)";
- }
- }
- elseif(stripos($ua, "Ruibin")) {
- $browser = "Ruibin";
- }
- elseif(stripos($ua, "qihu theworld")) {
- if (stripos($ ua, "Trident")) {
- $browser = "World Window Browser";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "World Window Browser (Extreme Speed Mode) ";
- }
- }
- elseif(stripos($ua, "MetaSr")) {
- if (stripos($ua, "Trident")) {
- $browser = "Sogou High-speed Browser (Compatibility Mode)";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "Sogou High-speed Browser (Extreme Speed Mode)";
- }
- }
- elseif(stripos($ua, "LBBROWSER")) {
- if (stripos($ua, "Trident")) {
- $browser = "Cheetah Browser (compatibility mode)";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "Cheetah Browser (Extreme speed mode)";
- }
- }
- elseif(stripos($ua, "YLMFBR")) {
- $browser = "115 browser";
- }
- elseif(stripos($ua, "QQBrowser")) {
- if (stripos($ua, "Trident")) {
- $browser = "QQ Browser (compatibility mode)";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "QQ Browser (speed mode)";
- }
- }
- elseif(stripos($ua, "TencentTraveler")) {
- $browser = "Tencent TT Browser";
- }
- elseif(stripos($ua, "TaoBrowser" )) {
- if (stripos($ua, "Trident")) {
- $browser = "Taobao Browser (compatibility mode)";
- }
- elseif(stripos($ua, "AppleWebkit")) {
- $browser = "Taobao Browser (Extreme Speed Mode)";
- }
- }
- elseif(stripos($ua, "CoolNovo")) {
- $browser = "Maple Browser";
- }
- elseif(stripos($ua, "SaaYaa")) {
- $browser = "Strip Browser";
- }
- elseif(stripos($ua, "360SE")) {
- $browser = "360 Safe Browser";
- }
- elseif(stripos ($ua, "360EE")) {
- if (stripos($ua, "Trident")) {
- $browser = "360 Extreme Browser (compatibility mode)";
- }
- elseif(stripos($ua, " AppleWebkit")) {
- $browser = "360 Extreme Browser (Extreme Speed Mode)";
- }
- }
- elseif(stripos($ua, "Konqueror")) {
- $browser = "Konqueror";
- }
- elseif (stripos($ua, "Chrome")) {
- $browser = "Google Chrome";
- }
- elseif(stripos($ua, "Safari")) {
- $browser = "Safari";
- }
- elseif (stripos($ua, "MSIE")) {
- $ver = explode(";", substr($ua, stripos($ua, "MSIE") + 5, 4));
- $ver = $ver[ 0];
- $browser = "IE ".$ver;
- }
- elseif(stripos($ua, "UCWEB")) {
- $browser = "UCWEB Browser";
- }
- elseif(stripos($ua, "WAP")) {
- $browser = "Mobile browser";
- } else {
- $browser = $ua;
- }
- if ($browser == '') $browser = $ua;
- return $browser;
- }
- /*Get operating system version*/
- function os($ua) {
- $os = "";
- if ( stripos($ua, "Googlebot")) {
- $os = "Google Spider";
- }
- elseif(stripos($ua, "Baiduspider") !== false) {
- $os = "Baiduspider";
- }
- elseif(stripos($ua, "Yahoo!") !== false) {
- $os = "Yahoo Spider";
- }
- elseif(stripos($ua, "bingbot")) {
- $os = " Bing Spider";
- }
- elseif(stripos($ua, "YRSpider")) {
- $os = "YRSpider";
- }
- elseif(stripos($ua, "Yeti") !== false) {
- $os = "Naver Spider";
- }
- elseif(stripos($ua, "Windows NT")) {
- switch (substr($ua, stripos($ua, "Windows NT") + 11, 3) ) {
- case 5.0:
- $os = "Windows 2000";
- break;
- case 5.1:
- $os = "Windows XP";
- break;
- case 5.2:
- $os = "Windows 2003";
- break;
- case 6.0:
- $os = "Windows Vista/2008";
- break;
- case 6.1:
- $os = "Windows 7";
- break;
- case 6.2:
- $os = "Windows 8 ";
- break;
- default:
- $os = "Windows";
- break;
- }
- if (stripos($ua, "WOW64")) {
- $os.= "(X64)";
- } else {
- $os.= "(X86)";
- }
- }
- elseif(stripos($ua, "Android")) {
- $os = substr($ua, stripos($ua, "Android"), 11);
- }
- elseif(stripos($ua, "Linux")) {
- if (stripos($ua, "i686")) {
- $os = "Linux X86";
- } else {
- $os = "Linux";
- }
- if (stripos($ua, "X11")) {
- $os.= "(X Window)";
- }
- }
- elseif(stripos($ua, "Macintosh")) {
- $os = "Mac";
- }
- elseif(stripos($ua, "IOS")) {
- $os = "iOS";
- }
- elseif(stripos($ua, "ZTE")) {
- $ os = "ZTE";
- }
- elseif(stripos($ua, "Windows 98")) {
- $os = "Windows 98";
- } else {
- $os = "Unknown System";
- }
- return $ os;
- }
- echo "Current browser:".browser($useragent);
- echo "Current operating system:".os($useragent);
- ?>
Copy code
|