切换原理
discuz手机版切换电脑版,底部链接:电脑版,url末尾添加参数 mobile=no,
新页面会执行函数 source\class\discuz\discuz_application.php->
init
()->
$this
->_init_mobile()
if(getgpc('mobile') === 'no') {
dsetcookie('mobile', 'no', 3600);
$nomobile = true;
} elseif($this->var['cookie']['mobile'] == 'no' && getgpc('mobile') === 'yes') {
checkmobile();
dsetcookie('mobile', '');
} elseif($this->var['cookie']['mobile'] == 'no') {
$nomobile = true;
} elseif(!checkmobile()) {
$nomobile = true;
}
设置有效期为1小时的mobile=no的cookie。
如果没有传参数,根据mobile=no的cookie,
$nomobile
=
true
;
在下面直接返回false;
并没有设置常量
IN_MOBILE,
面在
页面在选择模板时,
if(defined('IN_MOBILE') && !defined('TPL_DEFAULT') && strpos($file, 'mobile/') === false || (isset($_G['forcemobilemessage']) && $_G['forcemobilemessage'])) {
$file = 'mobile/'.$oldfile;
}
只有IN_MOBILE被复制后,才会选择moblie手机模板。