<?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伪静态代码的更多相关文章

  1. Discuz!伪静态原理分析

    伪静态在seo火热的时代,是每个站长都比较关注的问题,discuz!论坛如何伪静态,为什么伪静态失效了,为什么列表页无法实现伪静态,为什么有些页面不是伪静态呢?下面dz官方nxy105从两个角度入手为 ...

  2. 仅个人兴趣,自己通过搜索他人的成果,结合自己的理解,来分析discuz的代码。

    仅个人兴趣,自己通过搜索他人的成果,结合自己的理解,来分析discuz的代码. discuz 版本: 3.2

  3. ecstore b2b2c 商城页面伪静态代码 及相关注意事项

    一下代码需要添加到 nginx.conf配置文件的server块,阿里云虚拟机一般在conf文件夹下建立vhost文件夹,把server块放进去,然后 在nginx.conf使用include 包含进 ...

  4. 对discuz的代码分析学习(一)目录结构

    主目录 DISCUZ用的是自己的框架,和其他框架应用一样属于单入口应用.主目录下的.php文件,大部分是应用的入口文件. home.php:家园入口,即论坛中类似博客的那个东西.index.php:首 ...

  5. discuz伪静态设置

        Discuz! 通用伪静态 -包含所有类型主机本人找了一下午才找到的,谢谢这位原创者,发出来让大家用. 第一步:打开后台  全局 SEO设置 全部打勾<ignore_js_op>  ...

  6. discuz伪静态问题(简单)

    提前声明一下我用的是宝塔面板.Linux系统.Nginx Web Server.经过一上午的摸索(我很菜了),终于在一个很无语的地方成功搞了伪静态1.2.点击查看当前的 Rewrite 规则3.我的是 ...

  7. 对discuz的代码分析学习(三)mysql驱动

    一. 属性分析         1.tablepre :表名称前缀        2.version : 数据库版本        3.drivertype:驱动类型        4.querynu ...

  8. 对discuz的代码分析学习(二)首页文件

    如果当前地址栏存在查询字符,并且是一个数字,条件成立. 查询字符:www.baidu.com/index.php?aaa=bbb              aaa=bbb就是查询字符如果条件成立,则把 ...

  9. discuz!代码内置颜色大全(收藏)

    加闪烁字:[light]文字[/light] 加文字特效:[shadow=255,red,2]文字[/shadow]: 在标签的中间插入文字可以实现文字阴影特效,shadow内属性依次为宽度.颜色和边 ...

随机推荐

  1. kvc kvo 总结---180313

    textField.placeholder = @"username is in here!"; [textField setValue:[UIColor redColor] fo ...

  2. mysql 將時間戳直接轉換成日期時間

    from_unixtime()是MySQL裏的時間函數 Sql代碼 select uid,userid,username,email,FROM_UNIXTIME(addtime,'%Y年%m月%d') ...

  3. vim note(5)

    .vimrc 的设置 $HOME/.vimrc 的普通设置,例如以下. set nocompatible "" not compatible with VI "" ...

  4. JAVA 学习 IDEA安装及破解

    1.到官网下载安装包 网址:https://www.jetbrains.com/idea/download/#section=windows 选择  “”Ultimate “”这个版本点击“Downl ...

  5. POJ 3100:Root of the Problem

    Root of the Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12060   Accepted: 6 ...

  6. iOS开发——多线程

    很多朋友都说iOS开发中,最难理解和学习的就是多线程,很多的原理实现都是通过log看到,也比较抽象,本人也是在多线程方面投入过很多脑细胞..无论这方面的知识掌握和应用起来是否轻松,牢固的基本功.正确的 ...

  7. robotframework - Edit编辑器

    1.测试项目&套件 提供的Edit编辑器 2.在 Edit 标签页中主要分:加载外部文件.定义内部变量.定义元数据等三个部分. (1):加载外部文件Add Library:加载测试库,主要是[ ...

  8. robotframework - 框架做接口自动化post请求

    1.做get请求之前先安装 Request库,参考github上链接 :https://github.com/bulkan/robotframework-requests/#readme 2.请求&a ...

  9. php使用邮箱发送验证码

    如果看着文字眼乏就去看看视频吧-> 如何注册腾讯企业邮箱 https://www.bilibili.com/video/av14351397/ 如何在项目中使用 https://www.bili ...

  10. JS 实现PDF文件打印

    function PdfPrint() {        bdhtml = window.document.body.innerHTML;        sprnstr = "<!-- ...