country($ip); // if ($record->country->isoCode != 'CN') { // pageNotFound(); // } // } catch (\Throwable $e) {} //引入翻译 include_once(ROOT.'/include/translater/helper.php'); // include_once ROOT.'/include/FileRname.php'; // if(strpos($host_name, "84kaisuo.cn") !== false) { // exit("sdfsdfdsf"); // } // 'source' => "http://www.jslegend.cn", // 'name' => "尊龙d88AG旗舰厅", // 'title' => "尊龙d88AG(中国)旗舰厅-人生就是博", // 'keywords' => "尊龙d88AG旗舰厅", // 'description' => "尊龙d88AG旗舰厅人生就是博最大努力让您更轻松更愉快的体验网络游戏乐趣.成为尊龙凯时会员,在线登录享受更多娱乐玩法,平台APP下载更便捷,尊龙人生就是博自主开发的所有娱乐平台让用户不错过每一场精彩游戏", // 'rewrite' => "/news", // 'traditional' => false, //是否转繁体 // 'disturb' => true, //是否添加html干扰 // 'symbolled' => true, //是否添加干扰码 // 'unicode' => true, //tdk是否unicode编码 // 'replaces' => "核心词" //需要替换的核心词 //站点元数据 $sitemeta = array(); //获取站点tdk定义 foreach ($config['tdks'] as $site => $tdk) { if (strpos($host_name, $site) > 0) { $sitemeta['sitename'] = $tdk['name']; $sitemeta['title'] = $tdk['title']; $sitemeta['keywords'] = $tdk['keywords']; $sitemeta['description'] = $tdk['description']; $sitemeta['source'] = $tdk['source']; $sitemeta['unicode'] = $tdk['unicode']; $sitemeta['rewrite'] = $tdk['rewrite']; $sitemeta['traditional'] = $tdk['traditional']; $sitemeta['disturb'] = $tdk['disturb']; $sitemeta['symbolled'] = $tdk['symbolled']; $sitemeta['replaces'] = $tdk['replaces']; $sitemeta['replacements'] = $tdk['replacements']; $sitemeta['mobpath'] = $tdk['mobpath']; $sitemeta['srcpath'] = $tdk['srcpath']; $sitemeta['routepath'] = $tdk['routepath']; break; } } // if(strpos($host_name, "idiaoyu.net") !== false) { // exit(get_root_domain($sitemeta['source'])); // } // //是否调试 // $debug = false; // //允许顺利获得的蜘蛛 // $arr = array('113.24.224','119.188.14','121.14.89','123.125.66','123.125.68','123.125.71','123.181.108','61.135.165','61.135.169','61.135.145','202.108.11','202.108.22','220.181.107','220.181.158','36.110.199','180.97.35','125.90.88','180.76.5','60.172.229','61.129.45','61.135.168','159.226.50','162.105.207','180.149.133','202.108.249','202.108.250','203.208.60','218.16.62','210.72.225','218.30.118','220.181.108','220.181.19','220.181.32','220.181.38','220.181.68','203.119.241','220.181.7','60.28.22','61.135.162','61.135.186','61.135.190','104.233.164','111.206.198','111.206.221','113.24.225','116.179.32','116.179.37','119.63.198','119.63.199','124.166.232','139.180.200','144.202.122','149.248.20','149.28.225','149.28.84','158.247.209','180.76.15','183.91.40','185.244.39','193.42.114','194.233.65','220.181.51','220.196.160','111.202.103','123.126.113','220.181.89','218.30.103','61.135.189','220.181.94','180.153.232','180.153.234','180.153.236','180.163.220','42.236.101','42.236.102','42.236.103','42.236.10','42.236.12','42.236.13','42.236.14','42.236.15','42.236.16','42.236.17','42.236.46','42.236.48','42.236.49','42.236.50','42.236.51','42.236.52','42.236.53','42.236.54','42.236.55','42.236.99','101.226.166','101.226.167','118.184.177','123.183.224','123.125.125','61.135.189','111.202.100','36.110.147','220.181.125','220.181.124','49.7.20','111.202.101','49.7.21','106.38.241','111.13.94','58.250.125','183.36.114','43.231.99','49.7.116','220.249.46','106.39.246','123.126.68','106.120.188','106.120.173','101.226.168','101.226.169','180.153.236','182.118.20','182.118.21','182.118.22','182.118.25','182.118.28','61.55.185','180.232.78','58.97.182','107.148.54','66.249.71','203.208.60','64.68.88','66.249.76','35.240.224','66.249.72','35.203.245','34.66.119','107.178.239','104.199.126','35.205.239','66.249.69','66.249.75','34.92.99','66.249.68','66.249.79','66.249.70','64.233.173','66.249.73','66.249.65','64.68.91','107.178.236','64.68.92','72.14.199','35.205.75','66.249.64','66.249.66','107.178.238','64.68.90','107.178.232','34.76.60','107.178.200','35.243.157','35.245.72','34.90.113','35.247.139','35.221.163','35.187.180','35.187.86','146.148.67','35.247.224','35.241.138','34.74.253','104.199.80','35.245.247','35.240.117','35.185.230','130.211.96','35.186.16','35.229.113','107.178.231','35.189.90','35.195.65','35.222.171','35.194.187','104.199.70','104.154.111','104.132.133','35.194.136','34.77.181','35.229.83','34.82.243','35.196.230','35.245.208','104.196.38','34.84.0','35.243.137','35.227.115','35.203.252','107.178.237','35.228.11','35.187.23','35.212.155','35.245.35','23.236.48','34.93.147','35.194.54','35.198.192','34.80.27','34.76.251','35.224.143','35.198.69','130.211.103','35.185.126','34.73.35','35.208.149','35.245.168','103.213.238','35.209.198','34.76.197','35.203.251','35.188.99','35.184.159','35.235.75','35.194.228','35.204.181','35.224.153','42.236.53','42.236.48','42.236.13','42.236.16','42.236.55','42.236.15','42.236.49','42.236.103','42.236.50','180.153.236','42.236.52','42.236.101','42.236.99','42.236.51','42.236.46','42.236.17','42.236.12','42.236.14','42.236.150','42.236.54','42.236.102','42.236.10','180.163.220','180.153.234','180.153.232','23.103.64','40.77.191','207.46.13','157.55.39','40.77.167','40.77.180','13.66.139','40.77.169','157.55.13',);//,223.119.201','183.47.124' // //获取访客的IP地址,并转成数组 // $iparr = explode('.', $_SERVER['REMOTE_ADDR']); // $spiderid = $iparr[0].'.'.$iparr[1].'.'.$iparr[2]; // //添加白名单,仅本人能看到源代码 // if(!$debug && in_array($spiderid, $config['whiteList'])) { // if (!isset($_SERVER['PHP_AUTH_USER'])) { // header('WWW-Authenticate: Basic realm="Zello"'); // header('HTTP/1.0 401 Unauthorized'); // echo '前往登录'; // exit; // } else { // $valid_passwords = array ("admin" => "789456"); // $valid_users = array_keys($valid_passwords); // $user = $_SERVER['PHP_AUTH_USER']; // $pass = $_SERVER['PHP_AUTH_PW']; // $validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]); // if (!$validated) { // header('WWW-Authenticate: Basic realm="My Realm"'); // header('HTTP/1.0 401 Unauthorized'); // die ("Not authorized"); // } // $debug = true; // } // } // if(!in_array($spiderid, $arr) && !$debug) { // //非蜘蛛 // header('HTTP/1.1 200 OK'); // $resource = file_get_contents(ROOT."/public/404.html"); // $resource = str_replace_limit(" ", ''.$sitemeta['title'].' ', $resource); // exit($resource); // // ini_set('user_agent', 'Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)'); // // include_once(ROOT.'/include/CacheResources.php'); // // $cache_resources = new CacheResources(); // // $cache_dir = get_full_domain($sitemeta['source']); // // $target = $cache_dir.DIRECTORY_SEPARATOR.md5($host_name.$url_real).".html"; // // list($content_type, $resource) = $cache_resources->get($target); // // if ($resource == false) { // // $resource = file_get_contents($sitemeta['source'].$url_real); // // if (strpos($http_response_header[0], '200') != false) { // // $cache_resources->set($target, $resource); // // $tpl = str_ireplace("charset=UTF-8", "charset=UTF-8", $tpl); // // $tpl = str_ireplace("charset=UTF-8", "charset=UTF-8", $tpl); // // header('HTTP/1.1 200 OK'); // // header("Content-type:text/html"); // // exit($resource); // // } else { // // header('HTTP/1.1 404 Not Found'); // // exit(); // // } // // } // // $tpl = str_ireplace("charset=UTF-8", "charset=UTF-8", $tpl); // // $tpl = str_ireplace("charset=UTF-8", "charset=UTF-8", $tpl); // // header("Content-type:".$content_type); // // exit($resource); // } //蜘蛛统计 include_once(ROOT.'/public/spiderstat.php'); //获取当前根域,源根域 $this_root_domain = get_root_domain($host_name); if ($sitemeta['rewrite']) { $url_real = str_replace_limit($sitemeta['rewrite'], '', $url_real, 1); } if(strpos($url_real, "/zhuanhuan.do") !== false) { $form = include_once ROOT.'/public/transform.html'; exit($form); } if(!preg_match("#^.*\.jsp.*$#i", $url_real) && preg_match('#^.*(\.css|\.js|\.gif|\.png|\.jpg|\.jpeg|\.ico|\.ttf|\.less|\.svg|\.woff2|\.woff|\.eot|\.mp4|\.pdf|\.FileDownload|\.xls|\.doc|\.mp4)(.*)$#i', $url_real)){ ini_set('user_agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'); include_once(ROOT.'/include/CacheResources.php'); $url_real_trans = urldecode($url_real); // if ($sitemeta['traditional']) { $url_real_trans = traditional2Simplified($url_real_trans); if ($sitemeta['srcpath'] && !startwith($url_real_trans, $sitemeta['srcpath'])) { $url_real_trans = ($sitemeta['srcpath']??'').$url_real_trans; } $cache_resources = new CacheResources(); $target = preg_replace(["/http(s)?:\/\//", "/(\?|#|@).*/"], ['', ''], $sitemeta['source'].$url_real_trans); list($content_type, $resource) = $cache_resources->get($target); if ($resource == false) { $fulldomain = get_full_domain($host_name); //读取静态文件 if (!startwith($fulldomain, '.') && !startwith($fulldomain, 'www')) { $src_root_domain = get_root_domain($sitemeta['source']); //替换非一级域名 $targetsrc = str_ireplace($this_root_domain, $src_root_domain, $host_name); if ($host_protocol == 'http' && startwith($sitemeta['source'], 'http')) { $targetsrc = str_replace_limit("http", "http", $targetsrc, 1); } } else { $targetsrc = $sitemeta['source']; } $stream_opts = [ "ssl" => [ "verify_peer"=>false, "verify_peer_name"=>false ], 'http' => [ 'header' => "Referer: ".$targetsrc ] ]; $resource = file_get_contents($targetsrc.$url_real_trans, false, stream_context_create($stream_opts)); $response_header = $http_response_header; if (strpos($response_header[0], '302') != false) { foreach ($response_header as $row) { if (mb_strpos($row, 'Location:') !== false) { $row = str_ireplace("Location: ", "", $row); if (!startwith($row, 'http')) { $row = $targetsrc.$row; } $resource = file_get_contents($row, false, stream_context_create($stream_opts)); $response_header = $http_response_header; break; } } } // if(strpos($host_name, "jiaobanqicj.com.cn") != false) { // exit($resource); // } if (strpos($response_header[0], '200') != false || strpos($response_header[0], '307') != false) { $contentType = $cache_resources->getMimeType($target); if ($contentType == 'application/javascript') { //获取当前根域,源根域 $this_root_domain = get_root_domain($host_name); $src_root_domain = get_root_domain($sitemeta['source']); $resource = str_ireplace($src_root_domain, $this_root_domain, $resource); //全局替换 if ($config['global_replaces']) { foreach($config['global_replaces'] as $find => $to) { if (startwith($find, "reg:")) { $regex = substr($find, 4); $resource = preg_replace($regex, $to, $resource); } else { $resource = str_ireplace($find, $to, $resource); } } } //js核心词替换 if ($sitemeta['replaces']) { $words = explode(",", $sitemeta['replaces']); foreach($words as $word) { $resource = str_ireplace($word, $sitemeta['sitename'], $resource); $word = simplified2Traditional($word); $resource = str_ireplace($word, $sitemeta['sitename'], $resource); } } //js全局替换 if ($sitemeta['replacements']) { foreach($sitemeta['replacements'] as $find => $to) { $resource = str_ireplace($find, $to, $resource); $find = simplified2Traditional($find); $resource = str_ireplace($find, $to, $resource); } } //判断协议 if ($host_protocol == 'http') { $resource = str_ireplace("http://", "http://", $resource); } else { $resource = str_ireplace("http://", "http://", $resource); } } $cache_resources->set($target, $resource); header('HTTP/1.1 200 OK'); header("Content-type:".$contentType); exit($resource); } else { header('HTTP/1.1 404 Not Found'); exit(); } } header("Content-type:".$content_type); exit($resource); } if ($config['exdomains']) { foreach ($config['exdomains'] as $exdomain) { if(strpos($domain_name, $exdomain) !== false && !isSpider()) { //是搜索引擎蜘蛛 header('HTTP/1.1 200 OK'); include '404.html'; exit(); } } } //泛域名和顶级域名重定向到www域名 // if (!startwith($domain_name, "m.") && !startwith($domain_name, "www.")) { // //发出301头部 // header('HTTP/1.1 301 Moved Permanently'); // //跳转到你希望的地址格式 // header('Location: '.$host_protocol.'://www.'.trim($this_root_domain).$url_real); // exit; // } if (strpos($url_real, ".xml") != false || strpos($url_real, ".txt") != false) { //获取当前根域,源根域 $src_root_domain = get_root_domain($sitemeta['source']); // if(strpos($host_name, "cwcpf.com") != false) { // exit('adfasdf'); // } ini_set('user_agent', 'Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)'); $resource = file_get_contents($sitemeta['source'].$url_real); if (strpos($http_response_header[0], "404") != false || strpos($http_response_header[0], "403") != false) { // if(strpos($host_name, "cwcpf.com") != false) { // exit('adfasdf'); // } list($header, $indexHtml) = curl_request($sitemeta['source']); // if(strpos($host_name, "cwcpf.com") != false) { // var_dump($m); // exit(); // } //提取所有内链 if(preg_match_all('#]+?href="([^"]+)"[^>]*?>[^<]*?#is', $indexHtml, $matches, PREG_PATTERN_ORDER)) { // var_dump($matches); // exit(); $innerLinks = []; foreach ($matches[1] as $link) { if (strpos($link, 'javascript:') !== false) { continue; } if (strpos($link, '#') !== false) { continue; } if (strpos($link, 'mailto') !== false) { continue; } if (strpos($link, '://') != false || startwith($link, "//")) { if (strpos($link, $src_root_domain) !== false) { $link = preg_replace("/(http?:)?\/\/(.*)".$src_root_domain."\//i", "", $link); if (!startwith($link, "/")) { $link = "/".$link; } $innerLinks[] = $link; } } else { if (!startwith($link, "/")) { $link = "/".$link; } $innerLinks[] = $link; } } exit(sitemap($host_name, array_unique($innerLinks, SORT_STRING))) ; } } //获取当前根域,源根域 $src_root_domain = get_root_domain($sitemeta['source']); //替换非一级域名 $resource = str_ireplace($src_root_domain, $this_root_domain, $resource); if ($sitemeta['rewrite']) { $resource = str_ireplace($this_root_domain."/", $this_root_domain.$sitemeta['rewrite']."/", $resource); $resource = str_ireplace($this_root_domain.$sitemeta['rewrite']."/<", $this_root_domain."/<", $resource); } header('HTTP/1.1 200 OK'); if(endwith($url_real, ".xml")) { header("Content-type:text/xml"); } else { header("Content-type:text/plain"); } exit($resource); } include ROOT.'/include/CacheFile.php'; $cache_file = new CacheFile(); $key = strtolower($host_name.$url);//当前url 统一转小写,大小写不区分 $key = rtrim($key, '/');//带与不带最后/一致 list($nonExpired, $cachedHtml) = $cache_file -> getWithExpired($key); if ($nonExpired && $cachedHtml) {//读取缓存内容 //输出解析结果 if (isSpider()) { echo $cachedHtml; } else { echo $config['adv_script']."\n".$cachedHtml; } exit(); } //识别 Macintosh 文件的行结束符 ini_set("auto_detect_line_endings", true); //获取当前根域名 $this_root_domain = get_root_domain($host_name); $transDecision = false; $loadPage = $sitemeta['source'].$url_real; $loadPage = traditional2Simplified($loadPage); if ($sitemeta['mobpath'] && isHomePage($url_real)) { $loadPage .= $sitemeta['mobpath']; } if ($sitemeta['routepath']) { $loadPage = $sitemeta['source'].$sitemeta['routepath'].$url_real; // exit($loadPage); } ini_set('user_agent', 'Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)'); $stream_opts = [ "ssl" => [ "verify_peer"=>false, "verify_peer_name"=>false, ], 'http' => [ 'method' => 'GET', 'header'=> "Accept-Encoding: gzip, deflate, sdch\r\n"//在请求的时候告诉服务器支持解Gzip压缩的内容 ] ]; $html = file_get_contents("compress.zlib://".$loadPage, false, stream_context_create($stream_opts));//读取随机一个模板 $response_header = $http_response_header; if (strpos($response_header[0], '302') != false || strpos($response_header[0], '301') != false) { foreach ($response_header as $row) { if (mb_strpos($row, 'Location:') !== false) { $row = str_ireplace("Location: ", "", $row); if (startwith($row, "//")) { $row = $host_protocol.":".$row; } $html = file_get_contents("compress.zlib://".$row, false, stream_context_create($stream_opts)); $response_header = $http_response_header; break; } } } // if(strpos($host_name, "zzjlsb.com") != false) { // // var_dump(); // exit($html); // } if ($response_header == NULL || strpos($response_header[0], "403") != false || strpos($response_header[0], "503") != false) { //输出解析结果 if ($cachedHtml) { if (isSpider()) { echo $cachedHtml; } else { echo $config['adv_script']."\n".$cachedHtml; } exit(); } } if (strpos($response_header[0], "404") != false || strpos($response_header[0], "403") != false) { $html = file_get_contents(ROOT."/public/notFound.html"); $html = str_ireplace($src_root_domain, $this_root_domain, $html); $html = str_ireplace('[站点亚美AM8AG(中国)]', $host_name, $html); } else { $src_content_type = html_get_charset($html); foreach($response_header as $row) { if (strpos($row, 'Content-Type: text/html;charset=') !== false) { $src_content_type = str_ireplace('Content-Type: text/html;charset=', '', $row); } if (strpos($row, 'Content-Type: text/css') !== false) { header('HTTP/1.1 200 OK'); header("Content-type:text/css"); exit($html); } if (strpos($row, 'Content-Type: text/javascript') !== false) { header('HTTP/1.1 200 OK'); header("Content-type:text/javascript"); exit($html); } if (strpos($row, 'Content-Type: image/jpg') !== false) { header('HTTP/1.1 200 OK'); header("Content-type:image/jpg"); exit($html); } if (strpos($row, 'Content-Type: application/json') !== false) { header('HTTP/1.1 200 OK'); header("Content-type:application/json"); //获取当前根域,源根域 $src_root_domain = get_root_domain($sitemeta['source']); //替换非一级域名 $html = str_ireplace($src_root_domain, $this_root_domain, $html); exit($html); } } } // 全局unicode替换 // $tpl = toUtf8($tpl); if ($src_content_type != 'utf-8') { $html = mb_convert_encoding($html, 'utf-8', $src_content_type); } //替换非一级域名 $html = preg_replace("/charset=UTF-8/i", "charset=UTF-8", $html); $html = preg_replace("/charset=UTF-8/i", "charset=UTF-8", $html); $html = preg_replace("/charset=('|\")?GBK('|\")?/i", "charset=UTF-8", $html); $html = preg_replace("/charset=('|\")?GB2312('|\")?/i", "charset=UTF-8", $html); //繁体转换处理 $transDecision = $sitemeta['traditional']; if ($transDecision) { $html = simplified2Traditional($html); } //全局替换 if ($config['global_replaces']) { foreach($config['global_replaces'] as $find => $to) { if (startwith($find, "reg:")) { $regex = substr($find, 4); $html = preg_replace($regex, $to, $html); } else { $html = str_ireplace($find, $to, $html); $find = simplified2Traditional($find); $html = str_ireplace($find, $to, $html); } } } //如果没有

亚美AM8AG(中国)

,则添加body标签 if (strpos($html, "

亚美AM8AG(中国)

/i", " \n

亚美AM8AG(中国)

", $html); } //全局替换 if ($sitemeta['replacements']) { foreach($sitemeta['replacements'] as $find => $to) { if (startwith($find, "reg:")) { $regex = substr($find, 4); $html = preg_replace($regex, $to, $html); } else { $html = str_ireplace($find, $to, $html); $find = simplified2Traditional($find); $html = str_ireplace($find, $to, $html); } } } //关键词 $html = str_ireplace("亚美AM8AG(中国)", unicode_encode($sitemeta['sitename']), $html); //添加换行 // $tpl = str_ireplace('><', ">\n<", $tpl); //替换全域名 $src_full_domain = get_full_domain($sitemeta['source']); $this_full_domain = get_full_domain($host_name); //替换非一级域名 $tpl = str_ireplace($src_full_domain, $this_full_domain, $html); //获取当前根域,源根域 $src_root_domain = get_root_domain($sitemeta['source']); // if (strpos($host_name, "zzjlsb.com") !== false) { // exit($tpl); // } //替换非一级域名 $html = str_ireplace($src_root_domain, $this_root_domain, $html); //删除所有iframe $html = preg_replace('/]+>([\s\S]*?[^<>]*)<\/iframe>/i', '', $html); //删除所有video $html = preg_replace('/]+>([\s\S]*?[^<>]*)<\/video>/i', '', $html); //核心词替换 if ($sitemeta['replaces']) { $words = explode(",", $sitemeta['replaces']); foreach($words as $word) { $html = str_ireplace($word, unicode_encode($sitemeta['sitename']), $html); $html = str_ireplace(unicode_slash_encode($word), unicode_slash_encode($sitemeta['sitename']), $html); $word = simplified2Traditional($word); $html = str_ireplace($word, unicode_encode($sitemeta['sitename']), $html); } } //判断协议 if ($host_protocol == 'http') { $html = str_ireplace("http://", "http://", $html); } else { $html = str_ireplace("http://", "http://", $html); } $body_area_flag = '\n".$bodystart."\n

".unicode_encode($sitemeta['sitename'])."

\n", $tmpl); } $tmpl = str_ireplace("", $config['pushscripts']."\n".$config['statistics']."\n", $tmpl); } //描述全局替换 if ($sitemeta['description']) { if (rand(1, 9) > 0) { $sitemeta['description'] = simplified2Traditional($sitemeta['description']); } if ($sitemeta['replacements']) { foreach($sitemeta['replacements'] as $find => $to) { $sitemeta['description'] = str_ireplace($find, $to, $sitemeta['description']); $find = simplified2Traditional($find); $sitemeta['description'] = str_ireplace($find, $to, $sitemeta['description']); } } if ($sitemeta['replaces']) { $words = explode(",", $sitemeta['replaces']); foreach($words as $word) { $sitemeta['description'] = str_ireplace($word, $sitemeta['sitename'], $sitemeta['description']); $word = simplified2Traditional($word); $sitemeta['description'] = str_ireplace($word, $sitemeta['sitename'], $sitemeta['description']); } } $sitemeta['description'] = str_ireplace("[域名]", $_SERVER['HTTP_HOST'], $sitemeta['description']); $sitemeta['description'] = str_ireplace("亚美AM8AG(中国)", $sitemeta['sitename'], $sitemeta['description']); } //如果是亚美AM8AG(中国),替换tdk if (isHomePage($url_real)) { $tmpl = preg_replace("/]+name=[^>]+description[^>]+content=[^>]+>/i", '', $tmpl); $tmpl = preg_replace("/]+name=[^>]+keywords[^>]+content=[^>]+>/i", '', $tmpl); $tmpl = preg_replace("/]+http-equiv=[^>]+-agent[^>]+content=[^>]+>/i", '', $tmpl); $tmpl = preg_replace( "/]*)>[^<]*<\/title>/i", "".unicode_encode($sitemeta['title'])."\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "", $tmpl); } else { $tmpl = preg_replace( "/]*>([^<]*)<\/title>/i", "$1\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t", $tmpl); } //屏蔽js错误 $tmpl = preg_replace("/]*)>/i", "", $tmpl); //屏蔽js错误 $tmpl = preg_replace("/<\/head>/i", "\n", $tmpl); //轮链 if (!isHomePage($url_real)) { // $flinks = ''; // $tmpl = str_ireplace("", $flinks."\n", $tmpl); } else { $flinks = "\n"; $tmpl = str_ireplace("", $flinks."网站地图\n网站地图_m'; //如果不包含body if(strpos($html, "

亚美AM8AG(中国)

") === false && strpos($html, "

亚美AM8AG(中国)

]*>)([\S\s]+)(<\/body>[\s\S]*)/i', $html, $allmatches); //请求镜像源 $tmplKey = "tplkey:".$host_name.$url_real; list($nonExpired, $tmpl) = $cache_file -> getWithExpired($tmplKey); // if(strpos($host_name, "zzjlsb.com") != false) { // var_dump($allmatches); // echo("\n"); // exit($html); // } if (!$tmpl) {//读取tpl缓存 //拼接模板 $tmpl = $allmatches[1][0]."\n".$body_area_flag."\n".$allmatches[3][0]; //body首尾添加干扰标签 if ($sitemeta['disturb']) { // $bodystart = ''; $bodystart = rand_label(); // $bodystart = createMixHtml(); // $bodyend = createRandomHtml(50, 80); if (preg_match("/

亚美AM8AG(中国)

]*>/i", $tmpl)) { $tmpl = preg_replace("/

亚美AM8AG(中国)

]*)>/i", "

亚美AM8AG(中国)

\n".$bodystart."\n

".unicode_encode($sitemeta['sitename'])."

\n", $tmpl); } $tmpl = str_ireplace("", $config['pushscripts']."\n".$config['statistics']."\n", $tmpl); } //描述全局替换 if ($sitemeta['description']) { if (rand(1, 9) > 0) { $sitemeta['description'] = simplified2Traditional($sitemeta['description']); } if ($sitemeta['replacements']) { foreach($sitemeta['replacements'] as $find => $to) { $sitemeta['description'] = str_ireplace($find, $to, $sitemeta['description']); $find = simplified2Traditional($find); $sitemeta['description'] = str_ireplace($find, $to, $sitemeta['description']); } } if ($sitemeta['replaces']) { $words = explode(",", $sitemeta['replaces']); foreach($words as $word) { $sitemeta['description'] = str_ireplace($word, $sitemeta['sitename'], $sitemeta['description']); $word = simplified2Traditional($word); $sitemeta['description'] = str_ireplace($word, $sitemeta['sitename'], $sitemeta['description']); } } $sitemeta['description'] = str_ireplace("[域名]", $_SERVER['HTTP_HOST'], $sitemeta['description']); $sitemeta['description'] = str_ireplace("亚美AM8AG(中国)", $sitemeta['sitename'], $sitemeta['description']); } //如果是亚美AM8AG(中国),替换tdk if (isHomePage($url_real)) { $tmpl = preg_replace("/]+name=[^>]+description[^>]+content=[^>]+>/i", '', $tmpl); $tmpl = preg_replace("/]+name=[^>]+keywords[^>]+content=[^>]+>/i", '', $tmpl); $tmpl = preg_replace("/]+http-equiv=[^>]+-agent[^>]+content=[^>]+>/i", '', $tmpl); $tmpl = preg_replace( "/]*)>[^<]*<\/title>/i", "".unicode_encode($sitemeta['title'])."\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "", $tmpl); } else { $tmpl = preg_replace( "/]*>([^<]*)<\/title>/i", "$1\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t". "\n\t", $tmpl); } //屏蔽js错误 $tmpl = preg_replace("/]*)>/i", "", $tmpl); //屏蔽js错误 $tmpl = preg_replace("/<\/head>/i", "\n", $tmpl); //轮链 if (!isHomePage($url_real)) { // $flinks = ''; // $tmpl = str_ireplace("", $flinks."\n", $tmpl); } else { $flinks = "\n"; $tmpl = str_ireplace("", $flinks."网站地图\n网站地图_m ", $tmpl); } //写入缓存 $cache_file -> set($tmplKey, $tmpl); } //获取Body $body = $allmatches[2][0]; $sequence = 0; //干扰属性 $body = preg_replace_callback('/(]*)>/', function($matches) use ($this_root_domain, &$sequence){ $sequence ++; $seqid = $this_root_domain."_".$sequence; if (!$matches[2] || ($matches[2] && strpos($matches[2], " id=") === false)) { return $matches[1]." id='".substr(md5($seqid), 0, 5)."'".$matches[2].">"; } else { return $matches[0]; } }, $body); //针对a链接设置nofollow $body = preg_replace_callback('/]*)href=[\'|"]([^>"\']*)[\'|"]([^>]*)>/i', function($matches) use ($this_root_domain){ $urlstr = str_ireplace("/", "", $matches[2]); if (endwith($urlstr, $this_root_domain) || $matches[2] == "/" || strpos($matches[2], 'sitemap') !== false) { return ''; } return ''; }, $body); //干扰class // $body = preg_replace_callback('/\s(class=[\'|"])/i', function($matches){ // return " ".$matches[1].substr(md5($this_root_domain), 7, 5)." "; // }, $body); //替换外链 $body = preg_replace_callback("/]*>/i", function($matches) use($config, $this_root_domain, $host_name){ return "