源码介绍
WordPress防红系统跳转页面和引导跳转页面gophp-html源码美化版,双端自适应。自动文章内的外链加入加密的跳转链接,其他网站也可以用。
使用教程:
1、网站根目录新建go文件夹
2、go目录里新建index.php
3、index.php里的代码如下:
<?php /*自动跳转页面*@copyright (c) Emlog All Rights Reserved *///自定义跳转地址$cars = array( array("qcloud",'https://curl.qcloud.com/ogHI5jPB'), array("aliyun",'https://www.aliyun.com/minisite/goods?userCode=y7af6jip'), );if(strlen($_SERVER['REQUEST_URI']) > 384 || strpos($_SERVER['REQUEST_URI'], "eval(") || strpos($_SERVER['REQUEST_URI'], "base64")) { @header("HTTP/1.1 414 Request-URI Too Long"); @header("Status: 414 Request-URI Too Long"); @header("Connection: Close"); @exit;}//通过QUERY_STRING取得完整的传入数据,然后取得url=之后的所有值,兼容性更好$t_url = htmlspecialchars(preg_replace('/^url=(.*)$/i','$1',$_SERVER["QUERY_STRING"]));//此处可以自定义一些特别的外链,不需要可以删除以下5行foreach($cars as $k=>$val){ if($t_url==$val[0] ) { $t_url = $val[1]; $t_vip = 1; }} //数据处理if(!empty($t_url)) { //判断取值是否加密 if ($t_url == base64_encode(base64_decode($t_url))) { $t_url = base64_decode($t_url); } //对取值进行网址校验和判断 preg_match('/^(http|https|thunder|qqdl|ed2k|Flashget|qbrowser):///i',$t_url,$matches);if($matches){ $url=$t_url; $;} else { preg_match('/./i',$t_url,$matche); if($matche){ $url='http://'.$t_url; $; } else { $url = 'http://'.$_SERVER['HTTP_HOST']; $; }}} else { $title = '参数缺失,正在返回首页...'; $url = 'http://'.$_SERVER['HTTP_HOST'];}?><?php echo $title;?>
秒
3
外部网站,注意安全!
">立即前往菜鸟站长之家
4、在functions.php里加下面的代码:(注部分主题可能不是这个请自己区别)
/*自动给文章的外部链接添加nofollow属性开始*/ add_filter('the_content','link_jump',999);function link_jump($content){preg_match_all('//',$content,$matches);if($matches){ foreach($matches[2] as $val){ if(strpos($val,'://')!==false && strpos($val,home_url())===false && !preg_match('/.(jpg|jepg|png|ico|bmp|gif|tiff)/i',$val) && !preg_match('/(ed2k|thunder|Flashget|flashget|qqdl):///i',$val)){ $content=str_replace("href="$val"", "href="".home_url()."/go/?".base64_encode($val)."" rel="nofollow"",$content);}}}return $content;}// 自动给文章的外部链接添加nofollow属性结束/*WordPress外链自动新窗口打开并添加nofollow属性*/add_filter( 'the_content', 'cn_nf_url_parse');function cn_nf_url_parse( $content ) { $regexp = "]*href=("??)([^" >]*?)1[^>]*>"; if(preg_match_all("/$regexp/siU", $content, $matches, PREG_SET_ORDER)) { if( !empty($matches) ) { $srcUrl = get_option('siteurl'); for ($i=0; $i < count($matches); $i++) { $tag = $matches[$i][0]; $tag2 = $matches[$i][0]; $url = $matches[$i][0]; $noFollow = ''; $pattern = '/targets*=s*"s*_blanks*"/'; preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE); if( count($match) < 1 ) $noFollow .= ' target="_blank" '; $pattern = '/rels*=s*"s*[n|d]ofollows*"/'; preg_match($pattern, $tag2, $match, PREG_OFFSET_CAPTURE); if( count($match) < 1 ) $noFollow .= ' rel="nofollow" '; $pos = strpos($url,$srcUrl); if ($pos === false) { $tag = rtrim ($tag,'>'); $tag .= $noFollow.'>'; $content = str_replace($tag2,$tag,$content); } } } } $content = str_replace(']]>', ']]>', $content); return $content;}
OK 去看看效果吧,引用格式是:XXX/go/?你要跳转的地址
文章里出现外链是自动转换的。XXX代表你的网址地址!