取得訪客瀏覽器和作業系統
- $useragent=$useragent=$_SERVER['HTTP_USER_AGENT'];
-
- /*取得客戶端瀏覽器版本/
- function browser($ua) {
- if (stripos($ua, "Googlebot")) {
- $browser = "Google蜘蛛";
- }
- elseif(stripos($ ua, "Baiduspider") !== false) {
- $browser = "百度蜘蛛";
- }
- elseif(stripos($ua, "Yahoo!") !== false) {
- $browser = "雅虎蜘蛛";
- }
- elseif(stripos($ua, "bingbot")) {
- $browser = "必應蜘蛛";
- }
- elseif( stripos($ua, "YRSpider")) {
- $browser = "雲壤蜘蛛";
- }
- elseif(stripos($ua, "Yeti") !== false) {
- $browser = "Naver蜘蛛";
- }
- elseif(stripos($ua, "Maxthon")) {
- if (stripos($ua, "AppleWebKit")) {
- $browser = "遨遊瀏覽器(極速模式)";
- }
- elseif(stripos($ua, "Trident")) {
- $browser = "遨遊瀏覽器(相容模式)";
- }
- elseif(stripos($ua, "MAXTHON 2.0")) {
- $browser = "遨遊瀏覽器2.0";
- }
- }
- elseif(stripos($ua, "Firefpos($ua ")) {
- $browser = "火狐瀏覽器";
- }
- elseif(stripos($ua, "Opera") == 0 && stripos($ua, "Presto")) {
- $browser = "Opera";
- }
- elseif(stripos($ua, "BIDUBrowser")) {
- if (stripos($ua, "Trident")) {
- $browser = "百度瀏覽器(相容模式)";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "百度瀏覽器(極速模式)";
- }
- }
- elseif(stripos($ua, "Ruibin")) {
- $browser = "瑞影瀏覽器";
- }
- elseif(stripos($ua, "qihu theworld")) {
- if (stripos($ua, "Trident")) {
- $browser = "世界之窗瀏覽器";
- }
- elseif(stripos($ua, " AppleWebKit")) {
- $browser = "世界之窗瀏覽器(極速模式)";
- }
- }
- elseif(stripos($ua, "MetaSr")) {
- if (stripos($ua, "Trident")) {
- $browser = "搜狗高速瀏覽器(相容模式)";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "搜狗高速瀏覽器(極速模式)";
- }
- }
- elseif(stripos($ua, "LBBROWSER")) {
- if (stripos($ua , "Trident")) {
- $browser = "獵豹瀏覽器(相容模式)";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "獵豹瀏覽器(極速模式)";
- }
- }
- elseif(stripos($ua, "YLMFBR")) {
- $browser = "115瀏覽器";
- }
- elseif(stripos($ua, "QQBrowser")) {
- if (stripos($ua, "Trident")) {
- $browser = "QQ瀏覽器(相容模式)";
- }
- elseif(stripos($ua, "AppleWebKit")) {
- $browser = "QQ瀏覽器(極速模式)";
- }
- }
- elseif(stripos($ua , "TencentTraveler")) {
- $browser = "騰訊TT瀏覽器";
- }
- elseif(stripos($ua, "TaoBrowser")) {
- if (stripos($ua, "Trident")) {
- $browser = "淘寶瀏覽器(相容模式)";
- }
- elseif(stripos($ua, "AppleWebkit")) {
- $browser = "淘寶瀏覽器(極速模式)";
- }
- }
- elseif(stripos($ua, "CoolNovo")) {
- $browser = "楓樹瀏覽器";
- }
- elseif(stripos($ua, "SaaYaa")) {
- $browser = "閃遊瀏覽器";
- }
- elseif(stripos($ua, "360SE")) {
- elseif(stripos($ua, "360SE")) {
- $browser = "360安全瀏覽器";
- }
- elseif(stripos($ua, "360EE")) {
- if (stripos($ua, "Trident")) {
- $browser = "360極速瀏覽器(相容模式)";
- }
- elseif(stripos($ua, "AppleWebkit")) {
- $browser = "360極速瀏覽器(極速模式)" ;
- }
- }
- elseif(stripos($ua, "Konqueror")) {
- $browser = "Konqueror";
- }
- elseif(stripos($ua, "stripos($ua, " Chrome")) {
- $browser = "Google瀏覽器";
- }
- 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瀏覽器";
- }
- elseif(stripos($ua, "WAP")) {
- $browser = "Mobile瀏覽器";
- } else {
- $browser = $ua; }
- if ($browser == '') $browser = $ua;
- return $browser;
- }
- /*取得作業系統版本*/
- function os($ua) {
- $os = "";
- if (stripos($ua, "Googlebot")) {
- $os = "Google蜘蛛";
- }
- elseif(stripos($ua, "Baiduspider") !== false) {
- $os = "百度蜘蛛";
- }
- elseif(stripos($ua, "Yahoo!") !== false) {
- $ os = "Yahoo蜘蛛";
- }
- elseif(stripos($ua, "bingbot")) {
- $os = "必應蜘蛛";
- }
- elseif(stripos( $ua, "YRSpider")) {
- $os = "雲壤蜘蛛";
- }
- elseif(stripos($ua, "Yeti") !== false) {
- $os = "Naver蜘蛛";
- }
- 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 = "未知系統";
- }
- return $os;
- }
-
-
- echo "目前瀏覽器:". browser($useragent);
- echo "目前作業系統:".os($useragent);
-
-
- ?>
複製程式碼
|
複製程式碼