172800)) { @unlink($f); } } // 清理旧的gc标记(保留近7天) foreach ((array)glob($mcDir . '/.gc_*') as $m) { if (is_file($m) && (time() - @filemtime($m) > 604800)) { @unlink($m); } } } $mcKey = md5('show|' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '') . '|' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '')); $mcFile = $mcDir . '/' . $mcKey . '.html'; if (is_file($mcFile) && (time() - @filemtime($mcFile) <= $microCacheTtl)) { echo (string)@file_get_contents($mcFile); exit; } } // 基础防护:恶意爬虫拦截 + 轻量IP限流(防止高并发打爆CPU/网络) $clientIp = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0'; $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $uaLower = strtolower($ua); // 访问策略:仅手机可访问;百度蜘蛛需通过IP段校验 $isBaiduSpider = (strpos($uaLower, 'baiduspider') !== false); $remoteIp = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $trustedBaiduIpPrefixes = ['180.76.', '220.181.', '123.125.', '61.135.', '111.206.', '106.11.']; $isTrustedBaiduIp = false; if ($remoteIp !== '') { foreach ($trustedBaiduIpPrefixes as $pre) { if (strpos($remoteIp, $pre) === 0) { $isTrustedBaiduIp = true; break; } } } // UA伪装为百度但IP不在百度网段,直接拒绝 if ($isBaiduSpider && !$isTrustedBaiduIp) { http_response_code(403); exit('Forbidden'); } $isBaiduSpider = $isBaiduSpider && $isTrustedBaiduIp; // 放开PC访问:仅对蜘蛛执行严格策略,普通PC/手机用户均可访问 $isMobileClient = (bool)preg_match('/(iphone|ipod|ipad|android|mobile|windows phone|blackberry|symbian|opera mini|ucbrowser|harmonyos)/i', $ua); $securityMode = isset($securityMode) ? (int)$securityMode : 0; $blockBadUa = isset($blockBadUa) ? (int)$blockBadUa : 0; $rateLimitSwitch = isset($rateLimitSwitch) ? (int)$rateLimitSwitch : 0; $rateLimitWindow = isset($rateLimitWindow) ? max(1, (int)$rateLimitWindow) : 10; $rateLimitMaxReq = isset($rateLimitMaxReq) ? max(1, (int)$rateLimitMaxReq) : 25; // 仅放行通过IP段校验的百度蜘蛛(PC/手机) $isAllowedBot = $isBaiduSpider; // 拒绝百度以外蜘蛛 if ((strpos($uaLower, 'spider') !== false || strpos($uaLower, 'bot') !== false || strpos($uaLower, 'crawler') !== false) && !$isBaiduSpider) { http_response_code(403); exit('Forbidden'); } if ($securityMode === 1 && $blockBadUa === 1) { $denyTokens = [ 'sqlmap','acunetix','nuclei','masscan','zgrab','nessus','dirbuster','gobuster', 'curl/','python-requests','java/','okhttp','httpclient','go-http-client','wget','libwww-perl', 'googlebot','bingbot','sogou','360spider','bytespider','yandexbot','semrush','ahrefsbot' ]; $isBadUa = ($ua === ''); if (!$isBadUa) { foreach ($denyTokens as $t) { if (strpos($uaLower, $t) !== false) { $isBadUa = true; break; } } } if ($isBadUa && !$isAllowedBot) { http_response_code(403); exit('Forbidden'); } } if ($securityMode === 1 && $rateLimitSwitch === 1) { $rateDir = __DIR__ . '/data/runtime/rate_limit'; if (!is_dir($rateDir)) { @mkdir($rateDir, 0777, true); } // 目录瘦身:每小时清理一次2天前的限流文件,避免小文件堆积 $gcMark = $rateDir . '/.gc_show_' . date('YmdH'); if (!is_file($gcMark)) { @file_put_contents($gcMark, '1'); foreach ((array)glob($rateDir . '/*.json') as $f) { if (is_file($f) && (time() - @filemtime($f) > 172800)) { @unlink($f); } } } $rateFile = $rateDir . '/' . md5($clientIp . '|show') . '.json'; $nowTs = time(); $hit = ['ts' => $nowTs, 'count' => 0]; if (is_file($rateFile)) { $raw = @file_get_contents($rateFile); $tmp = json_decode($raw, true); if (is_array($tmp) && isset($tmp['ts'], $tmp['count'])) { $hit = $tmp; } } if (($nowTs - (int)$hit['ts']) > $rateLimitWindow) { $hit = ['ts' => $nowTs, 'count' => 1]; } else { $hit['count'] = (int)$hit['count'] + 1; } @file_put_contents($rateFile, json_encode($hit), LOCK_EX); if ((int)$hit['count'] > $rateLimitMaxReq && !$isAllowedBot) { http_response_code(429); header('Retry-After: 20'); exit('Too Many Requests'); } } // 简单蜘蛛访问日志(记录到 data/spider_log.txt,便于后续统计,支持区分PC/移动及简单真假百度蜘蛛) $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; if ($ua) { $uaLower = strtolower($ua); // 只记录常见搜索引擎蜘蛛,避免把普通用户全部记进去 if (strpos($uaLower, 'spider') !== false || strpos($uaLower, 'bot') !== false || strpos($uaLower, 'slurp') !== false) { $spiderName = 'OtherSpider'; $deviceType = 'PC'; $isRealBaidu = '-'; if (strpos($uaLower, 'baiduspider') !== false) { $spiderName = 'Baiduspider'; // UA 中包含 mobile 视为移动百度蜘蛛 if (strpos($uaLower, 'mobile') !== false) { $deviceType = 'Mobile'; } else { $deviceType = 'PC'; } // 简单按 IP 段判断真假百度蜘蛛(可按需在这里调整网段) $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $isRealBaidu = 'Fake'; if ($ip) { $baiduIpPrefixes = [ '180.76.', // 百度北京 '220.181.', // 百度北京 '123.125.', // 百度北京 '61.135.', // 百度北京 '111.206.', // 百度 '106.11.', // 百度 ]; foreach ($baiduIpPrefixes as $pre) { if (strpos($ip, $pre) === 0) { $isRealBaidu = 'Real'; break; } } } } elseif (strpos($uaLower, '360spider') !== false) { $spiderName = '360Spider'; } elseif (strpos($uaLower, 'sogou') !== false) { $spiderName = 'SogouSpider'; } elseif (strpos($uaLower, 'bingbot') !== false) { $spiderName = 'Bingbot'; } elseif (strpos($uaLower, 'googlebot') !== false) { $spiderName = 'Googlebot'; } $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '-'; $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '-'; $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '-'; $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '-'; $logLine = date('Y-m-d H:i:s') . "\t" . $spiderName . "\t" . $deviceType . "\t" . $isRealBaidu . "\t" . $ip . "\t" . $host . "\t" . $uri . "\t" . $referer . "\t" . $ua . "\n"; $logDir = __DIR__ . '/data/runtime/spider_log'; if (!is_dir($logDir)) { @mkdir($logDir, 0777, true); } // 按天切分日志,降低单文件过大风险 $logFile = $logDir . '/spider_' . date('Ymd') . '.log'; @file_put_contents($logFile, $logLine, FILE_APPEND | LOCK_EX); } } // PC 端模板映射:一域名一模板 // 在这里为不同域名指定不同的 PC 下载页模板 $pcTemplateMap = [ // 当前 shoubiao1688.com:使用老版 pGHVEvf 模板(模板1) 'shoubiao1688.com' => 'data/muban/pGHVEvf.html', // 第二个域名:使用 3673 风格模板(模板2) 'zjbojingit.com' => 'data/muban/pc_3673.html', // 第三个域名:使用 逗游 壳子模板(模板3) 'auto156.com' => 'data/muban/pc_doyo.html', // 第四个域名:使用 豌豆荚风格列表模板(模板4) 'yuntua.com' => 'data/muban/pc_wdj.html', // 下面是示例,后续你可以按需增加更多模板: // 'domain3.com' => 'data/muban/pc_doyo.html', ]; // 现在统一使用 PC 模板:不再区分 m. 域名与 PC 域名 $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; // 去掉 m. 前缀后的主域名或二级域名,用于匹配 $baseHost = preg_replace('/^m\./i', '', $host); // 泛域名裂变:基于当前根域生成随机子域名(需已配置泛解析) $rootDomainForFission = $baseHost; if (preg_match('/([\w-]+\.(?:com\.cn|net\.cn|org\.cn|gov\.cn|com|net|org|cn|cc|xyz|top|vip|shop|site|online|club|info|pro|io|co|me|tv|us|uk|eu))$/i', $baseHost, $mRoot)) { $rootDomainForFission = $mRoot[1]; } $randSubLen = mt_rand(4, 10); $randChars = 'abcdefghijklmnopqrstuvwxyz0123456789'; $randSub = ''; for ($i = 0; $i < $randSubLen; $i++) { $randSub .= $randChars[mt_rand(0, strlen($randChars) - 1)]; } $fissionHost = $randSub . '.' . $rootDomainForFission; $fissionUrl = 'http://' . $fissionHost . '/'; // -------- 城市 / 泛域名解析:从子域名自动识别城市名,用于 {城市} 标签 -------- // 例:bj.auto156.com -> 子域 bj -> 映射为 “北京”;sh.xxx.com -> “上海” $cityName = '全国'; if (!empty($host)) { $parts = explode('.', $host); if (count($parts) > 2) { // 取最左侧作为子域标识 $sub = strtolower($parts[0]); // 只保留字母,过滤掉数字等 $cityKey = preg_replace('/[^a-z]/', '', $sub); if ($cityKey && !in_array($cityKey, ['www', 'm'])) { // 内置一部分常见城市映射,方便开箱即用 $builtInCityMap = [ 'bj' => '北京', 'beijing' => '北京', 'sh' => '上海', 'shanghai' => '上海', 'gz' => '广州', 'guangzhou'=> '广州', 'sz' => '深圳', 'shenzhen' => '深圳', 'cd' => '成都', 'chengdu' => '成都', 'hz' => '杭州', 'hangzhou' => '杭州', 'nj' => '南京', 'nanjing' => '南京', 'wh' => '武汉', 'wuhan' => '武汉', 'cq' => '重庆', 'chongqing'=> '重庆', ]; // 支持自定义扩展:data/city_map.txt,每行:key|城市名 例如:tj|天津 $cityMap = $builtInCityMap; $cityFile = __DIR__ . '/data/city_map.txt'; if (is_file($cityFile)) { $lines = file($cityFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($lines as $line) { $line = trim($line); if ($line === '' || strpos($line, '|') === false) { continue; } list($k, $v) = explode('|', $line, 2); $k = strtolower(trim($k)); $v = trim($v); if ($k !== '' && $v !== '') { $cityMap[$k] = $v; } } } if (isset($cityMap[$cityKey])) { $cityName = $cityMap[$cityKey]; } } } } // 工具函数:支持主域名和 *.domain.com $resolveTemplate = function ($host, $map, $default) { foreach ($map as $domain => $tpl) { if ($host === $domain) { return $tpl; } if (preg_match('/\.'.preg_quote($domain, '/').'$/i', $host)) { return $tpl; } } return $default; }; // PC 端:按域名选专属模板(支持泛域名);未配置则回退到原来的 pGHVEvf,再不行随机旧模板 $pcTemplate = $resolveTemplate($baseHost, $pcTemplateMap, 'data/muban/pGHVEvf.html'); if (is_file($pcTemplate)) { $moban = file_get_contents($pcTemplate); } else { $templateFolder = 'data/muban/'; $templates = glob($templateFolder . '*.html'); $template = $templates[array_rand($templates)]; $moban = file_get_contents($template); } use sqhlib\Hanzi\HanziConvert; include_once 'data/fanti/HanziConvert.php'; $cacheFolder = 'cache/'; // 使用md5生成缓存文件名(基于当前请求的主机名和URI) $cacheName = md5($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); $cacheFile = $cacheFolder . $cacheName; // 检查缓存文件是否存在且缓存开关为1 if ($cacheSwitch == 1 && file_exists($cacheFile)) { // 如果缓存文件存在,则直接读取并输出缓存内容 header('Content-Type: text/html; charset=utf-8'); // 根据需要设置内容类型 echo file_get_contents($cacheFile); exit; // 确保在输出缓存内容后立即退出脚本 } $titlegs_list = file(__DIR__ . '/data/title.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $randomTitle = array_rand(array_flip($titlegs_list)); $moban = str_replace('{标题格式}', trim($randomTitle), $moban); $miaoshugs_list = file(__DIR__ . '/data/miaoshu.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $randomMiaoshu = array_rand(array_flip($miaoshugs_list)); if ($miaoshuSwitch == 1) { $randomMiaoshu = encodeValue($randomMiaoshu); } $moban = str_replace('{描述格式}', trim($randomMiaoshu), $moban); $fuzhu_list = file(__DIR__ . '/data/fuzhu.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $randomFuzhu = array_rand(array_flip($fuzhu_list)); if ($fzms1Switch == 1) { $randomFuzhu = encodeValue($randomFuzhu); } $moban = str_replace(['{辅助描述}', '{辅助描述1}'], trim($randomFuzhu), $moban); $fuzhu2_list = file(__DIR__ . '/data/fzms2.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $randomFuzhu2 = array_rand(array_flip($fuzhu2_list)); if ($fzms2Switch == 1) { $randomFuzhu2 = encodeValue($randomFuzhu2); } $moban = str_replace('{辅助描述2}', trim($randomFuzhu2), $moban); $fuzhu3_list = file(__DIR__ . '/data/keywords.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $randomFuzhu3 = array_rand(array_flip($fuzhu3_list)); if ($fzms2Switch == 1) { $randomFuzhu3 = encodeValue($randomFuzhu3); } $moban = str_replace('{辅助描述3}', trim($randomFuzhu3), $moban); $url_list = file(__DIR__ . '/data/url.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $moban = preg_replace_callback('/\{链接\}/', function($match) use ($url_list) { $randomurl = array_rand(array_flip($url_list)); return trim($randomurl); }, $moban); $moban = preg_replace_callback('/{随机数字(\d+)}/', function($match) { $length = intval($match[1]); return mt_rand(pow(10, ($length - 1)), pow(10, $length) - 1); }, $moban); while(strstr($moban,'{随机版本}')){ $moban = preg_replace('/{随机版本}/', 'V'.mt_rand(1, 15).'.'.mt_rand(01, 44).'.'.mt_rand(01, 17),$moban,1); } $moban = preg_replace_callback('/\{固定随机字符(\d+)?\}|\{固定字符(\d+)?\}/', function($match) { if (!empty($match[1])) { $length = intval($match[1]); // 限制随机位数在1-20之间 $length = max(1, min(20, $length)); } else if (!empty($match[2])) { $length = intval($match[2]); // 限制随机位数在1-20之间 $length = max(1, min(20, $length)); } else { // 如果未指定数字,则随机生成1-20位长度 $length = rand(1, 20); } // 检查是否已经生成过随机字符 if(isset($_SESSION['randomString'])) { $randomString = $_SESSION['randomString']; } else { $characters = 'abcdefghijklmnopqrstuvwxyz0123456789';//要大写就加入 ABCDEFGHIJKLMNOPQRSTUVWXYZ $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } // 保存生成的随机字符到会话中 $_SESSION['randomString'] = $randomString; } return $randomString; }, $moban); $moban = preg_replace_callback('/\{随机字符(\d+)\}|\{字符(\d+)\}/', function($match) { if (!empty($match[1])) { $length = intval($match[1]); } else if (!empty($match[2])) { $length = intval($match[2]); } else { return $match[0]; } $characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; }, $moban); // 只在手机模板上随机 class,PC 端保持原始 class,方便完全还原 3673 样式 if ($isMobileHost) { $characters = '0123456789abcdefgh0123456789ijklmnopq0123456789rstuvwxyz0123456789'; $moban = preg_replace_callback('/class="/', function($matches) use ($characters) { $randomString = ''; for ($i = 0; $i < 13; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return 'class="' . $randomString.' '; }, $moban); } $moban = preg_replace_callback('/{随机字母(\d+)}/', function($match) { $length = intval($match[1]); $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; }, $moban); $moban = preg_replace_callback('/{小写字母(\d+)}/', function($match) { $length = intval($match[1]); $characters = 'abcdefghijklmnopqrstuvwxyz'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; }, $moban); $moban = preg_replace_callback('/{大写字母(\d+)}/', function($match) { $length = intval($match[1]); $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; } return $randomString; }, $moban); $biaoqing_list = file(__DIR__ . '/data/biaoqing.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $randombiaoqing = array_rand(array_flip($biaoqing_list)); $moban = str_replace('{固定表情}', trim($randombiaoqing), $moban); $biaoqing_list = file(__DIR__ . '/data/biaoqing.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); shuffle($biaoqing_list); $index = 0; $moban = preg_replace_callback('/\{表情\}|\{随机表情\}/', function($matches) use ($biaoqing_list, &$index) { $replacement = isset($biaoqing_list[$index]) ? trim($biaoqing_list[$index]) : $matches[0]; $index++; return $replacement; }, $moban); $img_files = glob('data/img/*.txt'); $randomImgFile = $img_files[array_rand($img_files)]; $imgLines = file($randomImgFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $moban = preg_replace_callback('/\{图片\}|\{随机图片\}/', function () use ($imgLines) { return trim($imgLines[array_rand($imgLines)]); }, $moban); $keywords_files = glob('data/keywords/*.txt'); $randomKeywordsFile = $keywords_files[array_rand($keywords_files)]; $keywordLines = file($randomKeywordsFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); if (!empty($keywordLines)) { $keyword = $keywordLines[array_rand($keywordLines)]; } else { $keyword = ""; } $selectedKeyword = $keyword; $keywordFiles = glob('data/keywords/*.txt'); $randomKeywordFile = $keywordFiles[array_rand($keywordFiles)]; $keywordLines = file($randomKeywordFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $files = glob('data/keyword/*.txt'); $file = $files[array_rand($files)]; $keyword = trim(file($file)[array_rand(file($file))]); //require_once 'quanwang.php'; if ($gjc1Switch == 1) { $moban = str_replace('{关键词1}', $keyword, $moban); } $moban = str_replace('{关键词1}', $keyword, $moban); // $neirong1 = ''.$posts['0']['title'].''.$posts['0']['content'];//这是第一段内容 // while(strstr($moban,'{内容1}')) // { // $moban = preg_replace('/{内容1}/',$neirong1,$moban,1); // } $suijici_list = file(__DIR__ . '/data/keywordszm/zmci.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); shuffle($suijici_list); $index = 0; $moban = preg_replace_callback('/\{随机关键词2\}|\{随机关键词3\}/', function($matches) use ($suijici_list, &$index) { $replacement = isset($suijici_list[$index]) ? trim($suijici_list[$index]) : $matches[0]; $index++; return encodeValue($replacement); // 对替换结果进行转码 }, $moban); $juzi_files = glob('data/juzi/*.txt'); $randomJuziFile = $juzi_files[array_rand($juzi_files)]; $juziLines = file($randomJuziFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $moban = preg_replace_callback('/\{句子\}|\{随机句子\}/', function () use ($juziLines, $zmjuziSwitch) { $randomJuzi = trim($juziLines[array_rand($juziLines)]); if ($zmjuziSwitch == 1) { // 使用encodeValue转码 $randomJuzi = encodeValue($randomJuzi); } return $randomJuzi; }, $moban); $title_files = glob('data/title/*.txt'); $randomtitleFile = $title_files[array_rand($title_files)]; $titleLines = file($randomtitleFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $moban = preg_replace_callback('/\{标题\}|\{随机标题\}/', function () use ($titleLines, $zmtitleSwitch) { $randomTitle = trim($titleLines[array_rand($titleLines)]); if ($zmtitleSwitch == 1) { // 使用encodeValue转码 $randomTitle = encodeValue($randomTitle); } return $randomTitle; }, $moban); $reci_files = glob('data/reci/*.txt'); $randomreciFile = $reci_files[array_rand($reci_files)]; $reciLines = file($randomreciFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $moban = preg_replace_callback('/\{热词\}|\{随机热词\}/', function () use ($reciLines, $reciSwitch) { $randomHotWord = trim($reciLines[array_rand($reciLines)]); if ($reciSwitch == 1) { $randomHotWord = encodeValue($randomHotWord); } return $randomHotWord; }, $moban); // 栏目名称与栏目URL(用于 {随机栏目} / {随机栏目URL}) // 如果以后你在 data/mulu.txt 里维护栏目,可以改成从文件读取 $lanmuList = [ '系统工具', '聊天社交', '视频软件', '图形图像', '网络工具', '音乐软件', '办公软件', '安全防护', '游戏娱乐', '教育学习', '生活服务', '软件专题' ]; $randomLanmu = $lanmuList[array_rand($lanmuList)]; $lanmuUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/soft/'; $moban = str_replace('{随机栏目}', $randomLanmu, $moban); $moban = str_replace('{随机栏目URL}', $lanmuUrl, $moban); // 随机评论标签:{随机评论1} ~ {随机评论20} // 需求:pinglun.txt 至少准备 100 条评论;每次页面刷新随机显示 20 条,并随机带入本页关键词 $commentFile = __DIR__ . '/data/pinglun.txt'; if (is_file($commentFile)) { $commentLines = file($commentFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $commentLines = array_values(array_filter(array_map('trim', $commentLines))); if (!empty($commentLines)) { $maxDisplay = 20; // 模板中最多展示 20 条 // 打乱顺序,先取不重复的 shuffle($commentLines); $selected = array_slice($commentLines, 0, min($maxDisplay, count($commentLines))); // 如果评论总数不足 20 条,用随机重复填满 20 条,避免标签留空 while (count($selected) < $maxDisplay) { $selected[] = $commentLines[array_rand($commentLines)]; } // 当前页面可用的关键词(优先 selectedKeyword,其次 keyword) $commentKeyword = ''; if (!empty($selectedKeyword)) { $commentKeyword = trim($selectedKeyword); } elseif (!empty($keyword)) { $commentKeyword = trim($keyword); } // 写回模板:{随机评论1} ~ {随机评论20} foreach ($selected as $idx => $text) { // 在评论里随机嵌入关键词:优先用“软件”替换为关键词,否则在末尾追加 if ($commentKeyword !== '') { $replaced = false; if (mb_strpos($text, '软件') !== false) { $text = preg_replace('/软件/u', $commentKeyword, $text, 1); $replaced = true; } if (!$replaced) { $text .= ',' . $commentKeyword; } } if ($zmjuziSwitch == 1) { $text = encodeValue($text); } $moban = str_replace('{随机评论' . ($idx + 1) . '}', $text, $moban); } // 清理多余占位符(如模板里没用到的更高序号),避免首刷看到标签字样 $moban = preg_replace('/\{随机评论\d+\}/', '', $moban); } else { // 没有任何评论内容时,直接清空占位符 $moban = preg_replace('/\{随机评论\d+\}/', '', $moban); } } else { // 文件不存在,同样清空占位符,避免输出 {随机评论1} 之类的字样 $moban = preg_replace('/\{随机评论\d+\}/', '', $moban); } $url = $_SERVER['HTTP_HOST']; preg_match('/[\w][\w-]*\.(?:com\.cn|net\.cn|org\.cn|gov\.cn|ren|top|com|xyz|shop|mobi|kim|biz|work|store|online|wiki|video|show|world|chat|fund|guru|email|fashion|yoga|host|website|bio|green|pet|promo|VOTO|wang|sohu|net|vip|ink|red|ltd|auto|law|tech|art|love|social|cool|cfd|cx|today|company|gold|run|life|fit|space|archi|black|Lotto|pink|ski|citic|xin|club|site|info|pro|group|link|Beer|fun|design|center|team|zone|city|live|plus|pub|co|luxe|baidu|cloud|press|asia|blue|organic|poker|vote|com|net|space|pro|cyou|org|info|biz|me|mobi|name|cc|tv|co|io|in|cn|us|eu|uk|la|ws|au|jp|kr|shop|xyz|me|fun|store|ltd|pro|xin|vip|site|online|club|work|top|icu|cn|edu|net|org|gov|cc|biz|tech|info)(\/|$)/isU', $url, $match); $zym = $match[0]; $moban = str_replace("{根域名}", $zym, $moban); $moban = str_replace("{主域名}", $_SERVER['HTTP_HOST'], $moban); // 新增:城市占位符,结合子域名自动生成城市名(默认“全国”) $moban = str_replace("{城市}", $cityName, $moban); $moban = str_replace("", "<title>", $moban); $currentUrl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $moban = str_replace("{当前url}", $currentUrl, $moban); // 泛域名裂变占位符 $moban = str_replace('{裂变域名}', $fissionHost, $moban); $moban = str_replace('{裂变URL}', $fissionUrl, $moban); $moban = preg_replace_callback('/\{随机泛域名\}/', function() use ($rootDomainForFission) { $len = mt_rand(4, 10); $chars = 'abcdefghijklmnopqrstuvwxyz0123456789'; $sub = ''; for ($j = 0; $j < $len; $j++) { $sub .= $chars[mt_rand(0, strlen($chars) - 1)]; } return $sub . '.' . $rootDomainForFission; }, $moban); // 底部城市入口:在页面底部追加一排城市链接(自动读取 data/city_map.txt) if (!empty($zym)) { // 去掉可能的斜杠,保证是纯根域名 $rootDomain = rtrim($zym, '/'); // 从 city_map.txt 读取城市,按“城市名去重”,同一城市的多个 key 随机挑一个 $footerCities = []; $cityFile = __DIR__ . '/data/city_map.txt'; if (is_file($cityFile)) { $lines = file($cityFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($lines as $line) { $line = trim($line); if ($line === '' || $line[0] === '/' || strpos($line, '|') === false) { continue; } list($k, $v) = explode('|', $line, 2); $k = strtolower(trim($k)); $v = trim($v); if ($k !== '' && $v !== '') { // 先按城市名聚合所有 key if (!isset($footerCities[$v])) { $footerCities[$v] = []; } $footerCities[$v][] = $k; } } // 打乱城市顺序,再对每个城市名随机选一个 key,保证同一城市页面上只出现一次且顺序随机 $cityEntries = []; foreach ($footerCities as $cityNameFooter => $keys) { $cityEntries[] = ['name' => $cityNameFooter, 'keys' => $keys]; } shuffle($cityEntries); $finalCities = []; foreach ($cityEntries as $entry) { $keys = $entry['keys']; if (empty($keys)) { continue; } $key = $keys[array_rand($keys)]; $finalCities[$key] = $entry['name']; if (count($finalCities) >= 30) { break; // 底部最多展示 30 个城市,避免太长 } } $footerCities = $finalCities; } } if (!empty($footerCities)) { $cityHtml = '<div class="city-links" style="margin:20px auto;padding:10px 0;border-top:1px solid #eee;text-align:center;font-size:13px;color:#666;max-width:1200px;">' . '热门城市:'; $first = true; foreach ($footerCities as $sub => $name) { if (!$first) { $cityHtml .= ' | '; } $first = false; $cityHtml .= '<a href="http://' . $sub . '.' . htmlspecialchars($rootDomain, ENT_QUOTES) . '/" target="_blank" rel="nofollow" style="color:#666;text-decoration:none;">' . htmlspecialchars($name, ENT_QUOTES) . '</a>'; } $cityHtml .= '</div>'; if (stripos($moban, '</body>') !== false) { $moban = str_ireplace('</body>', $cityHtml . '</body>', $moban); } else { $moban .= $cityHtml; } } $now = time(); $yesterday = strtotime('-1 day'); // 按需替换随机时间,避免1000次空跑 while (strpos($moban, '{随机时间}') !== false || strpos($moban, '{动态时间}') !== false) { $randomTimestamp = mt_rand($yesterday, $now); $sjtime = date('Y-m-d H:i:s', $randomTimestamp); $moban = preg_replace('/{随机时间}|{动态时间}/', $sjtime, $moban, 1); } $time = date("Y-m-d H:i:s"); $time2 = date("Y年m月d日 l"); $weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']; $weekdayEnglish = date("l"); $weekdayChinese = $weekdays[array_search($weekdayEnglish, $weekdays)]; $time2 = str_replace($weekdayEnglish, $weekdayChinese, $time2); $time3 = date("Y-m-d"); $time4 = date("Y"); $time5 = date("m"); $time6 = date("d"); $time8 = time(); $moban = preg_replace([ '/{时间}|{当前时间}/', '/{当前日期}/', '/{年月日}/', '/{年}/', '/{月}/', '/{日}/', '/{时间戳}/' ], [ $time, $time2, $time3, $time4, $time5, $time6, $time8 ], $moban); /*新闻数据 $folderPath = 'data/news/'.date("Y-m-d").'/'; $files = glob($folderPath . '*.txt'); if (!empty($files)) { $randomFile = $files[array_rand($files)]; $xwtitle = basename($randomFile, ".txt"); $xwbody = file_get_contents($randomFile); } if ($zmtitleSwitch == 1) { $moban = str_replace('{新闻标题}', encodeValue($xwtitle), $moban); } else { $moban = str_replace('{新闻标题}', $xwtitle, $moban); } $xwbody = str_replace(' ', '', $xwbody); $moban = str_replace('{新闻内容}', $xwbody, $moban); */ $xwtitle = '热门资讯'; $xwbody = '<p>内容加载中,请稍后刷新查看。</p>'; if (isset($externalFetchSwitch) && (int)$externalFetchSwitch === 1) { $NEWS_URLS = [ "https://app.myzaker.com", "https://app.myzaker.com" ]; $NEWS_URL = $NEWS_URLS[array_rand($NEWS_URLS)]; $html = getCurlzhidao($NEWS_URL); // 正则表达式匹配模式 $pattern = '#<a href="//app.myzaker.com/news/article.php\?pk=(.*?)".*?title="(.*?)".*?target="_blank">#is'; $link = ''; // 有上限重试,避免外部异常导致死循环拖垮PHP进程 $maxFetchRetry = isset($externalFetchRetry) ? max(1, (int)$externalFetchRetry) : 2; for ($try = 0; $try < $maxFetchRetry; $try++) { if (preg_match_all($pattern, (string)$html, $matches) && !empty($matches[0])) { $index = array_rand($matches[0]); $link = isset($matches[1][$index]) ? $matches[1][$index] : ''; $xwtitle = isset($matches[2][$index]) ? $matches[2][$index] : $xwtitle; } if ($link === '') { break; } $xwbody_html = getCurlzhidao('https://app.myzaker.com/article/' . $link); preg_match('#<div id="content">(.*?)<div id="recommend_bottom">#is', (string)$xwbody_html, $match); $tmpBody = isset($match[1]) ? $match[1] : ''; if ($tmpBody !== '') { $xwbody = $tmpBody; break; } } $xwbody = preg_replace('/编辑:(.*?)|【责任编辑 : (.*?)】/', '', $xwbody); } // 最终收口:外部HTML白名单净化,防止注入脚本污染页面 if (!function_exists('sanitizeExternalHtml')) { function sanitizeExternalHtml($html) { $html = (string)$html; if ($html === '') return ''; // 移除高危标签及其内容 $html = preg_replace('#<(script|style|iframe|object|embed|form|input|button|textarea|select|meta|link)[^>]*>.*?</\1>#is', '', $html); $html = preg_replace('#<(script|style|iframe|object|embed|form|input|button|textarea|select|meta|link)[^>]*/?>#is', '', $html); // 移除事件属性与javascript协议 $html = preg_replace('/\son\w+\s*=\s*("[^"]*"|\'[^\']*\'|[^\s>]+)/i', '', $html); $html = preg_replace('/\s(href|src)\s*=\s*("|\')\s*javascript:[^"\']*("|\')/i', ' $1="#"', $html); // 仅保留基础展示标签 $html = strip_tags($html, '<p><br><strong><em><b><i><ul><ol><li><h2><h3><h4><blockquote><span><div>'); return $html; } } $xwbody = sanitizeExternalHtml($xwbody); if ($zmtitleSwitch == 1) { $moban = str_replace('{新闻标题}', encodeValue($xwtitle), $moban); } else { $moban = str_replace('{新闻标题}', $xwtitle, $moban); } $xwbody = str_replace(' ', '', $xwbody); $moban = str_replace('{新闻内容}', $xwbody, $moban); if ($zmkeywordSwitch == 1) { $selectedKeyword = encodeValue($keyword); } else { $selectedKeyword = $keyword; } $quKeyword = mb_substr($keyword, 0, 2, 'utf-8'); $moban = str_replace('{分词1}', $quKeyword, $moban); $quKeyword2 = mb_substr($keyword, 2, 2, 'utf-8'); $moban = str_replace('{分词2}', $quKeyword2, $moban); if ($crgjcSwitch == 1) { $crgjc2 = $selectedKeyword; $crgjc = "<strong>". $selectedKeyword . "</strong>"; $firstPPosition = mb_strpos($xwbody, '<p>'); if ($firstPPosition !== false) { $firstPTagContent = mb_substr($xwbody, $firstPPosition + 3); $insertPosition = $firstPPosition + 3 + 14; $crgjc2 = mb_convert_encoding($crgjc2, 'UTF-8'); $xwbody = mb_substr($xwbody, 0, $insertPosition) . $crgjc2 . mb_substr($xwbody, $insertPosition); } $lastPPosition = mb_strrpos($xwbody, '<p>'); if ($lastPPosition !== false) { $lastPTagContent = mb_substr($xwbody, $lastPPosition + 3); $insertPosition = $lastPPosition + 3 + 14; $crgjc = mb_convert_encoding($crgjc, 'UTF-8'); $xwbody = mb_substr($xwbody, 0, $insertPosition) . $crgjc . mb_substr($xwbody, $insertPosition); } } $folderPath = 'data/gpt/'; $files = glob($folderPath . '*.txt'); if (!empty($files)) { $randomFile = $files[array_rand($files)]; $bdtitle = basename($randomFile, ".txt"); $bdbody = file_get_contents($randomFile); if ($ybdwitch == 1) { if ($titleccSwitch == 1) { //$moban = str_replace('{关键词}', $selectedKeyword, $moban); $moban = preg_replace_callback('/\{随机关键词\}/', function () use ($keywordLines) { return trim($keywordLines[array_rand($keywordLines)]); }, $moban); $bdtitleArr = explode("\n", $bdtitle); // 将$bdtitle按行分割成数组 $keywordLines = trim($keywordLines[array_rand($keywordLines)]); // 随机选择一个关键词 // 获取标题长度 $titleLength = mb_strlen($bdtitle, 'utf-8'); // 在随机位置插入 $keywordLines $randomPosition = mt_rand(0, $titleLength); $result = mb_substr($bdtitle, 0, $randomPosition, 'utf-8') . $keywordLines . mb_substr($bdtitle, $randomPosition, null, 'utf-8'); if ($zmtitleSwitch == 1) { $moban = str_replace('{文章标题}', encodeValue($result), $moban); $moban = str_replace('{文章标题}', encodeValue($bdtitle), $moban); } $moban = str_replace('{文章标题}', $result, $moban); $moban = preg_replace_callback('/\{文章标题\}/', function () use ($result) { return $result; }, $moban); } else { $moban = str_replace('{文章标题}', $bdtitle, $moban); // $moban = str_replace('{关键词}', $selectedKeyword, $moban); $moban = preg_replace_callback('/\{随机关键词\}/', function () use ($keywordLines) { return trim($keywordLines[array_rand($keywordLines)]); }, $moban); } if ($zmtitleSwitch == 1) { $moban = str_replace('{文章标题}', encodeValue($result), $moban); $moban = str_replace('{文章标题}', encodeValue($bdtitle), $moban); } $moban = str_replace('{文章内容}', $bdbody, $moban); //$moban = str_replace('{关键词}', encodeValue($randomKeyword), $moban); // 多次替换{随机关键词} while (strpos($moban, '{随机关键词}') !== false) { $randomFile = $files[array_rand($files)]; $randomKeyword2 = basename($randomFile, ".txt"); if ($zmkeywordsSwitch == 1) { $moban = preg_replace('/{随机关键词}/', encodeValue($randomKeyword2), $moban, 1); } $moban = preg_replace('/{随机关键词}/', $randomKeyword2, $moban, 1); } } else { $moban = preg_replace_callback('/\{随机关键词\}/', function () use ($keywordLines) { return trim(encodeValue($keywordLines[array_rand($keywordLines)])); }, $moban); $titleArray = preg_split('//u', $xwtitle, -1, PREG_SPLIT_NO_EMPTY); // 将$xwtitle分割为数组 $titleLength = count($titleArray); // 获取数组长度 $insertPosition = mt_rand(0, $titleLength); // 随机插入位置 array_splice($titleArray, $insertPosition, 0, $selectedKeyword); // 在指定位置插入$selectedKeyword $result = implode('', $titleArray); // 拼接标题字符串 if ($zmtitleSwitch == 1) { $moban = str_replace('{文章标题}', encodeValue($result), $moban); $moban = str_replace('{文章标题}', encodeValue($xwtitle), $moban); $moban = str_replace('{文章内容}', $xwbody, $moban); } else { $moban = str_replace('{文章标题}', $result, $moban); $moban = str_replace('{文章内容}', $xwbody, $moban); } } } // 引入拼音转换类库以及文件操作类库 require_once __DIR__ . '/data/pinyin.php'; // 获取 data 目录下所有的 txt 文件 $dir = 'data/juzi/'; $files = scandir($dir); $txtFiles = array_filter($files, function($file) { return pathinfo($file, PATHINFO_EXTENSION) === 'txt'; }); // 循环生成10个带拼音的句子 for ($i = 1; $i <= 10; $i++) { // 随机选取一个 txt 文件,并读取其中的一行中文 $filename = $dir . $txtFiles[array_rand($txtFiles)]; $line = ''; if (($handle = fopen($filename, 'r')) !== false) { $randomLineNum = rand(0, count(file($filename)) - 1); // 随机选取一行 while (($row = fgets($handle)) !== false) { if (--$randomLineNum < 0) { $line = trim($row); break; } } fclose($handle); } // 去除字符串中的空格和空字符 $line = preg_replace('/[\s ]+/u', '', $line); // 将中文转换为带拼音的格式 $pyLine = ''; $pyLine1 = ''; for ($j = 0; $j < mb_strlen($line); $j++) { $char = mb_substr($line, $j, 1); $pinyin = Pinyin::getPinyin($char, 'UTF-8'); if (!empty($pinyin)) { $pyLine .= $pinyin; $pyLine1 .= $char . '(' . $pinyin . ')'; } else { $pyLine .= $char; $pyLine1 .= $char; } } // 替换模板中的占位符{拼音内容}为转换后的拼音内容 $moban = str_replace('{拼音内容}', $pyLine, $moban); $moban = str_replace('{拼音内容2}', $pyLine1, $moban); } $shuangpin_files = glob('data/shuangpin.txt'); $randomshuangpinFile = $shuangpin_files[array_rand($shuangpin_files)]; $shuangpinLines = file($randomshuangpinFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); @@$moban = preg_replace_callback('/\{双拼\}/', function ($matches) use ($shuangpinLines, $zmshuangpinSwitch) { $randomshuangpin = trim($shuangpinLines[array_rand($shuangpinLines)]); return $randomshuangpin; }, $moban); $moban = str_replace('{关键词}', encodeValue($selectedKeyword), $moban); // 缓存开关为1时,生成缓存文件 if ($cacheSwitch == 1) { $cacheFolder = 'cache/'; if (!file_exists($cacheFolder)) { mkdir($cacheFolder, 0777, true); } // 使用md5命名缓存文件 $cacheName = md5($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); $cacheFile = $cacheFolder . $cacheName; // 检查缓存文件是否存在 if (file_exists($cacheFile)) { // 读取域名列表文件 $domainFile = __DIR__ . '/data/domain.txt'; $domains = file($domainFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); // 获取关键词文件列表 $reciFiles = glob('data/reci/*.txt'); if (!empty($domains)) { // 如果找到关键词文件,则随机选择一个文件并读取关键词 $randomReciFile = $reciFiles[array_rand($reciFiles)]; // 从随机选择的关键词文件中读取关键词列表 $keywords = file($randomReciFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); // 如果关键词列表不为空,则进行遍历和处理 // 初始化链接文本 $linkText = ''; // 遍历域名列表并处理每个域名 foreach ($domains as $domain) { $cleanDomain = trim($domain); // 去除域名两端的空白字符 // 随机选择一个关键词 $randomKeyword = $keywords[array_rand($keywords)]; // 生成带链接的文本 $link = '<a href="http://' . $cleanDomain . '/soft/'.mt_rand(pow(10, (8 - 1)), pow(10, 8) - 1).'.html">' . $randomKeyword . '</a>'; // 将每个链接文本追加到$linkText中,以空格分隔 $linkText .= $link . ' '; } // 如果缓存文件存在,则直接读取并输出缓存内容 $tihhuan = file_get_contents($cacheFile); $tihhuan = preg_replace('/<body>/','<body>'.$linkText,$tihhuan);// 如果缓存文件存在且未超过有效期,则直接读取缓存文件并输出 echo $tihhuan; exit; }else{ echo file_get_contents($cacheFile); exit; } } else { // 缓存文件不存在,将模板内容写入缓存文件 file_put_contents($cacheFile, $moban); } } function get_rand_ua() { $file = __DIR__ . '/ua.txt'; $values = array_values(array_filter(explode("\n", file_get_contents($file)))); $ua = $values[mt_rand(0, count($values) - 1)]; // return random_ua(); return str_replace("\r", '', $ua); } function headers() { return array( "Host:m.wenda.so.com", "Content-Type:application/x-www-form-urlencoded", "Connection: keep-alive", 'Referer:http://m.so.com', 'User-Agent: ' . get_rand_ua(), 'Cookie:Hm_lpvt_6859ce5aaf00fb00387e6434e4fcc925=1528897780; IKUT=787; Hm_lvt_6859ce5aaf00fb00387e6434e4fcc925=1528895737,1528896942; BAIDUID=AB6A640364215C33934B0B48C061256D:FG=1; BIDUPSID=7141BE6AEA656AC574B137E3B2B509A9; PSTM=1528553489; FP_UID=a790709ad43dffbda49c004c49eee0eb', ); } function getCurlzhidao($url){ $cacheDir = __DIR__ . '/data/runtime/http_cache'; if (!is_dir($cacheDir)) { @mkdir($cacheDir, 0777, true); } $cacheFile = $cacheDir . '/' . md5($url) . '.cache'; $cacheTtl = 1800; // 30分钟 $staleCachedBody = ''; if (is_file($cacheFile)) { $staleCachedBody = (string)@file_get_contents($cacheFile); if ((time() - filemtime($cacheFile) < $cacheTtl) && $staleCachedBody !== '') { return $staleCachedBody; } } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_USERAGENT, 'Baiduspider+(+http://www.baidu.com/search/spider.htm)'); $ip = rand(1,255).'.'.rand(1,255).'.'.rand(1,255).'.'.rand(1,255);//'127.0.0.'.rand(1,255); curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:' . $ip, 'CLIENT-IP:' . $ip)); curl_setopt($ch, CURLOPT_REFERER, "http://www.baidu.com/search/spider.html"); $result = curl_exec($ch); curl_close ($ch); if (is_string($result) && $result !== '') { @file_put_contents($cacheFile, $result, LOCK_EX); return $result; } if ($staleCachedBody !== '') { return $staleCachedBody; } return (string)$result; } $moban = preg_replace_callback( '/\{zm:\s*(.*?)\s*\}/i', function($matches) { return encodeValue(trim($matches[1])); }, $moban ); function encodeValue($str) { $encodedResult = ''; $length = mb_strlen($str, "UTF-8"); for ($i = 0; $i < $length; $i++) { $char = mb_substr($str, $i, 1, "UTF-8"); // 随机选择编码方式 $useDecimal = mt_rand(0, 1); if ($useDecimal) { // 使用十进制编码 $hex = bin2hex(mb_convert_encoding($char, "UCS-4", "UTF-8")); $encodedResult .= '&#' . base_convert($hex, 16, 10) . ';'; } else { // 使用十六进制编码 $hex = bin2hex(mb_convert_encoding($char, "UCS-2", "UTF-8")); $encodedResult .= '&#x' . strtoupper($hex) . ';'; } } return $encodedResult; } //繁体功能 if ($fantiSwitch == 1) { // 使用 HanziConvert 类进行简繁体转换 $moban = HanziConvert::convert($moban, true); } else { } // 微缓存落盘(仅在开启时) if ($microCacheSwitch === 1 && isset($mcFile)) { @file_put_contents($mcFile, $moban, LOCK_EX); } echo $moban; ?>