Discuz伪静态代码
<?php
/**
* [伪静态跳转(xugui_redirect.{modulename})] (C)2012-2099 Powered by 懒人V难人.
* Version: 1.0
* Date: 2012-8-1 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!伪静态原理分析
伪静态在seo火热的时代,是每个站长都比较关注的问题,discuz!论坛如何伪静态,为什么伪静态失效了,为什么列表页无法实现伪静态,为什么有些页面不是伪静态呢?下面dz官方nxy105从两个角度入手为 ...
- 仅个人兴趣,自己通过搜索他人的成果,结合自己的理解,来分析discuz的代码。
仅个人兴趣,自己通过搜索他人的成果,结合自己的理解,来分析discuz的代码. discuz 版本: 3.2
- ecstore b2b2c 商城页面伪静态代码 及相关注意事项
一下代码需要添加到 nginx.conf配置文件的server块,阿里云虚拟机一般在conf文件夹下建立vhost文件夹,把server块放进去,然后 在nginx.conf使用include 包含进 ...
- 对discuz的代码分析学习(一)目录结构
主目录 DISCUZ用的是自己的框架,和其他框架应用一样属于单入口应用.主目录下的.php文件,大部分是应用的入口文件. home.php:家园入口,即论坛中类似博客的那个东西.index.php:首 ...
- discuz伪静态设置
Discuz! 通用伪静态 -包含所有类型主机本人找了一下午才找到的,谢谢这位原创者,发出来让大家用. 第一步:打开后台 全局 SEO设置 全部打勾<ignore_js_op> ...
- discuz伪静态问题(简单)
提前声明一下我用的是宝塔面板.Linux系统.Nginx Web Server.经过一上午的摸索(我很菜了),终于在一个很无语的地方成功搞了伪静态1.2.点击查看当前的 Rewrite 规则3.我的是 ...
- 对discuz的代码分析学习(三)mysql驱动
一. 属性分析 1.tablepre :表名称前缀 2.version : 数据库版本 3.drivertype:驱动类型 4.querynu ...
- 对discuz的代码分析学习(二)首页文件
如果当前地址栏存在查询字符,并且是一个数字,条件成立. 查询字符:www.baidu.com/index.php?aaa=bbb aaa=bbb就是查询字符如果条件成立,则把 ...
- discuz!代码内置颜色大全(收藏)
加闪烁字:[light]文字[/light] 加文字特效:[shadow=255,red,2]文字[/shadow]: 在标签的中间插入文字可以实现文字阴影特效,shadow内属性依次为宽度.颜色和边 ...
随机推荐
- Android上拉查看详情实现
京东淘宝有那么一种效果就是,上拉能够查看宝贝的详情,这里我也实现了一个类似的效果,也能够移植到商业项目上:先看看简单的效果图 实现原理事实上是利用了ScrollView的滚动和view的touch事件 ...
- Go语言核心之美 3.2-slice切片
Slice(切片)是长度可变的元素序列(与之相应,上一节中的数组是不可变的),每一个元素都有同样的类型.slice类型写作[]T.T是元素类型.slice和数组写法非常像,差别在于slice没有指定长 ...
- ×变成x
昨天晚上遇到一个很尴尬的bug. 当使用IE浏览器,跳转链接使用&传参的时候第二个参数是times,也就是×(你有可能看到的是x,实际是×),结果& ...
- linux服务器上的mysql允许远程连接
首先进入mysql: 输入GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; 这里是 ...
- python uzip
import zipfile import osdef un_zip(file_name): """unzip zip file""" zi ...
- 【poj2774】Long Long Message
用个分隔符将两个字符串连接起来,再用后缀数组求出height数组的值,找出一个height值最大并且i与i-1的sa值分别在两串字符中就好 #include<algorithm> #inc ...
- swoole简易实时聊天
最近公司拓展业务,需要做一个即时聊天业务,就顺带研究了一下swoole,文档地址贴出来:https://wiki.swoole.com/ 文档写得很详细,demo也很简洁明了,所以废话就不多说了. 工 ...
- GCD总结(一)
GCD为我们提供了三种类型的调度队列(dispatch queue),分别为串行,并行和主调度队列. 串行(Serial) 你可以创建任意个数的串行队列,每个队列依次执行添加的任务,一个队列同 ...
- SPOJ OTOCI 动态树 LCT
SPOJ OTOCI 裸的动态树问题. 回顾一下我们对树的认识. 最初,它是一个连通的无向的无环的图,然后我们发现由一个根出发进行BFS 会出现层次分明的树状图形. 然后根据树的递归和层次性质,我们得 ...
- Python 私有化类的属性
class MandgerSec: def __init__(self,name,gender,level): self.type=("fire",None) self.name= ...