dz手机版空白显示index.php,discuzX3 开启手机版,访问网站会自动判断是来自桌面端还是移动端,是怎么做的?...

没看到和user agent有关的逻辑

你居然没找到!

function checkmobile() {

global $_G;

$mobile = array();

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', 'windows phone');

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');

static $pad_list = array('ipad');

$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);

if(dstrpos($useragent, $pad_list)) {

return false;

}

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';

if(isset($_G['mobiletpl'][$_GET['mobile']])) {

return true;

} else {

return false;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值