discuz如何开启用电脑访问手机/触屏版进行调试

Discuz1352浏览0条评论disucz

DISCUZ屏蔽了电脑访问手机版,不管是触屏版还是标准版都做了判断,这让设计者做手机版的插件和模板调试起来很不方便,下面分享一下修改方法。


需要修改2个文件:

1./source/function/function_core.php

第317行左右找到checkmobile()函数,在下面静态变量$touchbrowser_list里添加'firefox'的标识即可,这个标识是浏览器的标志,你用谷歌就添加chrome,就代表这个标识的浏览器属于手机端了。

function checkmobile() {
	global $_G;
	$mobile = array();
	static $touchbrowser_list =array('firefox在这里添加标识,表示这个是手机浏览器的意思','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;
	}
}


2./static/js/mobile/common.js

把第二行!supporttouch && (window.location.href = 'forum.php?mobile=1');注释掉。

var supporttouch = "ontouchend" in document;
//!supporttouch && (window.location.href = 'forum.php?mobile=1');

到现在就可以电脑浏览器访问手机触屏版了。

本文地址:http://wuheng.net/blog_64.html 转载请注明出处

分享到: