zoukankan      html  css  js  c++  java
  • 检测客户端系统-PHP

    if(isset($_SERVER['HTTP_USER_AGENT'])) {
    
            $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
    
            $clientkeywords = array(
                'nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-'
            ,'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu',
                'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini',
                'operamobi', 'opera mobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile'
            );
            $upgradekeywords = array('iphone','ipod','chrom','safari');
            $operaminikeywords = array('operamini','opera mini','opera mobi');
            $androidkeywords = array('android');
            echo($userAgent.'<br/>');
    //        echo(preg_match("/(".implode('|',$clientkeywords).")/i",$userAgent));
    //        echo(strpos($userAgent,'ipad'));
    //       // 从HTTP_USER_AGENT中查找手机浏览器的关键字
    //        echo(preg_match("/(".implode('|',$clientkeywords).")/i",$userAgent)&&strpos($userAgent,'ipad'));
    
            if(preg_match("/(".implode('|',$clientkeywords).")/i",$userAgent)&&strpos($userAgent,'ipad')=== false)
            {
                if(preg_match("/(".implode('|',$androidkeywords).")/i",$userAgent)){
                    header("Location: http://xxxxx");
                    exit;
                }else{
                    header("Location: http://xxxxx");
                    exit;
                }
            }else{
                header("Location: xxxxxx");
                exit;
            }
    
        }
  • 相关阅读:
    poj 1654(利用叉积求面积)
    poj 3230(初始化。。动态规划)
    hdu 1392(凸包)
    hdu 1348(凸包)
    hdu 1147(线段相交)
    hdu 1115(多边形重心问题)
    POJ 2373 Yogurt factory
    GCJ 2008 APAC local onsites C Millionaire
    FZU 1397 保送
    FZU 1064 教授的测试
  • 原文地址:https://www.cnblogs.com/yaohonv/p/5494945.html
Copyright © 2011-2022 走看看