Lua代码(保存为文件):

p1 = [=[
<html><head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="referrer" content="always">
  <title>道锋潜鳞 - 风控中心 - 跳转</title>
<style>
    html,body{background:#F3F4F5;font-family: PingFang SC,Hiragino Sans GB,Arial,Microsoft YaHei,Verdana,Roboto,Noto,Helvetica Neue,sans-serif;padding:0;margin:0;}
    a{text-decoration:none;}
    .content{padding-top:220px;width:450px;margin:auto;word-break: break-all;}
    .content .logo-img img{display: block;width:175px;margin:auto;margin-bottom: 16px;}
    .content .loading-item{background:#fff;padding:24px;border-radius: 12px;border: 1px solid #E1E1E1;}
    .content .flex{display:flex;align-items:center;}
    .content .flex-end{display:flex;justify-content:flex-end}
    .content .tip1{background:#F0F9EA;} 
    .content .tip2{background:#FDF5E6;}
    .content .tip3{background:#FEF0F0;}
    .content .loading-color1{color:#267DCC;}
    .content .loading-color2{color:#FC5531;}
    .content .loading-tip{padding:12px;margin-bottom:16px;border-radius:4px;}
    .content .loading-topic{font-size: 14px;color: #222226;line-height: 24px;margin-bottom:24px;}
    .content .loading-img{width:24px;height:24px;}
    .content .loading-btn{font-size: 14px;color: #FC5531;border: 1px solid #FC5531;display:inline-block;box-sizing: border-box;padding:6px 18px;border-radius: 18px;margin-left:8px;}
    .content .loading-btn2{font-size: 14px;color: #000000;border: 1px solid #000000;display:inline-block;box-sizing: border-box;padding:6px 18px;border-radius: 18px;margin-left:8px;}
    .content .loading-btn-github{width:121px;background:#FC5531;color:#fff;}
    .content .loading-text{font-size: 16px;font-weight: 600;color: #222226;line-height: 22px;margin-left:12px;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;}
    @media (max-width: 450px){
      .content{padding-top:120px;width:94%;}
    }
    #csdn-toolbar{width: 0;height: 0;display: none}
  </style></head>
<body class="vsc-initialized">
  
    <div id="linkPage" class="link-page">
        <div class="content">
            <div class="logo-img"><img src="https://b.4l2.cn/wp-content/uploads/2021/02/logo-full.png" alt=""></div>
              
        <div class="loading-item loading-others">                        
          <div class="flex loading-tip tip2">                          
               <img class="loading-img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAADWUlEQVRoQ+2YvWsUQRiH33fmOMQiRQor7RQSweB9KAQEg1iYKFaZnJJ/wcTOMhLs7Ez8FwLebikasTGCoJDcHSoYQbHRyiKFhajczCu3SS73sbfzsXNJDnLV3s4y83vm3X12dhAG/IcDnh+OAHpVkITISvg2DYyQjwyVcXGt3o9q960CdZELAWC6ERoRn/CgentgAGimOCVJPmsNzJFfx2DjuW8I7xWg+xMZ9enXRwIaaQ2LgJ/Z2aFzvm8l7wBypjBPpB7FzTQiu8uDypLPKngFIDE+rODPFwIYjgUA2GJw7AyGb7d8QXgFkCK/TEB3ksIh4GMeVucOHQCV8qNKwQcCymgA6ozBGJarmz4gvFWgLvKrAHTNLBS+yITVSbNrk6/yAhCnTV04X1pNDdBLmzoAX1pNDZCkTS2EB62mAtBpUwvgQaupAEy0qYdIp1VnAFNtGgCk0qozgJ02tRjOWnUCoFJxUiqZuLJEgB+AbCWKTmqWAE4mYXDGp7C8sapD7Wy3BjDVJke8iUH1aZS/lL8hFUXHvX6uWrUGMNUmByxiWK1sAxTyUqnoOBHCQatWADbadAJw0KoVgJwpLBEpo5WkC0CjOohsmQeVeV21dtuNAWy16QwAaKVVYwBbbboCbM+s+WrVCMBEm50lTwcAYKpVLYCpNrsALDXa7XezTQAtgKk2Y14wVi+yuIfWZBMgEcBGm6bWsLkODbSaCGCjTZtgNtfqtNoTwFabMffwb0DYWQvBLAEdtwm+5/lkrfYEsNVmazgElIzxcSyvr0dLiVu5opL4joC4C0SSVmMBXLTZBoDwnge1863npMjVCKDtnA1ML612Abhqs70C8JPB6VMYhv+iCgiRVfD1OwGcsAndPim4yUaHxjr3VrsAZCk3RwpS718i4gpjdK8RQil8SESzruGbzwODeV6uLXdM1t7fg9amDjBOq20VOAza1EJ0rFabAGm1qRvYVzt2rFabAHWRa3zjetmv9BU2oZ/VTFibarRHACQuXJZQX9uHgb0NwZFdwaDyKgKQorBAoBa99b4PHSHCAx7UFnYqULikUL0mArYPY6ceInrTA05gWHmz9xCL4kWF6ioAZFOP0NcO8C8jerm746H9HuhrFg+dHwF4mMRUXQx8Bf4DeBHHQHvQneAAAAAASUVORK5CYII=" alt="">                          
               <div class="loading-text">请注意您的账号和财产安全</div>                        
          </div>                        
          <div class="loading-topic">
               <span>您即将离开,去往:</span>
               <a class="loading-color2">
]=]
p2 = [=[
</a> </p>
               <span>该链接不是我们的官方链接,风险不在我们的可控范围内</span>
          </div>
          <div class="flex-end">
               <a class="loading-btn" href="
]=]
p3 = [=[
" target="_self" >继续</a>&nbsp;&nbsp;
	<a class="loading-btn2"  href="#" onClick="javascript:history.back(-1);" target="_self">取消</a>
          </div>
</div>
</div>
</div>
</body>
</html>
]=]
resp = p1..ngx.var.arg_url..p2..ngx.var.arg_url..p3
ngx.say(resp)

Nginx配置(部分):

location ~ ^/goto/* {
    if ($request_method != GET) {
      return 403;
    } 
    if ($arg_url = "") {
      return 403;
    }
      default_type text/html;
      content_by_lua_file /data/lua/link.lua; #前面lua代码的地址
    }

Wp:

打开你的主题内的functions.php文件。

在末尾添加如下php代码:

function the_content_nofollow($content){
    preg_match_all('/<a(.*?)href="(.*?)"(.*?)>/',$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)){
            $content=str_replace("href=\"$val\"", "href=\"".home_url()."/goto?url=$val\" ",$content);
        }
    }
}
return $content;
}
add_filter('the_content','the_content_nofollow',999);

实现效果:


天渊应龙圣神大帝-道锋潜鳞

由道而生,消逝于道

0 条评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注




Enter Captcha Here :