Discuz! X3.* 触屏版切换电脑版时,加入提示页面
分类 网站技术/村民张先生 发布于 2015-09-22 19:40
适用情况:若已启用触屏版伪静态(自行修改模板实现),当用户切换到电脑版,再后退到触屏版时,由于网址中已不再带有 mobile=2 参数,点击任意链接仍然会进入电脑版,必须通过电脑版上的“手机版”链接切回。为了避免用户进入电脑版后不懂如何回到触屏版,我们可以在用户选择切换电脑版时,加入一个确认页面。
1、将以下代码保存为 redirect.php 并上传到根目录。
<?php define('CURSCRIPT', 'redirect'); require './source/class/class_core.php';//引入系统核心文件 $discuz = & discuz_core::instance();//以下代码为创建及初始化对象 $discuz->init(); $n = $_GET['n']; $n = trim($n); $n = strip_tags($n,""); //清除HTML如<br />等代码 $n = ereg_replace("\t","",$n); //去掉制表符号 $n = ereg_replace("\r\n","",$n); //去掉回车换行符号 $n = ereg_replace("\r","",$n); //去掉回车 $n = ereg_replace("\n","",$n); //去掉换行 $n = ereg_replace(" ","",$n); //去掉空格 $n = ereg_replace("'","",$n); //去掉单引号 $to = $_GET['to']; $to = trim($to); $to = strip_tags($to,""); //清除HTML如<br />等代码 $to = ereg_replace("\t","",$to); //去掉制表符号 $to = ereg_replace("\r\n","",$to); //去掉回车换行符号 $to = ereg_replace("\r","",$to); //去掉回车 $to = ereg_replace("\n","",$to); //去掉换行 $to = ereg_replace(" ","",$to); //去掉空格 $to = ereg_replace("'","",$to); //去掉单引号 if($_GET['tid']) { header("HTTP/1.1 301 Moved Permanently"); header("location: thread-".$_GET['tid']."-1-1.html"); exit; } elseif($_GET['ptid']) { if(preg_match("/(Bot|Crawl|Spider|slurp|sohu-search|lycos|robozilla)/i", $_SERVER['HTTP_USER_AGENT'])) { $url = 'thread-'.$_GET['ptid'].'-1-1.html'; } else { $url = 'forum.php?mod=redirect&goto=findpost&ptid='.$_GET['ptid'].'&pid='.$_GET['pid']; } header("HTTP/1.1 301 Moved Permanently"); header("location: $url"); exit; } elseif($n == 'switcher' && $to) { $navtitle = '版本切换'; include template('common/redirect');//调用单页模版文件 exit; } else { header('HTTP/1.1 404 Not Found'); header('status: 404 Not Found'); echo '参数错误。<a href="/">返回首页</a>'; exit; } ?>
欢迎谈谈你的看法(无须登录) *正文中请勿包含"http://"否则将被拦截