您现在的位置是:首页 > 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自带参数防御CC攻击和原理分析
CC攻击确实是很蛋疼的一种攻击方式,Discuz!的配置文件中已经有了一个自带的减缓CC攻击的参数,在配置文件config.inc.php中:
URLOS快速安装Discuz论坛的方法
Discuz是国内大最多人使用的论坛社区系统,自2001年6月面世以来,Discuz!已拥有15年以上的应用历史和200多万网站用户案例,是全球成熟度较高、覆盖率大的论坛软件系统之一。
Discuz<= 7.2 SQL注入漏洞分析
Discuz树大招风已成常态,不过对于其他整站程序何尝不是如此?是否曾记得大明湖畔的PHPCMS和DEDCMS万人破的场景,流行整站程序最重要的还是漏洞的快速响应。0x01 漏洞成因:
Discuz论坛添加Wiki语法的方法
目标是使在论坛中的特定语法能够被解析为Wiki实际的url, 如:关键字需要支持以下2种论坛语法:
相关源码
-
(自适应响应式)蓝色外贸英文产品介绍展示网站模板本模板采用手工编写的DIV+CSS架构,代码精简高效。适配手机端浏览,数据实时同步更新。内置SEO优化框架,支持独立设置各页面标题、关键词及描述。开源代码结构清晰,便于二次开发。查看源码 -
(响应式自适应)小学初中作文论文文章资讯博客pbootcms模板下载为中小学作文、教育类网站设计,特别适合展示学生作文、教学资源和写作指导等内容。采用响应式技术,确保在不同设备上都能获得良好的阅读体验。查看源码 -
(自适应响应式)环保水净化处理设备阀门等网站源码下载基于PbootCMS内核开发的响应式模板,为水处理设备、空气净化器等环保企业设计,自适应手机端浏览。通过简洁高效的后台管理系统,助力环保科技企业快速建立专业在线展示平台。查看源码 -
pbootcms模板(PC+WAP)APP应用软件下载类官网源码为APP应用软件官网打造的响应式解决方案,PC端与移动端(WAP)数据实时同步,一次更新全网生效,满足多终端用户无缝体验需求。查看源码 -
(自适应响应式)教育培训机构集团网站pbootcms源码下载本模板基于PbootCMS系统开发,为教育培训机构设计,特别适合展示课程体系、师资团队和教学成果。采用响应式技术,确保在各类设备上都能提供良好的浏览体验。查看源码 -
(PC+WAP)绿色草坪地坪操场pbootcms网站模板该模板基于PbootCMS内核开发,专为人造草坪、地坪施工企业设计,采用绿色主题呼应行业属性,实现PC与WAP端全栈响应式适配,确保跨设备无缝浏览体验。查看源码
| 分享笔记 (共有 篇笔记) |
