<?php/** *[pseudo static jump (xugui_redirect.{ ModuleName})] (C) 2012-2099 Powered by Lazy Man v survivors. *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 ', ' $ ', $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 ') {//disable $_g[' setting ' [' output '] = Array ("0" = "0"); return;}} Label Pseudo-Static 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);//Current address $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");d ie ();}}}? >
Discuz Pseudo-Static code