您现在的位置是:首页 > 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 X2任务开发教程实例
由于公司的需求要在系统中添加任务管理,用户通过完成任务而获得一定的奖励,因此其设计过程需要考虑到:1、由于任务都是在系统中相关功能块处做一些相关事情,比如说在做题系统中
Discuz的NT企业版Sphinx全文搜索
在前文中,介绍了Discuz!NT引入SPHINX的背景和相应的客户端的C#代码架构实现。今天这篇文章将会介绍如果在LINUX环境下安装配置SPHINX中文搜索工具,也就是服务器配置方案.
discuz的SSO单点,同歩,异步登录实现方法
discuz(dz) SSO(单点,同歩,异步)登录1 )登录请求到 localhost/member.php 初始化一些设置,然后调用source/module/member/member_logging.php(37行)。
安装Discuz论坛时提示“mysqli_connect()不支持advice_mysqli
安装Discuz!论坛时提示“不支持Mysql数据库,无法安装论坛”的解决方法1,在系统的 system32(C:\windows\system32)目录下缺少libmysql.dll文件,解决方法是找到php目录下的libmysql.dll
相关源码
-
(自适应)宽屏大气的净水器智能电子设备网站pbootcms源码下载本模板基于PbootCMS内核开发,为净水器设备、智能电子设备企业量身打造,采用响应式设计技术,可快速构建专业级企业官网。通过本模板可高效展示产品技术参数、解决方案及企业服务优势。查看源码 -
(PC+WAP)压缩机离心风机红色机械设备营销型网站pbootcms模板基于PbootCMS开发的压缩机/离心风机专用模板,助力机械设备企业构建高效营销平台;模板可编辑压缩机参数表、风机性能曲线等专业展示模块查看源码 -
响应式茶叶茶道pbootcms网站模板源码(自适应手机端)棕色复古茶具主题的响应式网站模板,为茶叶茶道企业设计,同时支持古玩字画、艺术文化等行业的快速适配,通过替换文字图片即可转型为其他行业官网,大幅降低开发成本。查看源码 -
pbootcms模板PC+WAP娱乐新闻资讯类博客网站源码该模板基于PbootCMS内核开发,专为娱乐新闻、健康生活类资讯网站设计,同时支持快速适配其他行业(如企业官网、博客门户等),仅需替换图文内容即可完成转型。查看源码 -
(自适应)建站广告公司工作室作品展示品牌策划设计pbootcms源码下载基于PbootCMS开发的创意服务展示系统,内置作品集展示、服务流程图等专业模块,预设客户案例、设计流程等创意行业专属栏目结构。查看源码 -
(PC+WAP)门窗门业家居定制铝合金产品pbootcms模板下载基于PbootCMS内核开发的门窗门业企业专用模板,采用响应式设计结构,数据一次录入即可同步适配电脑与手机端浏览。通过简洁大气的视觉呈现,帮助门窗企业快速建立专业线上展示平台,有效传递产品价值与服务优势。查看源码
| 分享笔记 (共有 篇笔记) |
