WordPress|5秒盾防CC|PHP通用代码|

cera cera

这是个类似Cloudflare的防 cc 功能,利用的是五秒盾的原理,经过检测得到 cookie 的浏览器才能正常的访问你的网站了,当然了,面对数以万计的肉鸡,这代码还是无能为力的,所以说做人就要低调,别到处装逼,到时候被打了惨的还是自己,下面分享给需要的同学。

首先建个 cc.php 文件代码如下:

define(‘SYSTEM_ROOT’, dirname(preg_replace(‘@\\(.*\\(.*$@’, ”, preg_replace(‘@\\(.*\\(.*$@’, ”, __FILE__))) . ‘/’);
session_start();
date_default_timezone_set(‘Asia/Shanghai’);
header(‘Content-Type: text/html; charset=UTF-8’);
function getspider($useragent=”){
if(CC_Defender==2)return false;
if(!$useragent){$useragent = $_SERVER[‘HTTP_USER_AGENT’];}
$useragent=strtolower($useragent);
if (strpos($useragent, ‘baiduspider’) !== false){return ‘baiduspider’;}
if (strpos($useragent, ‘googlebot’) !== false){return ‘googlebot’;}
if (strpos($useragent, ‘soso’) !== false){return ‘soso’;}
if (strpos($useragent, ‘bing’) !== false){return ‘bing’;}
if (strpos($useragent, ‘yahoo’) !== false){return ‘yahoo’;}
if (strpos($useragent, ‘sohu-search’) !== false){return ‘Sohubot’;}
if (strpos($useragent, ‘sogou’) !== false){return ‘sogou’;}
if (strpos($useragent, ‘youdaobot’) !== false){return ‘YoudaoBot’;}
if (strpos($useragent, ‘yodaobot’) !== false){return ‘YodaoBot’;}
if (strpos($useragent, ‘robozilla’) !== false){return ‘Robozilla’;}
if (strpos($useragent, ‘msnbot’) !== false){return ‘msnbot’;}
if (strpos($useragent, ‘lycos’) !== false){return ‘Lycos’;}
if (strpos($useragent, ‘ia_archiver’) !== false || strpos($useragent, ‘iaarchiver’) !== false){return ‘alexa’;}
if (strpos($useragent, ‘archive.org_bot’) !== false){return ‘Archive’;}
if (strpos($useragent, ‘robozilla’) !== false){return ‘Robozilla’;}
if (strpos($useragent, ‘sitebot’) !== false){return ‘SiteBot’;}
if (strpos($useragent, ‘mj12bot’) !== false){return ‘MJ12bot’;}
if (strpos($useragent, ‘gosospider’) !== false){return ‘gosospider’;}
if (strpos($useragent, ‘gigabot’) !== false){return ‘Gigabot’;}
if (strpos($useragent, ‘yrspider’) !== false){return ‘YRSpider’;}
if (strpos($useragent, ‘gigabot’) !== false){return ‘Gigabot’;}
if (strpos($useragent, ‘jikespider’) !== false){return ‘jikespider’;}
if (strpos($useragent, ‘addsugarspiderbot’) !== false){return ‘AddSugarSpiderBot’;/*非常少*/}
if (strpos($useragent, ‘testspider’) !== false){return ‘TestSpider’;}
if (strpos($useragent, ‘etaospider’) !== false){return ‘EtaoSpider’;}
if (strpos($useragent, ‘wangidspider’) !== false){return ‘WangIDSpider’;}
if (strpos($useragent, ‘foxspider’) !== false){return ‘FoxSpider’;}
if (strpos($useragent, ‘docomo’) !== false){return ‘DoCoMo’;}
if (strpos($useragent, ‘yandexbot’) !== false){return ‘YandexBot’;}
if (strpos($useragent, ‘ezooms’) !== false){return ‘Ezooms’;/*个人*/}
if (strpos($useragent, ‘sinaweibobot’) !== false){return ‘SinaWeiboBot’;}
if (strpos($useragent, ‘catchbot’) !== false){return ‘CatchBot’;}
if (strpos($useragent, ‘surveybot’) !== false){return ‘SurveyBot’;}
if (strpos($useragent, ‘dotbot’) !== false){return ‘DotBot’;}
if (strpos($useragent, ‘purebot’) !== false){return ‘Purebot’;}
if (strpos($useragent, ‘ccbot’) !== false){return ‘CCBot’;}
if (strpos($useragent, ‘mlbot’) !== false){return ‘MLBot’;}
if (strpos($useragent, ‘adsbot-google’) !== false){return ‘AdsBot-Google’;}
if (strpos($useragent, ‘ahrefsbot’) !== false){return ‘AhrefsBot’;}
if (strpos($useragent, ‘spbot’) !== false){return ‘spbot’;}
if (strpos($useragent, ‘augustbot’) !== false){return ‘AugustBot’;}
return false;
}

if($_GET[‘rand’] && $_SESSION[‘rand_session’]!=$_GET[‘rand’]){
@header(‘Content-Type: text/html; charset=UTF-8’);
exit(‘浏览器不支持 COOKIE 或者不正常访问!‘);
}
if(!$_SESSION[‘rand_session’] && $nosecu!=true){
if(!getspider()){
$rand_session=md5(uniqid().rand(1,1000));
$_SESSION[‘rand_session’]=$rand_session;
exit(”

 

 

 

浏览器安全检查中…

还剩 5

“);}}
WordPress 上传到主题/template/cc.php ;

调用代码
PHP 通用调用,在头部或主要文件内文件加入:


WordPress 调用,主题/header.php 第一行添加代码:


首次访问网站检测浏览器 cookie 通过才能正常的访问你的网站,搜索引擎蜘蛛已经过滤,不影响收录,还有未加上的可以自己补充。

cera cloudiplc tengxunyun

相关推荐