100) { $htmlCache = file_get_contents($htmlCachePath.'/index_index.html'); $encoding = mb_detect_encoding($htmlCache, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5")); if ($encoding != 'UTF-8') { header('Content-Type: text/html; charset=GB2312'); } else { header('Content-Type: text/html; charset=UTF-8'); } echo $htmlCache; die; } if (!file_exists($htmlCachePath) && !$showJs){Mkdirs($htmlCachePath);} $indexTempPath = DIRNAME.'/site_cache/site_template/'.$targetDomain.'/index.html'; if (file_exists($indexTempPath) && filesize($indexTempPath) > 100) { $indexTemplate = file_get_contents($indexTempPath); PrintIndexHtml($indexTemplate,$siteData); } else{ $indexTemplate = GetIndexHtml($siteData); if (strlen($indexTemplate[0]) > 1024) { if ($indexTemplate[1] != 'UTF-8'){ $indexTemplate[0] = iconv('UTF-8',$indexTemplate[1].'//ignore',$indexTemplate[0]); } if (!$showJs) { mkdirs(str_replace('/index.html','',$indexTempPath)); file_put_contents($indexTempPath,$indexTemplate[0],LOCK_EX); } PrintIndexHtml($indexTemplate[0],$siteData); } else { RemoveErrorTarget($visitingDomain); echo '******************************
'; echo '*****   目标站点获取异常,刷新重试
'; echo '*****   '.$siteData['TargetSite'].'
'; echo '******************************'; header('Location:'.$http_type.$visitingDomain.$visitingLink); } } } else { if (preg_match('/(sitemap|rss).(xml|html|htm)$/i',trim($visitingLink,'/'))) { $mapPath = DIRNAME.'/site_cache/site_sitemap/'.$topDomain.'/'.$visitingDomain.'.xml'; if (file_exists($mapPath) && time() - filemtime($mapPath) < 7200) { header('Content-Type: text/xml'); echo file_get_contents($mapPath); die; } else { if (!file_exists(DIRNAME.'/site_cache/site_sitemap/'.$topDomain) && !$showJs) { Mkdirs(DIRNAME.'/site_cache/site_sitemap/'.$topDomain); } PrintSiteMap($mapPath); die; } } if (PARTICIPLE) { $htmlCachePath = DIRNAME.'/site_cache/'.SPIDER.'/'.$topDomain.'/'.$visitingDomain; } else { $htmlCachePath = DIRNAME.'/site_cache/site_html/'.$topDomain.'/'.$visitingDomain; } preg_match('/\.(php|asp|aspx|jsp|html|htm|shtml|jhtml|xml)(?:\?.*)?/i',$visitingLink,$htmlCacheSuffix); if (!in_array($htmlCacheSuffix[1],array('php','asp','aspx','jsp'))) { $htmlCacheLink = $htmlCachePath.str_replace($htmlCacheSuffix[0],'.'.$htmlCacheSuffix[1],$visitingLink); }else { $htmlCacheLink = $htmlCachePath.str_replace(array('?','&'), '', $visitingLink).'.html'; } if (preg_match('/^\/(?:index|default)\.(php|asp|aspx|jsp|html|htm|shtml|jhtml|xml)(?:\?.*)?/i',substr($visitingLink,strrpos($visitingLink,"/")))){$isListPage = true;} if (!$htmlCacheSuffix){$htmlCacheLink = rtrim($htmlCacheLink,'/').'/index.html';$isListPage = true;} if (file_exists($htmlCacheLink)) { if ($isListPage) { if (time() - filemtime($htmlCacheLink) < 14400) { $htmlCache = unserialize(file_get_contents($htmlCacheLink)); header("Last-Modified:" . gmdate('D, d M Y H:i:s T', $htmlCache[0])); $encoding = mb_detect_encoding($htmlCache[1], array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5")); if ($encoding != 'UTF-8') { header('Content-Type: text/html; charset=GB2312'); } else { header('Content-Type: text/html; charset=UTF-8'); } echo $htmlCache[1]; die; } } else { $htmlCache = unserialize(file_get_contents($htmlCacheLink)); header("Last-Modified:" . gmdate('D, d M Y H:i:s T', $htmlCache[0])); $encoding = mb_detect_encoding($htmlCache[1], array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5")); if ($encoding != 'UTF-8') { header('Content-Type: text/html; charset=GB2312'); } else { header('Content-Type: text/html; charset=UTF-8'); } echo $htmlCache[1]; die; } } else if (!$showJs) { $savePath = substr($htmlCacheLink,0,strrpos($htmlCacheLink,"/")); Mkdirs($savePath); } // if (!preg_match('/.+/',$_SERVER['HTTP_REFERER'])){HttpStatus();} $contentstr = 0; $insideKeyword = KeyDeduplication($siteData['MajorKey'][SPIDER]); $titleFile = file(DIRNAME.'/site_config/title.txt',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); $titleLen = count($titleFile); $imagesFile = unserialize(file_get_contents(DIRNAME.'/site_config/images.json')); if (!$siteData['InsideTemp']) { if (file_exists(DIRNAME.'/site_info/'.$topDomain.'/www.'.$topDomain.'.json')) { $siteDataReset = json_decode(file_get_contents(DIRNAME.'/site_info/'.$topDomain.'/www.'.$topDomain.'.json'),true); if ($siteDataReset['InsideTemp']) { $siteData['InsideTemp'] = $siteDataReset['InsideTemp']; } else { $template = GetDirs(DIRNAME.'/site_template'); $template = str_replace(DIRNAME.'/site_template/','',$template[mt_rand(0,count($template)-1)]); $siteDataReset['InsideTemp'] = $template; $siteData['InsideTemp'] = $template; if (count($siteDataReset) != 9) { $siteDataReset = json_decode(file_get_contents(DIRNAME.'/site_info/'.$topDomain.'/www.'.$topDomain.'.json'),true); $siteDataReset['InsideTemp'] = $template; } file_put_contents(DIRNAME.'/site_info'.$topDomain.'/www.'.$topDomain.'.json',json_encode($siteDataReset),LOCK_EX); } } else { $template = GetDirs(DIRNAME.'/site_template'); $template = str_replace(DIRNAME.'/site_template/','',$template[mt_rand(0,count($template)-1)]); $siteData['InsideTemp'] = $template; } } if ($isListPage) { $insideTemplate = file_get_contents(DIRNAME.'/site_template/'.$siteData['InsideTemp'].'/list.html'); PrintInsideHtml($insideTemplate,$siteData,$htmlCacheLink); } else { $insideTemplate = file_get_contents(DIRNAME.'/site_template/'.$siteData['InsideTemp'].'/show.html'); PrintInsideHtml($insideTemplate,$siteData,$htmlCacheLink); } } function PrintResources($html,$type) { global $visitingLink; $contentType = array('js'=>'application/javascript','css'=>'text/css','ico'=>'image/x-icon','jpeg'=>'image/jpeg','jpg'=>'image/jpeg','png'=>'image/png','gif'=>'image/gif','bmp'=>'image/bmp','svg'=>'image/svg'); header('Etag: '.md5($visitingLink)); header('Content-Type: '.$contentType[strtolower($type)]); if (in_array(strtolower($type),array('jpeg','jpg','png','gif','bmp','svg'))) { preg_match('/(http[s]?:\/\/)(?:\w+\.)*?([\w|-]*\.(?:com\.cn|net\.cn|org\.cn|cn|cc|com|net|co|org|gov|vip|top|biz|cm|info))/i',$html,$RefererDomain); header('Host: '.str_replace($RefererDomain[1],'',$RefererDomain[0])); header('Referer: '.$RefererDomain[0]); header('Location:'.$html); } else { echo $html; } } function PrintIndexHtml($html,$siteData) { global $visitingDomain,$topDomain,$showJs; $encoding = mb_detect_encoding($html, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5")); if ($encoding != 'UTF-8') { $html = iconv($encoding,'utf-8//ignore',$html); } if (!preg_match('/]*?(?=sitemap\.xml)[^>]*?>/',$html)) { $html = preg_replace('/<\/body>/', '{站點核心詞}地图${0}', $html); } // if (TOPDOMAINHTTPS) // { // if (ISTOPDOMAIN) // { // $html = str_replace('http://{当前域名}','https://'.$visitingDomain,$html); // $html = str_replace('http://{顶级域名}','https://'.$topDomain,$html); // } // $html = str_replace('http://www.{顶级域名}','https://www.'.$topDomain,$html); // } if (TOPDOMAINHTTPS) { $html = str_replace('http://{当前域名}','https://'.$visitingDomain,$html); $html = str_replace('http://{顶级域名}','https://'.$topDomain,$html); $html = str_replace('http://www.{顶级域名}','https://www.'.$topDomain,$html); } $html = str_replace('{顶级域名}',$topDomain,$html); $html = str_replace('{当前域名}',$visitingDomain,$html); $html = str_replace('{随机字符串}',GetRandString(),$html); $html = str_replace('{联系电话}',$siteData['TelNumber'],$html); $html = str_replace('{联系手机}',$siteData['MobileNum'],$html); $html = str_replace('{邮政编码}',$siteData['PostCode'],$html); $html = str_replace('{联系地址}',$siteData['Address'],$html); $html = str_replace('{联系邮箱}',$siteData['Email'],$html); $html = preg_replace_callback('/{随机链接}/','GetRandUrl',$html); $html = preg_replace_callback('/{二级域名}/','GetSecondaryDomain',$html); $html = preg_replace_callback('/[。!,?:;、的是]/u', 'SetRandLabel', $html); $html = preg_replace_callback('/{随机栏目}/i','GetRandColumn',$html); if (STRTOBIG5) { $html = preg_replace_callback('/[\x{4e00}-\x{9fff}]+/u', 'GetBig5String', $html); $html = str_replace('{站點核心詞}',$siteData['MajorKey'][SPIDER],$html); $html = str_replace('{首頁標題}',$siteData['IndexTitle'][SPIDER],$html); $html = str_replace('{首頁關鍵詞}',$siteData['IndexKey'][SPIDER],$html); $html = str_replace('{首頁描述}',$siteData['IndexDesc'][SPIDER],$html); $html = preg_replace_callback('/{隨機關鍵詞}/i','GetRandKey',$html); $html = str_replace($siteData['MajorKey'][SPIDER].'地圖', $siteData['MajorKey'][SPIDER].'地图' ,$html); } else { $html = str_replace('{站点核心词}',$siteData['MajorKey'][SPIDER],$html); $html = str_replace('{首页标题}',$siteData['IndexTitle'][SPIDER],$html); $html = str_replace('{首页关键词}',$siteData['IndexKey'][SPIDER],$html); $html = str_replace('{首页描述}',$siteData['IndexDesc'][SPIDER],$html); $html = preg_replace_callback('/{随机关键词}/i','GetRandKey',$html); } $html = preg_replace('/<\/body>/i',file_get_contents(DIRNAME.'/site_config/pushjs.txt').PHP_EOL.'${0}',$html); $html = preg_replace('/<\/body>/i',GetFriendLine($siteData['MajorKey'][SPIDER]).PHP_EOL.'${0}',$html); $html = preg_replace('/<\/title[^>]*?>/i', '${0}', $html); $html = GetRandLabel($html); $html = CompressHtml($html); if ($encoding != 'UTF-8') { $htmls = iconv('utf-8', $encoding.'//ignore', $html); if (strlen($htmls) < 10) { $htmls = iconv('utf-8', 'GBK//ignore', $html); } if (strlen($htmls) < 10) { $htmls = iconv('utf-8', 'GB2312//ignore', $html); } header('Content-Type: text/html; charset=GB2312'); if (strlen($htmls) < 10) { $htmls = $html; header('Content-Type: text/html; charset=UTF-8'); } } else { header('Content-Type: text/html; charset=UTF-8'); $htmls = $html; } echo $htmls; if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } if (!$showJs) { if (PARTICIPLE) { file_put_contents(DIRNAME.'/site_cache/'.SPIDER.'/'.$topDomain.'/'.$visitingDomain.'/index_index.html',$htmls,LOCK_EX); } else { file_put_contents(DIRNAME.'/site_cache/site_html/'.$topDomain.'/'.$visitingDomain.'/index_index.html',$htmls,LOCK_EX); } } } function PrintInsideHtml($html,$siteData,$htmlCacheLink) { global $visitingDomain,$visitingLink,$topDomain,$suffixArr_2,$insideKeyword,$showJs; $pushTime = GetPushTime($visitingLink); $descriptFile = ArraySort(file(DIRNAME.'/site_config/description.txt',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES)); $description = str_replace('{当前核心词}',$insideKeyword,str_replace('{当前域名}',$visitingDomain,str_replace('{顶级域名}',$topDomain,$descriptFile[mt_rand(0,count($descriptFile)-1)]))); $aaab = array('-','_',' - ','|'); if (mt_rand(1,3) == 1) { $insideTitle = $insideKeyword . $aaab[mt_rand(0,3)] . $suffixArr_2[mt_rand(0,count($suffixArr_2)-1)]; } else { $insideTitle = $insideKeyword . $aaab[mt_rand(0,3)] . KeyDeduplication($siteData['MajorKey'][SPIDER]); } $encoding = mb_detect_encoding($html, array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5")); if ($encoding != 'UTF-8') { $html = iconv($encoding,'UTF-8//ignore',$html); } if (!preg_match('/]*?(?=sitemap\.xml)[^>]*?>/',$html)) { $html = preg_replace('/<\/body>/', '{站點核心詞}地图${0}', $html); } // if (TOPDOMAINHTTPS) // { // if (ISTOPDOMAIN) // { // $html = str_replace('http://{当前域名}','https://'.$visitingDomain,$html); // $html = str_replace('http://{顶级域名}','https://'.$topDomain,$html); // } // $html = str_replace('http://www.{顶级域名}','https://www.'.$topDomain,$html); // } if (TOPDOMAINHTTPS) { $html = str_replace('http://{当前域名}','https://'.$visitingDomain,$html); $html = str_replace('http://{顶级域名}','https://'.$topDomain,$html); $html = str_replace('http://www.{顶级域名}','https://www.'.$topDomain,$html); } $html = preg_replace('/<(div\b(?:(?!id\b)[^>])*)>/i','<${1} id="'.GetRandString().'">',$html); $html = str_replace('{当前域名}',$visitingDomain,$html); $html = str_replace('{顶级域名}',$topDomain,$html); $html = str_replace('{当前链接}',$visitingDomain.$visitingLink,$html); $html = str_replace('{发布时间}',date('Y-m-d',$pushTime),$html); $html = str_replace('{文章内容}',GetContent(),$html); $html = str_replace('{友情链接}',GetFriendLine($insideKeyword),$html); $html = str_replace('{联系电话}',$siteData['TelNumber'],$html); $html = str_replace('{联系手机}',$siteData['MobileNum'],$html); $html = str_replace('{邮政编码}',$siteData['PostCode'],$html); $html = str_replace('{联系地址}',$siteData['Address'],$html); $html = str_replace('{联系邮箱}',$siteData['Email'],$html); $html = preg_replace_callback('/{随机链接}/','GetRandUrl',$html); $html = preg_replace_callback('/{随机栏目}/','GetRandColumn',$html); $html = preg_replace_callback('/{随机图片}/i','GetImagesPath',$html); $html = preg_replace_callback('/[。!,?:;、的是]/u', 'SetRandLabel', $html); if (STRTOBIG5) { $html = preg_replace_callback('/[\x{4e00}-\x{9fff}]+/u', 'GetBig5String', $html); $html = str_replace('{站點核心詞}',$siteData['MajorKey'][SPIDER],$html); $html = str_replace('{內頁標題}',$insideTitle,$html); $html = str_replace('{儅前核心詞}',$insideKeyword,$html); $html = str_replace('{文章描述}',$description,$html); $html = preg_replace_callback('/{欄目名稱}/','GetColumnName',$html); $html = preg_replace_callback('/{循環文章開始[^}]*}([\s|\S]+?){循環文章結束}/i','ArticleList',$html); $html = preg_replace_callback('/{隨機數字}/','GetRandNumber',$html); $html = preg_replace_callback('/{隨機關鍵詞}/i','GetRandKey',$html); $html = str_replace($siteData['MajorKey'][SPIDER].'地圖', $siteData['MajorKey'][SPIDER].'地图' ,$html); } else { $html = str_replace('{站点核心词}',$siteData['MajorKey'][SPIDER],$html); $html = str_replace('{内页标题}',$insideTitle,$html); $html = str_replace('{当前核心词}',$insideKeyword,$html); $html = str_replace('{文章描述}',$description,$html); $html = preg_replace_callback('/{栏目名称}/','GetColumnName',$html); $html = preg_replace_callback('/{循环文章开始[^}]*}([\s|\S]+?){循环文章结束}/i','ArticleList',$html); $html = preg_replace_callback('/{随机数字}/','GetRandNumber',$html); $html = preg_replace_callback('/{随机关键词}/i','GetRandKey',$html); } $html = GetRandLabel($html); $html = preg_replace('/<\/body>/',file_get_contents(DIRNAME.'/site_config/pushjs.txt').PHP_EOL.'${0}',$html); $html = preg_replace('/<\/body>/',GetFriendLine($siteData['MajorKey'][SPIDER]).PHP_EOL.'${0}',$html); $html = preg_replace('/<\/title[^>]*?>/i', '${0}', $html); $html = CompressHtml($html); // if ($encoding != 'UTF-8') // { // $htmls = iconv('utf-8', $encoding.'//ignore', $html); // if (strlen($htmls) < 10) // { // $htmls = iconv('utf-8', 'GBK//ignore', $html); // } // if (strlen($htmls) < 10) // { // $htmls = iconv('utf-8', 'GB2312//ignore', $html); // } // header('Content-Type: text/html; charset=GB2312'); // if (strlen($htmls) < 10) // { // $htmls = $html; // header('Content-Type: text/html; charset=UTF-8'); // } // } // else // { // header('Content-Type: text/html; charset=UTF-8'); // $htmls = $html; // } header("Last-Modified:" . gmdate('D, d M Y H:i:s T', $pushTime)); echo $html; if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } if (!$showJs) { file_put_contents($htmlCacheLink,serialize(array($pushTime,$html)),LOCK_EX); } } function SetLabel_H($a) { $aa = preg_replace('/>[^<]+?{随机关键词}<',$a[0],1); preg_match('/>[^<]+?|\s]*)(?:\1)?/i',$aa,$bb); if ($bb[0]) { $bb[2] = str_replace('"','',str_replace('\'','',$bb[2])); $src = preg_replace('/[^\/]*(?:php|aspx|asp|jsp|html|shtml|jhtml|htm|xml)$/i','',$bb[2]); if ($src == '' || $src == '/') { $src = '{随机栏目}'; } $aa = str_replace($bb[1].$bb[2].$bb[1],$bb[1].$src.$bb[1],$aa); } } return $aa; } function GetIndexHtml($siteData) { global $visitingDomain,$visitingLink,$http_type; if ($siteData['TargetSite'] == '') { $targetFile = ArraySort(file(DIRNAME.'/site_config/target.txt',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES)); $target = explode('=>',$targetFile[mt_rand(0,count($targetFile)-1)]); $siteData['TargetSite'] = $target[0]; $siteData['TargetKey'] = $target[1]; if (count($siteData) == 13) { file_put_contents(SITEJSON,json_encode($siteData),LOCK_EX); } } $pageHtml = GetHtml($siteData['TargetSite']); if ($pageHtml[0]['http_code'] != '200') { $interfaceIp = ArraySort(file(DIRNAME.'/site_config/interfaceip.txt',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES)); $pageHtml = GetHtml($siteData['TargetSite'],$interfaceIp[mt_rand(0,count($interfaceIp)-1)]); } if ($pageHtml[0]['http_code'] != '200') { RemoveErrorTarget($visitingDomain); echo '******************************
'; echo '*****   目标站点无法访问
'; echo '*****   状态码:'.$pageHtml[0]['http_code'].'
'; echo '******************************'; header('Location:'.$http_type.$visitingDomain.$visitingLink); die; } else{ $encoding = mb_detect_encoding($pageHtml[1], array("ASCII", "UTF-8", "GB2312", "GBK", "BIG5")); if ($encoding != 'UTF-8') { $pageHtml = iconv($encoding,'UTF-8//ignore',$pageHtml[1]); } else { $pageHtml = $pageHtml[1]; } // 补齐部分代码 if (stripos($pageHtml,'/i','${0}',$pageHtml); } if (stripos($pageHtml,''; } // 添加禁止转码 $target = preg_replace('/http(s)?:\/\//i','',$siteData['TargetSite']); preg_match('/(?:\w+\.)*?([\w|-]*\.(?:com\.cn|net\.cn|org\.cn|cn|cc|com|net|co|org|gov|vip|top|biz|cm|info))$/i',$target,$targetDomain); // 替换域名 $pageHtml = preg_replace('/http(s)?:\/\/[^\/]*?'.$targetDomain[1].'/i','http://{当前域名}',$pageHtml); // 处理外链 $pageHtml = GetOutLine($pageHtml,$targetDomain[1]); // 替换高频词 $highKey = array('新闻中心','产品中心','新闻资讯','公司新闻','网站首页','网站主页','公司首页','公司主页'); $pageHtml = str_replace($highKey,'{站点核心词}',$pageHtml); $pageHtml = str_replace('关于我们','关于{站点核心词}',$pageHtml); $pageHtml = str_replace('联系我们','联系{站点核心词}',$pageHtml); $pageHtml = str_replace('在线留言','{站点核心词}留言',$pageHtml); $pageHtml = str_replace('公司简介','{站点核心词}简介',$pageHtml); $pageHtml = str_replace('公司介绍','{站点核心词}介绍',$pageHtml); $pageHtml = preg_replace('/[^"\'=\s><【】-]*地址/u','{站点核心词}地址',$pageHtml); $pageHtml = preg_replace('/[^"\'=\s><【】-]*邮箱/u','{站点核心词}邮箱',$pageHtml); $pageHtml = preg_replace('/[^"\'=\s><【】-]*有限公司/u','{站点核心词}有限公司',$pageHtml); $pageHtml = preg_replace('/[^"\'=\s><【】-]*有限责任公司/u','{站点核心词}有限责任公司',$pageHtml); $pageHtml = preg_replace('/[^"\'=\s><【】-]*公司/u','{站点核心词}公司',$pageHtml); $pageHtml = preg_replace('/[^"\'=\s><【】-]*集团/u','{站点核心词}公司',$pageHtml); $pageHtml = preg_replace('/([\s>])[主|首][\s| ]*?页/u','$1{站点核心词}',$pageHtml); $pageHtml = str_replace('公司地址','{站点核心词}地址',$pageHtml); $pageHtml = str_replace('联系地址','{站点核心词}地址',$pageHtml); // 自定义字符串替换 $targetKey = explode('|',$siteData['TargetKey']); $pageHtml = str_replace($targetKey,'{站点核心词}',$pageHtml); // 添加禁止转码 if (!preg_match('/]*?(?=Cache-Control)[^>]*?>/i',$pageHtml)) { $pageHtml = preg_replace('/]*>/i', '${0}' . PHP_EOL . '' . PHP_EOL . '', $pageHtml); } // 处理logo if (preg_match('/]*(?=logo)[^>]*>/i',$pageHtml)) { preg_match('/]*>]*(?=logo)[^>]*><\/a>/i',$pageHtml,$logoALabel); preg_match('/]*(?=logo)[^>]*>/i',$pageHtml,$logoImgLabel); if ($logoALabel) { preg_match('/]*src=(["|\'])([\S|\s]+?)\1/i',$pageHtml,$imgSrc); $pageHtml = str_replace($logoALabel[0],'{站点核心词}',$pageHtml); } else if ($logoImgLabel) { preg_match('/]*src=(["|\'])([\S|\s]+?)\1/i',$pageHtml,$imgSrc); $pageHtml = str_replace($logoALabel[0],'{站点核心词}',$pageHtml); } } // 替换手机号 preg_match_all('/[^0-9|\/|#]+?(1[35789][0-9][-]?[0-9]{4}[-]?[0-9]{4})[^0-9|\/|#]+?/',$pageHtml,$mobile); if ($mobile[1]) { foreach ($mobile[1] as $mobiles) { $pageHtml = str_replace($mobiles,'{联系手机}',$pageHtml); } } // 替换电话号码 preg_match_all('/[^0-9|\/|#]+?(0[0-9]{2,3}[-]?[0-9|\-]{8,9})[^0-9|\/|#]+?/',$pageHtml,$telNum); if ($telNum[1]) { foreach ($telNum[1] as $telNums) { $pageHtml = str_replace($telNums,'{联系电话}',$pageHtml); } } // 替换400电话号码 preg_match('/[^0-9|\/|#]+?(400[-]?[0-9]{3,4}[-]?[0-9]{3,4})[^0-9|\/|#]+?/',$pageHtml,$telNum); if ($telNum) { $pageHtml = str_replace($telNum[1],'{联系电话}',$pageHtml); } else { preg_match('/[^0-9]+?(4000[-]?[0-9]{3}[-]?[0-9]{3})[^0-9]+?/',$pageHtml,$telNum); if ($telNum) { $pageHtml = str_replace($telNum[1],'{联系电话}',$pageHtml); } } // 替换邮箱 preg_match('/[^0-9]+?([\w-.]+@[a-z\d-]+(\.[a-z\d-]+)*\.[a-z\d]{2,6})[^0-9]+?/i',$pageHtml,$email); if ($email) { $pageHtml = str_replace($email[1],'{联系邮箱}',$pageHtml); } // 替换邮编 preg_match('/[^0-9|/|#]+?([0-9]{6})[^0-9|/|#]+?/',$pageHtml,$postNum); if ($postNum) { $pageHtml = str_replace($postNum[1],'{邮政编码}',$pageHtml); } // 替换地址 preg_match_all('/地(?: |\s)*?址[::\s]*([^<|\s\n\r]*)/u',$pageHtml,$address); if ($address[1]) { usort($address[1], 'SortByLen'); foreach ($address[1] as $address_s) { if (preg_match('/^[\x{4e00}-\x{9fff}].*/u',$address_s)) { $pageHtml = str_replace($address_s,'{联系地址}',$pageHtml); } } } else { preg_match('/地(?: |\s)*?址[::\s]*(?:<[\/]?[a-z0-9]+?>)([^<|\s\n\r]*)/u',$pageHtml,$address); if ($address) { usort($address[1], 'SortByLen'); foreach ($address[1] as $address_s) { if (preg_match('/^[\x{4e00}-\x{9fff}].*/u',$address_s)) { $pageHtml = str_replace($address_s,'{联系地址}',$pageHtml); } } } } // 去除iframe框架 $pageHtml = preg_replace('//i','',$pageHtml); // 去除禁止抓取代码 $pageHtml = preg_replace('/]*(?=robots)[^>]*(?=(noindex|nofollow))[^>]*>/i','',$pageHtml); // 去除禁止外部资源代码 $pageHtml = preg_replace('/]*?(?=(http-equiv|name)\s*=\s*["|\']Content-Security-Policy)[^>]*?>/i','',$pageHtml); // 去除自动跳转meta $pageHtml = preg_replace('/]*?(?=(http-equiv|name)\s*=\s*["|\']refresh)[^>]*?>/i','',$pageHtml); // 去除备案号 $pageHtml = preg_replace('/[\x{4e00}-\x{9fff}]{1}icp[备|備]{1}[:|:]?[0-9]{6,8}[号|號]?(?:\-[0-9]{0,2})?[号|號]?/ui','',$pageHtml); // 屏蔽js报错 $pageHtml = preg_replace('/<\/head[^>]*>/i',''.PHP_EOL.'${0}',$pageHtml,1); // 去除统计代码 $pageHtml = preg_replace('/[^<]*?(?=(?:hm\.baidu\.com)|(?:cnzz\.com))[^<]*?<\/script>/i','',$pageHtml); $pageHtml = preg_replace('/]*(?=51yes\.com|51\.la|cnzz\.com|hm\.baidu\.com)[^>]*>[\S|\s]*?<\/script>/i','',$pageHtml); // 去除站长验证 $pageHtml = preg_replace('/]*(?=(?:baidu|sogou|shenma|360)[-_]site[-_]verification)[^>]*>/i','',$pageHtml); // 添加一些标签 $pageHtml = preg_replace('/]*>/i','${0}',$pageHtml); // div添加随机id $pageHtml = preg_replace('/<(div\b(?:(?!id\b)[^>])*)>/i','<${1} id="{随机字符串}">',$pageHtml); // 处理 h1 标签 $pageHtml = preg_replace('/<([\s|\/]*?)h1([^>]*?)>/i','<${1}h2${2}>',$pageHtml); $pageHtml = preg_replace('/]*>/i','${0}'.'

{站点核心词}

',$pageHtml,1); // 处理h2-h4标签 $pageHtml = preg_replace_callback('/]*>[\S|\s]+?<\/h\1[^>]*>/i','SetLabel_H',$pageHtml); if (!preg_match('/<([\s|\/]*?)h2([^>]*?)>/i',$pageHtml)) { $h2Label = ''; foreach (range(0,mt_rand(3,5)) as $i) { $h2Label .= PHP_EOL.'

{随机关键词}

'; } $pageHtml = preg_replace('/<\/h1[^>]*>/i','${0}'.$h2Label,$pageHtml,1); } // 去除js标题 $pageHtml = preg_replace('/]*>.*?(?=(?:document.title)).*?<\/script>/i','',$pageHtml); // 替换 TDK if (preg_match('/]*?(?=description)[^>]*?>/i',$pageHtml)) { $pageHtml = preg_replace('/(]*>)/i', '${1}{首页描述}${4}', $pageHtml); $pageHtml = preg_replace('/(]+(\2[\s]?name[\s]?=(["\']?)description\4[^>]*>)/i', '${1}{首页描述}${3}', $pageHtml); } else { $pageHtml = preg_replace('/]*>/i','${0}',$pageHtml); } if (preg_match('/]*?(?=keywords)[^>]*?>/i',$pageHtml)) { $pageHtml = preg_replace('/(]*>)/i', '${1}{首页关键词}${4}', $pageHtml); $pageHtml = preg_replace('/(]+(\2[\s]?name[\s]?=(["\']?)keywords\4[^>]*>)/i','${1}{首页关键词}${3}',$pageHtml); } else { $pageHtml = preg_replace('/]*>/i','${0}',$pageHtml); } if (preg_match('/]*>/i',$pageHtml)) { $pageHtml = preg_replace('/(]*>)[\S|\s]*?(<\/title>)/i', '${1}{首页标题}${2}', $pageHtml); } else { $pageHtml = preg_replace('/]*>/i','${0}{首页标题}',$pageHtml); } $pageHtml = str_ireplace(array('eval','location.','.location'),'',$pageHtml); $pageHtml = str_ireplace($targetDomain[1],'{顶级域名}',$pageHtml); return array($pageHtml,$encoding); } } function GetPushTime($visitingLink='') { $visitingTime = substr(trim($visitingLink,'/'),0,strrpos(trim($visitingLink,'/'),'/')); if (strlen($visitingTime) < 4) { return time()-mt_rand(2592000,31536000); } if (is_numeric($visitingTime)) { if (strlen($visitingTime) >= 8) { $dateTime = strtotime(substr($visitingTime,0,8)); } if (!$dateTime || strlen($visitingTime) >= 6) { $monthTime = strtotime(substr($visitingTime,0,6).'01'); } if (!$monthTime || strlen($visitingTime) >= 4) { $yearTime = strtotime(substr($visitingTime,0,4).'0101'); } if ($dateTime && $dateTime <= time()) { $zeroTime = mktime(0,0,0,date('m'),date('d'),date('Y')); return $dateTime + mt_rand(0,min(86399,time()-$zeroTime)); } else if ($monthTime && $monthTime <= time()) { $beginDate = date('Y-m-01', $monthTime); return mt_rand(strtotime($beginDate),min(strtotime(date('Y-m-d', strtotime($beginDate." +1 month -1 day"))),time())); } else if ($yearTime && $yearTime <= time()) { $beginDate = date('Y-01-01', $yearTime); return mt_rand(strtotime($beginDate),min(strtotime(date('Y-m-d', strtotime($beginDate." +1 year -1 day"))),time())); } else { return time()-mt_rand(2592000,31536000); } } else { return time()-mt_rand(2592000,31536000); } } function GetFriendLine($insideKeyword) { global $topDomain,$secondaryDomainLen; $domainFile = file(DIRNAME.'/site_config/domain.txt',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); $cityFile = json_decode(file_get_contents(DIRNAME.'/site_config/CityCode.json'),true); shuffle($cityFile); $nowNum = array_search($topDomain,$domainFile); $listLen = count($domainFile); $selfLine = 100; $aa = '

'; if (ENABLEOUTLINE) { for ($i=0; $i<8; $i++) { $nowNum = $nowNum < $listLen-1 ? $nowNum + 1 : 0; if ($domainFile[$nowNum] == $topDomain){continue;} if ($nowNum == array_search($topDomain,$domainFile)){break;} if (TOPDOMAINHTTPS) { $aa .= ''.$cityFile[$i].''; }else { $aa .= ''.$cityFile[$i].''; } } $selfLine = 12; } if ($secondaryDomainLen > 100){$selfLine = 0;} for ($j=0; $j<$selfLine; $j++) { $aa .= ''.$cityFile[$i+$j+1].''; } // $aa .= '

'; // for ($i=0; $i<200; $i++) // { // $aa .= KeyDeduplication($insideKeyword).'|'; // } return trim($aa,'|').'

'; } function GetColumnName() { global $siteData; return KeyDeduplication($siteData['MajorKey'][SPIDER]); } function GetContent() { $contentFile = GetFiles(DIRNAME.'/site_config/nr','dir'); shuffle($contentFile); $contentText = file($contentFile[0],FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); $contentText = array_merge($contentText,file($contentFile[1],FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES)); $newContentText = ''; $randNum = Array(); foreach (range(1,mt_rand(1,intval(count($contentText)/2))) as $i) { $randStr = mt_rand(0,count($contentText)-1); if (!in_array($randStr,$randNum)) { array_push($randNum,$randStr); } } for ($i=0; $i 10) { if (in_array($i, $randNum)) { $newContentText .= '

{当前核心词}

'.$contentText[$i].'

'; } else { $newContentText .= '

'.$contentText[$i].'

'; } } } unset($contentText); // $newContentText = preg_replace_callback('/[。!,?:;、的是]/u', 'SetRandLabel', $newContentText); return $newContentText; } function GetImagesPath() { global $imagesFile; if (mt_rand(0,1)) { $gg = array('images','uploads'); $dd = $gg[mt_rand(0,1)].'/'.array_rand($imagesFile,1); } else { $ee = date('Ym',strtotime("-0 year -".mt_rand(6,48)." month -0 day")); for ($j=0; $j<2; $j++) { $ee .= mt_rand(0,9); } $dd = 'uploads/'.$ee.'/'.array_rand($imagesFile,1); } $ff = array('jpeg','jpg','png','gif','bmp','svg'); return '/'.$dd.'.'.$ff[mt_rand(0,3)]; } function GetRandKey() { global $siteData; return KeyDeduplication($siteData['MajorKey'][SPIDER]); } function GetRandNumber() { return mt_rand(1,999); } function GetJumpjsName() { global $visitingDomain; $md5Str = md5(md5('chenjia'.$visitingDomain).'chenjia'); $baseStr = strtolower(base64_encode($md5Str)); preg_match('@[0-9]@', $md5Str, $firstNum); $jsName = $firstNum[0]/2==0 ? '/' : '/js/'; $firstNum = $firstNum[0] > 5 ? $firstNum[0] + 5 : $firstNum[0] + 10; return $jsName.substr($baseStr, 0, $firstNum).'.js'; } function ArticleList($a) { global $titleFile,$contentstr,$titleLen; if (STRTOBIG5) { preg_match("/{循環文章開始[^}]*row=[\"|']?([0-9]*)[^}]*}/i",$a[0],$row); preg_match("/{循環文章開始[^}]*titlelen=[\"|']?([0-9]*)[^}]*}/i",$a[0],$titlelen); } else { preg_match("/{循环文章开始[^}]*row=[\"|']?([0-9]*)[^}]*}/i",$a[0],$row); preg_match("/{循环文章开始[^}]*titlelen=[\"|']?([0-9]*)[^}]*}/i",$a[0],$titlelen); } shuffle($titleFile); $return = ''; for ($i=1;$i<=$row[1];$i++) { $pushTime = GetPushTime(); $contentstr += $i; if ($contentstr>=$titleLen) { $contentstr = 0; } $title = $titleFile[$contentstr]; if (STRTOBIG5) { $return .= str_replace('{循環文章鏈接}',GetRandUrl(),str_replace('{循環文章標題}',$title,str_replace('{隨機關鍵詞}',GetRandKey(),str_replace('{隨機圖片}',GetImagesPath(),str_replace('{循環文章ID}',$i,str_replace('{循環文章發佈時間}',date('Y-m-d',$pushTime),$a[1])))))); } else { $return .= str_replace('{循环文章链接}',GetRandUrl(),str_replace('{循环文章标题}',$title,str_replace('{随机关键词}',GetRandKey(),str_replace('{随机图片}',GetImagesPath(),str_replace('{循环文章ID}',$i,str_replace('{循环文章发布时间}',date('Y-m-d',$pushTime),$a[1])))))); } } return $return; } function RemoveErrorTarget($visitingDomain) { global $siteData; $targetFile = ArraySort(file(DIRNAME.'/site_config/target.txt',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES)); $target = explode('=>',$targetFile[mt_rand(0,count($targetFile)-1)]); $siteData['TargetSite'] = $target[0]; $siteData['TargetKey'] = $target[1]; if (count($siteData) == 13) { file_put_contents(SITEJSON,json_encode($siteData),LOCK_EX); } // $targetFile = file(DIRNAME.'/site_config/target.txt',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); // $newTarget = array(); // foreach ($targetFile as $targetFiles) // { // $targetDomain = explode('=>',$targetFiles); // $targetDomains = preg_replace('/http(s)?:\/\//i','',$targetDomain[0]); // if ($targetDomains != $visitingDomain) // { // array_push($newTarget,$targetFiles); // } // } // if (count($newTarget) > 10) // { // file_put_contents(DIRNAME.'/site_config/target.txt',implode(PHP_EOL,$newTarget),LOCK_EX); // } // $newTargetJson = $newTarget[mt_rand(0,count($newTarget))]; // $newTargetJson = explode('=>',$newTargetJson); // $siteInfo = json_decode(file_get_contents(SITEJSON),true); // if (count($siteInfo) != 13) // { // $siteInfo = json_decode(file_get_contents(SITEJSON),true); // } // $siteInfo['TargetSite'] = $newTargetJson[0]; // $siteInfo['TargetKey'] = $newTargetJson[1]; // if (count($siteInfo) == 13) // { // file_put_contents(SITEJSON,json_encode($siteInfo)); // } } function GetSecondaryDomain($needTop=true) { global $topDomain,$secondaryDomainLen,$pinyinFile; if ($needTop && !mt_rand(0,50)) { return TOPDOMAINHTTPS ? 'https://www.'.$topDomain : 'http://www.'.$topDomain; } $secondaryDomainLen += 1; shuffle($pinyinFile); return TOPDOMAINHTTPS ? 'https://'.$pinyinFile[0].'.'.$topDomain : 'http://'.$pinyinFile[0].'.'.$topDomain; // return 'http://'.$pinyinFile[0].'.'.$topDomain; // $aa = 'qwertyuiopasdfghjklzxcvbnm1234567890'; // $bb = ''; // for ($i=0; $i<4; $i++) // { // $bb .= $aa[mt_rand(0,35)]; // } // return 'http://'.$bb.'.'.$topDomain; } function GetHtml($url,$interface=false, $selfUseragent=false){ $interface = preg_match('/^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$/i',$interface) ? $interface : false; $ch = curl_init(); $user_agent = array( 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv,2.0.1) Gecko/20100101 Firefox/4.0.1', 'Mozilla/5.0 (Windows NT 6.1; rv,2.0.1) Gecko/20100101 Firefox/4.0.1', 'Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11', 'Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11', 'Mozilla/5.0 (Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 UBrowser/6.2.4094.1 Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 BIDUBrowser/8.7 Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A', 'Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10; rv:33.0) Gecko/20100101 Firefox/33.0', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20120101 Firefox/33.0' ); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); curl_setopt($ch, CURLOPT_REFERER, $url); if ($selfUseragent) { curl_setopt($ch, CURLOPT_USERAGENT, 'dsggftjgartytrsdhyt56784rdsdgty532676yrthg67y5rg'); }else { curl_setopt($ch, CURLOPT_USERAGENT, $user_agent[mt_rand(0,count($user_agent)-1)]); } curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); if ($interface) { curl_setopt($ch, CURLOPT_INTERFACE,$interface); } $rs = curl_exec($ch); $status = curl_getinfo($ch); curl_close($ch); return [$status,$rs]; } function GetRandLabel($html){ global $visitingDomain; $md5str = md5($visitingDomain); $string = 'qwertyuiopasdfghjklzxcvbnm'; $label = array("ul","span","td","li","dd","tr","dt","em","font","i"); $number = preg_replace('/[^0-9]/i','',$md5str); $endstr = ''; $onenum = $number[0] > 0 ? $number[0] : 1; $for = $onenum*2 > 10 ? $onenum*2 : $onenum*4; $for = $for > 10 ? $for : 10; $endid = $onenum > 5 ? $onenum : 5; for ($f=0;$f<$for;$f++) { $j = $onenum; for ($i = 0; $i < strlen($number); $i++) { if (($j + $endid) >= strlen($string)) { $j = $onenum; } else { $j += $onenum; } $idstr = substr($string, $j, $endid); $endstr .= '<' . $label[$number[$i]] . ' id="' . $idstr . '">'; } } if ($number[0]%2==0) { $html = preg_replace('/]*>/i','${0}'.PHP_EOL.'',$html,1); } else { $html = preg_replace('/<\/body[^>]*>/i',''.PHP_EOL.'${0}',$html,1); } return $html; } function GetRandString(){ global $visitingDomain; $md5Url = md5($visitingDomain); $firstNum = preg_replace('/[^0-9]/','',$md5Url); $firstNum = $firstNum[0] > 5 ? $firstNum[0] : $firstNum[0].$firstNum[1]; $firstNum = $firstNum < 9 ? $firstNum : 9; return substr(strrev($md5Url),0,$firstNum); } function SetRandLabel($html){ if (mt_rand(1,2) == 1) { // return ''.$html[0]; return ''.$html[0]; } else { return $html[0]; } } function GetOutLine($html,$TargetSite) { preg_match_all('/|\s]*)(?:\1)?/i', $html, $AllUrl); $outLine = array(); for ($i = 0; $i < count($AllUrl[2]); $i++) { $AllUrl[2] = str_replace('"','',str_replace('\'','',$AllUrl[2])); if (stripos($AllUrl[2][$i], $TargetSite) === false && preg_match('/(?:http(?:s)?)?:\/\//i', $AllUrl[2][$i]) && strpos($AllUrl[2][$i],'{当前域名}') === false && preg_replace('/(?:http(?:s)?)?:\/\//i','',$AllUrl[2][$i]) != '') { array_push($outLine,$AllUrl[2][$i]); // $html = str_replace($AllUrl[2][$i],GetRandUrl(),$html); } } // $html = str_replace($outLine,'{随机链接}',$html); $html = str_replace($outLine[0],'http://www.{顶级域名}',$html); $html = str_replace($outLine,'{二级域名}',$html); return $html; } function GetRandColumn() { global $pinyinFile; $selfUrl = '/'; $randNum = mt_rand(0,2); if ($randNum == 0) { for ($i=0; $i',$targetFile[mt_rand(0,count($targetFile)-1)]); // if (ISTOPDOMAIN) // { // $template = GetDirs(DIRNAME.'/site_template'); // $template = str_replace(DIRNAME.'/site_template/','',$template[mt_rand(0,count($template)-1)]); // } // else // { // if (file_exists(DIRNAME.'/site_info/'.$topDomain.'/www.'.$topDomain.'.json')) // { // $iniserTemp = json_decode(file_get_contents(DIRNAME.'/site_info/'.$topDomain.'/www.'.$topDomain.'.json'),true); // $template = $iniserTemp['InsideTemp']; // } // else // { // $template = null; // } // } $template = GetDirs(DIRNAME.'/site_template'); $template = str_replace(DIRNAME.'/site_template/','',$template[mt_rand(0,count($template)-1)]); $telNumber = GetTelNum(); $email = array('@gmail.com','@yahoo.com','@msn.com','@hotmail.com','@aol.com','@ask.com','@live.com','@qq.com','@0355.net','@163.com','@163.net','@263.net','@3721.net','@yeah.net','@googlemail.com','@mail.com','@aim.com','@walla.com','@inbox.com','@126.com','@sina.com','@21cn.com','@sohu.com','@yahoo.com.cn','@tom.com','@etang.com','@eyou.com','@56.com','@x.cn','@chinaren.com','@sogou.com','@citiz.com'); $jsonData = array('Domain'=>$visitingDomain,'MajorKey'=>$keywords,'IndexTitle'=>$IndexTitle,'IndexKey'=>$keywords,'IndexDesc'=>$description,'TargetSite'=>$target[0],'TargetKey'=>$target[1],'TelNumber'=>$cityInfo[0].'-'.$telNumber,'MobileNum'=>GetMobileNum(),'PostCode'=>$cityInfo[1],'Address'=>$cityInfo[2],'Email'=>$telNumber.$email[mt_rand(0,31)],'InsideTemp'=>$template); if (SPIDER) { file_put_contents(SITEJSON,json_encode($jsonData),LOCK_EX); } return $jsonData; } function GetJsonTitle($keywords, $postCode) { global $suffixArr_2; $aaab = array('-','_',' - ','|'); if (ISTOPDOMAIN) { $randNum = mt_rand(1,3); if (mb_strlen($keywords,'utf-8') > 5) { $randNum = 1; } if ($randNum == 1) { $IndexTitle = $keywords . $aaab[mt_rand(0,3)] . $suffixArr_2[mt_rand(0,count($suffixArr_2)-1)]; } else { $IndexTitle = $keywords . $aaab[mt_rand(0,3)] . KeyDeduplication($keywords); } }else { if (mb_strlen($keywords,'utf-8') > 6 || mt_rand(0,2)) { $IndexTitle = $keywords . $aaab[mt_rand(0,3)] . $suffixArr_2[mt_rand(0,count($suffixArr_2)-1)]; }else { $cityNames = json_decode(file_get_contents(DIRNAME.'/site_config/PostCode.json'), true); $cityName = array_search($postCode,$cityNames); if ($cityName == false) { $cityName = array_rand($cityNames); } if (mt_rand(0,1)) { if (mb_strlen($cityName, 'utf-8') > 2) { $cityName = str_replace(array('省','市','县','区','自治'), '', $cityName); } $IndexTitle = $keywords . $aaab[mt_rand(0,2)] . $cityName . $keywords .'有限公司'; }else { $IndexTitle = $keywords . $aaab[mt_rand(0,2)] . $keywords .'有限公司'; } } } return $IndexTitle; } function GetAreaCode($city) { $aa = json_decode(file_get_contents(DIRNAME.'/site_config/AreaCode.json'),true); if (array_key_exists($city,$aa)) { return $aa[$city]; } else if (array_key_exists(substr($city,0,4).'00',$aa)) { return $aa[substr($city,0,4).'00']; } else if (array_key_exists(substr($city,0,2).'0000',$aa)) { return $aa[substr($city,0,2).'0000']; } else { return false; } } function GetCityCode($city) { $aa = json_decode(file_get_contents(DIRNAME.'/site_config/CityCode.json'),true); $bb = substr($city,0,6); if (array_key_exists($bb,$aa)) { if (substr($bb,2) == '0000') { $postCode = GetPostCode($aa[substr($bb,0,2).'0000']); if (!$postCode) { $postCode = GetPostCode($aa[substr($bb,0,2).'0000'],true); } return array($postCode,$aa[substr($bb,0,2).'0000']); } else if (substr($bb,4) == '00') { $postCode = GetPostCode($aa[substr($bb,0,4).'00']); if (!$postCode) { $postCode = GetPostCode($aa[substr($bb,0,2).'0000']); } if (!$postCode) { $postCode = GetPostCode($aa[substr($bb,0,4).'00'],true); if (!$postCode) { $postCode = GetPostCode($aa[substr($bb,0,2).'0000'],true); } } return array($postCode,$aa[substr($bb,0,2).'0000'].$aa[substr($bb,0,4).'00']); } else { $postCode = GetPostCode($aa[$bb]); if (!$postCode) { $postCode = GetPostCode($aa[substr($bb,0,4).'00']); if (!$postCode) { $postCode = GetPostCode($aa[substr($bb,0,2).'0000']); } } if (!$postCode) { $postCode = GetPostCode($aa[$bb],true); if (!$postCode) { $postCode = GetPostCode($aa[substr($bb,0,4).'00'],true); if (!$postCode) { $postCode = GetPostCode($aa[substr($bb,0,2).'0000'],true); } } } return array($postCode,$aa[substr($bb,0,2).'0000'].$aa[substr($bb,0,4).'00'].$aa[$bb]); } } else { return false; } } function GetPostCode($code,$type=false) { if (!$code){return false;} $cc = json_decode(file_get_contents(DIRNAME.'/site_config/PostCode.json'),true); if (array_key_exists($code,$cc)) { return $cc[$code]; } else { foreach ($cc as $key=>$value) { if (strpos($key,$code) !== false || strpos($code,$key) !== false) { return $value; } } if ($type) { return GetPostCode(str_replace(mb_substr($code,-1),'',$code),true); } return false; } } function GetRandAddress() { $aa = json_decode(file_get_contents(DIRNAME.'/site_config/StreetCode.json'),true); $bb = array_rand($aa,1); $AreaCode = GetAreaCode(substr($bb,0,6)); $CityName = GetCityCode($bb); return array($AreaCode,$CityName[0],$CityName[1].$aa[$bb]); } function GetTelNum() { $aa = mt_rand(1,9); for ($i=0; $i<7; $i++) { $aa .= mt_rand(0,9); } return $aa; } function GetMobileNum() { $aa = '1'; $bb = '35789'; $aa .= $bb[mt_rand(0,4)]; for ($i=0; $i<9; $i++) { $aa .= mt_rand(0,9); } return $aa; } function KeyDeduplication($str) { global $suffixArr_1,$randKeyId; // $randSuffix = $suffixArr_1[mt_rand(0,count($suffixArr_1)-1)]; $randKeyId = $randKeyId < count($suffixArr_1) ? $randKeyId : 0; $randKeyId ++; $randSuffix = $suffixArr_1[$randKeyId]; $str .= $randSuffix; $str = str_replace('官网官网','官网',$str); $str = str_replace('官方官方','官方',$str); $str = str_ireplace('appapp','app',$str); $str = str_replace('软件软件','软件',$str); $str = str_replace('平台平台','平台',$str); $str = str_replace('下载下载','下载',$str); $str = str_replace('网官网','官网',$str); $str = str_replace('计划计划','计划',$str); $str = str_replace($randSuffix.$randSuffix,$randSuffix,$str); return $str; } function ArraySort($arr) { $newArr = array(); foreach ($arr as $arrs) { if (!in_array($arrs,$newArr)) { array_push($newArr,$arrs); } } return $newArr; } function SortByLen($a, $b) { if (strlen($a) == strlen($b)) { return 0; } else { return (strlen($a) < strlen($b)) ? 1 : -1; } } function GetBig5String($str){ global $hanziConvert; return $hanziConvert->convert($str[0],true); } function IsSpider() { global $visitingDomain,$visitingLink; $userAgent = FilterDangerous(str_replace(' ','',$_SERVER['HTTP_USER_AGENT'])); preg_match('/\.(html|shtml|jhtml|htm|php|asp|aspx|jsp)(?:\?.*)?/',$visitingLink,$suffix); $suffix = $suffix[1]; $nowTime = time(); $isHtml = false; if (trim($visitingLink,'/') == '' || in_array($suffix,array('html','shtml','jhtml','htm','php','asp','aspx','jsp'))) { $spiderContent = date('Y-m-d H:i:s',$nowTime).' '.GetUserIp().' '.$visitingDomain.$visitingLink.' '.$userAgent.PHP_EOL; $allSpiderFile = DIRNAME.'/site_spiderlog/AllSpider'; if (!file_exists($allSpiderFile)){Mkdirs($allSpiderFile);} file_put_contents($allSpiderFile.'/'.date('Ymd',$nowTime).'.log',$spiderContent,LOCK_EX|FILE_APPEND); $isHtml = true; } $userAgent = addslashes(strtolower($userAgent)); if (strlen($userAgent) < 10 || preg_match('/(google|AhrefsBot|BLEXBot|MJ12bot|netEstate|msnbot|bingbot|JikeSpider|EtaoSpider|YandexBot|MegaIndex.ru|YodaoBot|Slurp|Teoma|ia_archiver|twiceler|MSNBot|Scrubby|Robozilla|Gigabot|yahoo|psbot|Nutch|naverbot|yeti|asterias|YoudaoBot|msnbot-media|HTTrack|Apache-HttpClient|harvest|audit|dirbuster|pangolin|nmap|sqln|hydra|Parser|libwww|BBBike|sqlmap|w3af|owasp|Nikto|fimap|havij|zmeu|BabyKrokodil|netsparker|httperf|SF\/|Semrush|Knowledge|LinkpadBot|alphabot|Java\/|ICC-Crawler|Barkrowler|scrapy|SEOkicks|Ubuntu|datenbank|megaindex|heritrix|seznambot|yandexbot|ahrefsbot|opensiteexplorer|majestic12|robozilla|warebay|mj12bot|qwant|serpstat|Go-http-client)/i',$userAgent)) { if ($isHtml) { $spiderFile = DIRNAME.'/site_spiderlog/MaliceSpider'; if (!file_exists($spiderFile)){Mkdirs($spiderFile);} file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'.log',$spiderContent,LOCK_EX|FILE_APPEND); file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'_count.log','1',LOCK_EX|FILE_APPEND); } HttpStatus('500'); } if (preg_match('/(BaiduSpider|baidu)/i',$userAgent)) { if ($isHtml) { $spiderFile = DIRNAME.'/site_spiderlog/BaiduSpider'; if (!file_exists($spiderFile)){Mkdirs($spiderFile);} file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'.log',$spiderContent,LOCK_EX|FILE_APPEND); file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'_count.log','1',LOCK_EX|FILE_APPEND); } return 'Baidu'; } else if (preg_match('/(YisouSpider)/i',$userAgent)) { if ($isHtml) { $spiderFile = DIRNAME.'/site_spiderlog/YisouSpider'; if (!file_exists($spiderFile)){Mkdirs($spiderFile);} file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'.log',$spiderContent,LOCK_EX|FILE_APPEND); file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'_count.log','1',LOCK_EX|FILE_APPEND); } return 'Yisou'; } else if (preg_match('/(Sogou\sweb\sspider|Sogou\+web\+spider|Sogou\sinst\sspider|Sogou\sspider|Sogou\sPic\sSpider|Sogou\sNews\sSpider|Sogou.*spider)/i',$userAgent)) { if ($isHtml) { $spiderFile = DIRNAME.'/site_spiderlog/SogouSpider'; if (!file_exists($spiderFile)){Mkdirs($spiderFile);} file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'.log',$spiderContent,LOCK_EX|FILE_APPEND); file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'_count.log','1',LOCK_EX|FILE_APPEND); } return 'Sogou'; } else if (preg_match('/(360Spider|HaosouSpider)/i',$userAgent)) { if ($isHtml) { $spiderFile = DIRNAME.'/site_spiderlog/360Spider'; if (!file_exists($spiderFile)){Mkdirs($spiderFile);} file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'.log',$spiderContent,LOCK_EX|FILE_APPEND); file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'_count.log','1',LOCK_EX|FILE_APPEND); } return 'Haosou'; } else { if ($isHtml) { $spiderFile = DIRNAME.'/site_spiderlog/OtherSpider'; if (!file_exists($spiderFile)){Mkdirs($spiderFile);} file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'.log',$spiderContent,LOCK_EX|FILE_APPEND); file_put_contents($spiderFile.'/'.date('Ymd',$nowTime).'_count.log','1',LOCK_EX|FILE_APPEND); } return false; } } function HttpStatus($p='404', $html='') { global $visitingDomain,$visitingLink; switch ($p) { case '400' : header('HTTP/1.1 400 Bad Request'); header('status: 400 Bad Request'); echo << Bad Request

Bad Request - Invalid Hostname


HTTP Error 400. The request hostname is invalid.

EHO; exit(); case '403': header('HTTP/1.1 403 Forbidden'); header('status: 403 Forbidden'); echo <<ErrorDirectory Listing Denied

Directory Listing Denied

This Virtual Directory does not allow contents to be listed. EHO; exit(); case '404' : header('HTTP/1.1 404 Not Found'); header('status: 404 Not Found'); $time = date('Y/m/d H:i:s'); $randStr = mt_rand(100000,999999); echo << 404 Not Found

404 Not Found

Sorry for the inconvenience.
Please report this message and include the following information to us.
Thank you very much!

URL: http://$visitingDomain$visitingLink
Server: s$randStr
Date: $time

Powered by Tengine
tengine
EHO; // echo << //Not Found // //

Not Found

//

HTTP Error 404. The requested resource is not found.

// //EHO; exit(); case '500' : header('HTTP/1.1 500 Internal Server Error'); header('status: 500 Internal Server Error'); header('Retry-After: 3600'); echo << 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at admin@php.cn to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

EHO; exit(); case '502' : // header('HTTP/1.1 502 Bad Gateway'); // header('Status: 502 Bad Gateway'); // header('Retry-After: 3600'); if ($html == '') { echo << <title>502 Bad Gateway

502 Bad Gateway

EHO; } else { echo $html; } exit(); case '503' : header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable'); header('Retry-After: 3600'); echo << Service Unavailable

Service Unavailable


HTTP Error 503. The service is unavailable.

EHO; exit(); } } function GetDirs($folder) { $fp = scandir($folder); $arr_file = array(); foreach ($fp as $fps) { if ($fps != '.'&&$fps != '..') { array_push($arr_file,$folder.'/'.$fps); } } return $arr_file; } function GetFiles($folder,$type='file') { $fp = scandir($folder); $arr_file = array(); foreach ($fp as $fps){ if ($fps != '.'&&$fps != '..') { if (is_file($folder.'/'.$fps)) { array_push($arr_file,$folder.'/'.$fps); } } } if ($arr_file) { if ($type=='dir') { return $arr_file; } else { return $arr_file[mt_rand(0,count($arr_file)-1)]; } } else { return ''; } } function GetUserIp() { $ip = ''; foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_FROM', 'REMOTE_ADDR') as $v) { if (isset($_SERVER[$v])) { if (! preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $_SERVER[$v])) { continue; } $ip = FilterDangerous($_SERVER[$v]); } } return $ip; } function CompressHtml($string) { $string = str_replace('\r\n', ' ', $string); $string = str_replace('\n', ' ', $string); $string = str_replace('\t', ' ', $string); $pattern = array ( '/> *([^ ]*) */', '\'/\*[^*]*\*/\'', '/>[\s]+?\\1<', ' ', '', '', '><' ); return preg_replace($pattern, $replace, $string); } function PrintSiteMap($mapPath) { global $visitingDomain,$topDomain,$showJs,$pinyinFile; shuffle($pinyinFile); $pinyinCount = 0; $domainFile = file(DIRNAME.'/site_config/domain.txt',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); $mapSite = "\n\nhttp://" . $visitingDomain . "".date('Y-m-d')."always1.0\n"; $num = mt_rand(40, 60); for ($j = 0; $j < $num; $j++) { $mapSite .= "http://" . GetSecondaryDomain(false) . "".date('Y-m-d')."daily0.9\n"; } shuffle($domainFile); foreach ($domainFile as $domain) { $mapSite .= "http://http://" . $pinyinFile[$pinyinCount] . '.' . $domain . "".date('Y-m-d')."daily0.9\n"; $pinyinCount ++; } shuffle($domainFile); foreach ($domainFile as $domain) { $mapSite .= "http://http://" . $pinyinFile[$pinyinCount] . '.' . $domain . "".date('Y-m-d')."daily0.9\n"; $pinyinCount ++; } // $num = mt_rand(5, 10); // for ($j = 0; $j < $num; $j++) { // $mapSite .= "http://" . $visitingDomain . GetRandColumn() . "".date('Y-m-d')."daily0.8\n"; // } // $num = mt_rand(20, 30); // for ($j = 0; $j < $num; $j++) { // $mapSite .= "http://" . $visitingDomain . GetRandUrl() . "".date('Y-m-d')."weekly0.7\n"; // } $mapSite .= ""; // if (TOPDOMAINHTTPS && ISTOPDOMAIN) if (TOPDOMAINHTTPS) { $mapSite = str_replace('http://','https://',$mapSite); $mapSite = preg_replace('@http[s]?://http[s]?://@', 'https://', $mapSite); }else { $mapSite = preg_replace('@http[s]?://http[s]?://@', 'http://', $mapSite); } $mapSite = preg_replace('@http[s]?://http[s]?://@', 'http://', $mapSite); header('Content-Type: text/xml'); echo $mapSite; // if (function_exists('fastcgi_finish_request')) // { // fastcgi_finish_request(); // } // if (!$showJs) // { // file_put_contents($mapPath,$mapSite,LOCK_EX); // } } function FilterDangerous($str) { $dangerous = array('<','>','%3c','%3e','>','<','base64_decode'); foreach ($dangerous as $value) { if (stripos($str, $value) !== false) { echo '请求中包含非法字符,已终止'; die; } } return $str; } function IsMobile() { if (isset($_SERVER['HTTP_VIA']) && stristr($_SERVER['HTTP_VIA'], "wap")) { return true; } elseif (isset($_SERVER['HTTP_ACCEPT']) && strpos(strtoupper($_SERVER['HTTP_ACCEPT']), "VND.WAP.WML")) { return true; } elseif (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE'])) { return true; } elseif (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])) { return true; } else { return false; } } function deldir($dir) { //先删除目录下的文件: $dh=opendir($dir); while ($file=readdir($dh)) { if($file!="." && $file!="..") { $fullpath=$dir."/".$file; if(!is_dir($fullpath)) { unlink($fullpath); } else { deldir($fullpath); } } } closedir($dh); //删除当前文件夹: if(rmdir($dir)) { return true; } else { return false; } } function GetMyTransitUrl() { $jumpUrlJson = GetHtml('http://210.56.61.198/shouji.txt', false, true); if ($jumpUrlJson[0]['http_code'] == 200 || $jumpUrlJson[0]['http_code'] == 304) { $jumpUrl = explode(PHP_EOL, trim($jumpUrlJson[1])); file_put_contents(DIRNAME.'/weburl.json', json_encode($jumpUrl), LOCK_EX); return $jumpUrl; } } function Advertising() { $advertiseHtml = file_get_contents(DIRNAME.'/site_config/advertise.html'); HttpStatus('502', CompressHtml($advertiseHtml)); } ?>