Example #1
0
/**
 * 
 * 根据php的$_SERVER['HTTP_USER_AGENT'] 中各种浏览器访问时所包含各个浏览器特定的字符串来判断是属于PC还是移动端
 * @author           discuz3x
 * @lastmodify    2014-04-09
 * @return  BOOL
 */
function checkmobile()
{
    global $_G;
    //各个触控浏览器中$_SERVER['HTTP_USER_AGENT']所包含的字符串数组
    static $touchbrowser_list = array('iphone', 'android', 'phone', 'mobile', 'wap', 'netfront', 'java', 'opera mobi', 'opera mini', 'ucweb', 'windows ce', 'symbian', 'series', 'webos', 'sony', 'blackberry', 'dopod', 'nokia', 'samsung', 'palmsource', 'xda', 'pieplus', 'meizu', 'midp', 'cldc', 'motorola', 'foma', 'docomo', 'up.browser', 'up.link', 'blazer', 'helio', 'hosin', 'huawei', 'novarra', 'coolpad', 'webos', 'techfaith', 'palmsource', 'alcatel', 'amoi', 'ktouch', 'nexian', 'ericsson', 'philips', 'sagem', 'wellcom', 'bunjalloo', 'maui', 'smartphone', 'iemobile', 'spice', 'bird', 'zte-', 'longcos', 'pantech', 'gionee', 'portalmmm', 'jig browser', 'hiptop', 'benq', 'haier', '^lct', '320x320', '240x320', '176x220');
    //window手机浏览器数组【猜的】
    static $mobilebrowser_list = array('windows phone');
    //wap浏览器中$_SERVER['HTTP_USER_AGENT']所包含的字符串数组
    static $wmlbrowser_list = array('cect', 'compal', 'ctl', 'lg', 'nec', 'tcl', 'alcatel', 'ericsson', 'bird', 'daxian', 'dbtel', 'eastcom', 'pantech', 'dopod', 'philips', 'haier', 'konka', 'kejian', 'lenovo', 'benq', 'mot', 'soutec', 'nokia', 'sagem', 'sgh', 'sed', 'capitel', 'panasonic', 'sonyericsson', 'sharp', 'amoi', 'panda', 'zte');
    $pad_list = array('pad', 'gt-p1000');
    $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
    if (dstrpos($useragent, $pad_list)) {
        return false;
    }
    if ($v = dstrpos($useragent, $mobilebrowser_list, true)) {
        $_G['mobile'] = $v;
        return '1';
    }
    if ($v = dstrpos($useragent, $touchbrowser_list, true)) {
        $_G['mobile'] = $v;
        return '2';
    }
    if ($v = dstrpos($useragent, $wmlbrowser_list)) {
        $_G['mobile'] = $v;
        return '3';
        //wml版
    }
    $brower = array('mozilla', 'chrome', 'safari', 'opera', 'm3gate', 'winwap', 'openwave', 'myop');
    if (dstrpos($useragent, $brower)) {
        return false;
    }
    $_G['mobile'] = 'unknown';
    //对于未知类型的浏览器,通过$_GET['mobile']参数来决定是否是手机浏览器
    if (isset($_G['mobiletpl'][$_GET['mobile']])) {
        return true;
    } else {
        return false;
    }
}
Example #2
0
function checkmobile()
{
    global $_G;
    $mobile = array();
    static $mobilebrowser_list = array('iphone', 'android', 'phone', 'mobile', 'wap', 'netfront', 'java', 'opera mobi', 'opera mini', 'ucweb', 'windows ce', 'symbian', 'series', 'webos', 'sony', 'blackberry', 'dopod', 'nokia', 'samsung', 'palmsource', 'xda', 'pieplus', 'meizu', 'midp', 'cldc', 'motorola', 'foma', 'docomo', 'up.browser', 'up.link', 'blazer', 'helio', 'hosin', 'huawei', 'novarra', 'coolpad', 'webos', 'techfaith', 'palmsource', 'alcatel', 'amoi', 'ktouch', 'nexian', 'ericsson', 'philips', 'sagem', 'wellcom', 'bunjalloo', 'maui', 'smartphone', 'iemobile', 'spice', 'bird', 'zte-', 'longcos', 'pantech', 'gionee', 'portalmmm', 'jig browser', 'hiptop', 'benq', 'haier', '^lct', '320x320', '240x320', '176x220');
    $pad_list = array('pad', 'gt-p1000');
    $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
    if (dstrpos($useragent, $pad_list)) {
        return false;
    }
    if ($v = dstrpos($useragent, $mobilebrowser_list, true)) {
        $_G['mobile'] = $v;
        return true;
    }
    $brower = array('mozilla', 'chrome', 'safari', 'opera', 'm3gate', 'winwap', 'openwave', 'myop');
    if (dstrpos($useragent, $brower)) {
        return false;
    }
    $_G['mobile'] = 'unknown';
    if ($_GET['mobile'] === 'yes') {
        return true;
    } else {
        return false;
    }
}
Example #3
0
function checkpc()
{
    $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
    $ualist = array('macintosh', 'msie', 'windows nt', 'applewebkit');
    $noualist = array('android', 'moblie', 'wap', 'phone');
    if (dstrpos($useragent, $ualist) && !dstrpos($useragent, $noualist)) {
        return true;
    } else {
        return false;
    }
}
Example #4
0
function rewrite_path_info($url)
{
    global $_G;
    $url = trim($url, '/');
    $url = trim($url, '&');
    $first = substr($url, 0, 1);
    $is_add = false;
    $first3 = substr($url, 0, 3);
    if ($first == 'm') {
        $url = str_replace(array('m=', '&a='), '/', $url);
    } else {
        if ($first == 'a' && $first3 != 'aid') {
            $url = '/index' . str_replace('a=', '/', $url);
        } else {
            $url = '/' . str_replace('=', '/', $url);
        }
    }
    $url = preg_replace("/&([a-z_]+)=/is", "/\$1/", $url);
    $search = array('/id', '/fid', '/itemid', '/cid', '/num_iid', '/aid');
    if (dstrpos($url, $search)) {
        $is_add = true;
    }
    $url = str_replace(array('&', '='), '/', $url);
    if (strpos($url, '/id/') !== false) {
        $url = str_replace("/id/", '/', $url);
    }
    $url .= $is_add ? ".html" : '/';
    //$_G['rel'][] = $url;
    return $url;
}