免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1003 | 回复: 0
打印 上一主题 下一主题

获得客户浏览器与操作系统信息 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-03 14:41 |只看该作者 |倒序浏览

?php
    /**
     * @company xingquan
     * @auther        BianJiang
     * @date     Thu Apr 03 14:01:36 CST 2008
     * @copyright     Shen Yang Xing Quan
     * @todo 获得客户浏览器,操作系统,IP地址信息
     * @version     0.1
    */
    function getClientInfo() {
        $agent = $_SERVER['HTTP_USER_AGENT'];
        // Get client explorer info
        if(strpos($agent, 'MSIE 7.0')!==FALSE) $explorer = 'IE 7';
        elseif(strpos($agent, 'MSIE 6.0')!==FALSE) $explorer = 'IE6';
        elseif(strpos($agent, 'Firefox') !==FALSE) $explorer = 'Firefox';
        elseif(strpos($agent, 'Opera') !==FALSE) $explorer = 'Opera';
        elseif(strpos($agent, 'Netscape')!==FALSE) $explorer = 'Netscape';
        elseif(strpos($agent, 'MAXTHON') !==FALSE) $explorer = 'Maxthon';
        elseif(strpos($agent, 'Safari') !==FALSE) $explorer = 'Safari';
        elseif(strpos($agent, "Firebird")!==FALSE) $explorer = "Firebird";
        else $explorer = 'Unknow';
        // Get client system info
        if(strpos($agent, 'Windows NT 5.0') !== FALSE) $os = 'Windows 2000';
        elseif(strpos($agent, 'Windows NT 5.1') !== FALSE) $os= 'Windows XP';
        elseif(strpos($agent, 'Windows NT 5.2') !== FALSE) $os= 'Windows 2003';
        elseif(strpos($agent, 'Windows NT 6.0') !== FALSE) $os= 'Windows Vista';
        elseif(strpos($agent, 'Windows NT') !== FALSE) $os= 'Windows NT';
        elseif(strpos($agent, 'Windows 98') !== FALSE) $os= 'Windows 98';
        elseif(strpos($agent, 'unix') !== FALSE) $os= 'Unix';
        elseif(strpos($agent, 'linux')!== FALSE) $os= 'Linux';
        elseif(strpos($agent, 'SunOS')!== FALSE) $os= 'SunOS';
        elseif(strpos($agent, 'BSD')!== FALSE) $os= 'FreeBSD';
        elseif(strpos($agent, 'Mac')!== FALSE) $os= 'Mac';
        else $os = 'Unknow';
        // Get client ip addr
        if(isset($_SERVER['HTTP_CLIENT_IP'])) $ip = $_SERVER['HTTP_CLIENT_IP'];
        elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        elseif(isset($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
        else $ip = 'Unknow';
        return array(
            'explorer' => $explorer,
            'system' => $os,
            'ip' => $ip
        );
    }
   
    print_r(getClientInfo());
?>


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/10599/showart_516274.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP