- /*
- 手机客户端检测,摘自 Discuz! x2.5,有删改
- */
- function checkmobile($set=false) {
- if ($set===true) {
- $_SESSION['mobile']='';
- }
- if($_SESSION['mobile'] === 'no') {
- return false;
- }
- $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))) {
- return true;
- }
- $brower = array('mozilla', 'chrome', 'safari', 'opera', 'm3gate', 'winwap', 'openwave', 'myop');
- if(dstrpos($useragent, $brower)) return false;
- }
- /*
- checkmobile 附属函数
- */
- function dstrpos($string, &$arr, $returnvalue = false) {
- if(empty($string)) return false;
- foreach((array)$arr as $v) {
- if(strpos($string, $v) !== false) {
- $return = $returnvalue ? $v : true;
- return $return;
- }
- }
- return false;
- }
复制代码 摘自sxbxjhwm |