您现在的位置是:首页 > cms教程 > Discuz教程Discuz教程
Discuz伪静态代码示例
亭邬2025-07-17Discuz教程已有人查阅
导读*[伪静态跳转(xugui_redirect.{modulename})] (C)2012-2099 Powered by ebingou.*Version: 1.0
<?php
/**
*[伪静态跳转(xugui_redirect.{modulename})] (C)2012-2099 Powered by ebingou.
*Version: 1.0
*Date: 2025-07-17 15:28
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
class plugin_xugui_redirect {
function plugin_xugui_redirect(){
global $_G;
//$this->tml=new template();
$this->user_no_on = $_G['cache']['plugin']['xugui_redirect']['user_no_on'];
$this->redirect_on = $_G['cache']['plugin']['xugui_redirect']['redirect_on'];
$this->tag_rewrite_on = $_G['cache']['plugin']['xugui_redirect']['tag_rewrite_on'];
$this->portal_cat_on = $_G['cache']['plugin']['xugui_redirect']['portal_cat_on'];
$this->custom_replace = trim($_G['cache']['plugin']['xugui_redirect']['custom_replace']);
if(empty($this->custom_replace)){
$this->custom_replace="comsenz.com->sharejie.com";
}
}
private function getreplace_Url(){
$Url=$_SERVER['REQUEST_URI'];
$pinfo=pathinfo($_SERVER['SCRIPT_NAME']);
$pinfo['dirname']=($pinfo['dirname']=="\\"||$pinfo['dirname']=="/")?"":$pinfo['dirname'];
$Url=ltrim(str_replace($pinfo['dirname'],"",$Url),'/');
$Url=str_replace(array('&extra','&page'),array('&extra','&page'),$Url);
$tempUrl=output_replace('<a href="'.$Url.'">a</a>');
$tempUrl= preg_replace ('/<a[^>]*?href="(.*?)"[^>]*>a<\/a>/i', "$1", $tempUrl);
$tempUrl=str_replace('&', '&', $tempUrl);
if(strpos($tempUrl, "http://")===0){
return $tempUrl;
}
return "http://".$_SERVER['HTTP_HOST'].$pinfo['dirname']."/".$tempUrl;
}
private function checkDomain($url){
global $_G;
if(!empty($_G['setting']['output']['str']['search'])) {
if(empty($_G['setting']['domain']['app']['default'])) {
$_G['setting']['output']['str']['replace'] = str_replace('{CURHOST}', $_G['siteurl'], $_G['setting']['output']['str']['replace']);
}
$pinfo=pathinfo($_SERVER['SCRIPT_NAME']);
if($pinfo['dirname']!="\\"){
return $url;
}
$Script_basename=$pinfo['basename'];
$A_Script_basename = str_replace($_G['setting']['output']['str']['search'], $_G['setting']['output']['str']['replace'], '<a href="'.$Script_basename);
$A_Script_basename=str_replace('<a href="',"",$A_Script_basename);
if($A_Script_basename==$Script_basename){
return $url;
}
$url_info=parse_url($A_Script_basename);
if($url_info['host']!=$_SERVER['HTTP_HOST']){
return str_replace($_SERVER['HTTP_HOST'],$url_info['host'],$url);
}
}
return $url;
}
function common(){
if(defined('IN_MODCP') || defined('IN_ADMINCP')) return "";
global $_G;
if($this->user_no_on){
if($_G['groupid'] !='7'&&$_G['groupid'] !='20'){
//禁用
$_G['setting']['output'] = array("0"=>"0");
return;
}
}
//标签伪静态
if($this->tag_rewrite_on&&!empty($_G['setting']['output']['preg']['search'])){
$_G['setting']['output']['preg']['search']['xugui_tag_top']='/<a([^\>]*?)href\="misc.php\?mod\=tag"([^\>]*)\>/i';
$_G['setting']['output']['preg']['replace']['xugui_tag_top']='<a$1href="tag_0.html"$4>';
$_G['setting']['output']['preg']['search']['xugui_tag']='/<a([^\>]*?)href\="misc.php\?mod\=tag&(amp;)?id\=(\d+?)"([^\>]*)\>/i';
$_G['setting']['output']['preg']['replace']['xugui_tag']='<a$1href="tag_$3.html"$4>';
}
if(!empty($this->custom_replace)){
$replace_arr=explode("\r\n", $this->custom_replace);
foreach ($replace_arr as $key=>$value){
$temp_Arr=explode("->",$value);
if(count($temp_Arr)!=2||empty($temp_Arr[0])||empty($temp_Arr[1])){continue;}
$_G['setting']['output']['str']['search']['xugui_rep_'.$key]=$temp_Arr[0];
$_G['setting']['output']['str']['replace']['xugui_rep_'.$key]=$temp_Arr[1];
}
}
if($this->portal_cat_on&&!empty($_G['setting']['output']['preg']['search'])){
$tab_domain=$_G['setting']['domain']['app']['portal']?$_G['setting']['domain']['app']['portal']:$_G['setting']['domain']['app']['default'];
$_G['setting']['output']['preg']['search']['xugui_portal_cat']='/<a([^\>]*?)href\="portal.php\?mod\=list&(amp;)?catid\=(\d+?)"([^\>]*)\>/i';
$_G['setting']['output']['preg']['replace']['xugui_portal_cat']='<a$1href="plist_$3.html"$4>';
$_G['setting']['output']['preg']['search']['xugui_portal_cat_h']='/<a([^\>]*?)href\="http\:\/\/'.$_SERVER['HTTP_HOST'].'\/portal\.php\?mod=list&(amp;)?catid=(\d+?)"([^\>]*)\>/i';
$_G['setting']['output']['preg']['replace']['xugui_portal_cat_h']='<a$1href="http://'.$_SERVER['HTTP_HOST'].'/plist_$3.html"$4>';
}
if($this->redirect_on){
$purl=$this->getreplace_Url();
$purl=$this->checkDomain($purl);
//现在的地址
$turl=strpos($_SERVER['REQUEST_URI'],"http://")===0?$_SERVER['REQUEST_URI']:"http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if($turl!=$purl){
header("HTTP/1.1 301 Moved Permanently");
header("location: $purl");
die();
}
}
}
}
?>
本文标签:
很赞哦! ()
下一篇:discuz优化技巧分享
相关教程
图文教程
Discuz集成第三方统计工具如百度统计的方法
将Discuz与百度统计集成,意味着在你的论坛页面中嵌入百度统计的代码,从而能够跟踪用户的访问行为。这种集成可以帮助你了解用户如何使用你的论坛,哪些页面欢迎,以及用户的来源和路径。
Discuz的NT非官方升级介绍
接触Discuz的NT有很长的一段时间,从最初的神秘到现在的跃跃欲试,在这个九月之后一天,十一的前一天下午,终于完成了一次非官方升级!
discuz模板引擎介绍分析
discuz是采用“编译型的模板”,就是指采用普通网页文件保存,在文件中插入需要动态显示数据的仿php的代码,之后进行编译成真正的php的文件保存为模板缓存文件
Powershell实践Discuz!NT自动打包发布
最近喜欢上了Powershell,由于本人向来懒惰,遂将日常工作中一些琐碎的,重复的事情用powershell来做了。为此某不才,读了PowerShell自带的
相关源码
-
(自适应html5)自媒体运营培训教程个人博客pbootcms模板本模板基于PbootCMS系统开发,特别适合自媒体运营培训、知识付费类网站使用。采用响应式设计,能够适配各类终端设备,为内容创作者提供专业的内容展示平台。查看源码 -
(自适应)响应式文章博客互联网新闻pbootcms模板下载本模板基于PbootCMS开发,专为科技新闻、互联网资讯和文章博客类网站设计。采用响应式布局技术,确保在电脑、平板和手机上都能获得最佳浏览体验。适用于科技媒体、行业博客查看源码 -
帝国cms题库问答学习平台模板知识付费网站源码+数据采集为教育机构、培训平台及在线学习场景设计,提供完整的题库管理与问答服务解决方案。支持多种题型展示与答案查询,满足不同层次的学习需求。查看源码 -
帝国cms7.2淘宝客导购自媒体博客网站模板源码本模板基于帝国CMS7.2内核深度开发,为淘宝客、商品导购类自媒体及博客网站设计。通过可视化后台管理,可快速搭建具备商品推荐、比价功能的内容平台,帮助用户实现流量高效转化。查看源码 -
(PC+WAP)绣花刺绣传统手工工艺pbootcms网站源码下载这款基于PbootCMS的网站模板为刺绣和传统手工艺行业设计,采用优雅的布局和精致的细节处理,能够呈现手工艺品的独特韵味和文化内涵。模板结构合理,功能完善,是手工艺从业者展示作品的理想选择。查看源码 -
(响应式)轴承机械五金零件产品pbootcms落地推广单页源码下载为轴承、机械零件等工业产品打造的响应式单页模板,基于PbootCMS内核开发,助力企业快速构建专业级产品展示页面。模板采用工业风设计语言,突出产品参数与性能优势,适用于设备制造商、零部件供应商等B2B场景推广。查看源码
| 分享笔记 (共有 篇笔记) |
