Loading... **自动收集网上的聚合节点订阅** 新建一个txt文档,复制以下代码进去,修改文件名为:index.php Token验证 *iloveyou* 可以修改为你自己的 打开网页:https://域名/test.php?token=iloveyou ``` <?php // Token验证https://域名/test.php?token=iloveyou if (!isset($_GET['token']) || $_GET['token'] !== 'iloveyou') {//因为作者是超绝恋爱脑 header("Content-Type: text/plain"); echo "你的TOKEN不对!"; exit; } set_time_limit(0); // 禁用脚本执行时间限制 // 缓存配置 $cache_file = __DIR__ . '/cache.txt'; $cache_time = 14400; // 4小时缓存 // 返回缓存内容(如果有效) if (file_exists($cache_file) && (time() - filemtime($cache_file) < $cache_time)) { header("Content-Type: text/plain"); echo file_get_contents($cache_file); exit; } // 完整URL列表 $urls = [ "https://raw.githubusercontent.com/aiboboxx/v2rayfree/main/v2", "https://raw.githubusercontent.com/shirkerboy/scp/main/sub", "https://jiang.netlify.app/", "https://fforever.github.io/v2rayfree/", "https://xlz767v2ray.pages.dev/sub/b9b8cf4c-29a3-4288-9c6c-8811dc37beec#BPB-Normal", "https://bpbv2ray.xlz767.ip-ddns.com/sub/b9b8cf4c-29a3-4288-9c6c-8811dc37beec#BPB-Normal", "https://www.xlz767.ip-ddns.com/proxy.php?url=https://edgetunnelworker.xlz.workers.dev/f47ac10b-58cc-4372-a567-0e02b2c3d479", "https://raw.githubusercontent.com/ripaojiedian/freenode/main/sub", "https://github.com/Huibq/TrojanLinks/raw/refs/heads/master/links/ss", "https://github.com/Huibq/TrojanLinks/raw/refs/heads/master/links/vmess", "https://github.com/Huibq/TrojanLinks/raw/refs/heads/master/links/trojan", "https://github.com/Huibq/TrojanLinks/raw/refs/heads/master/links/vless", "https://raw.githubusercontent.com/firefoxmmx2/v2rayshare_subcription/main/subscription/vray_sub.txt", "https://github.com/Roywaller/clash_subscription/raw/refs/heads/main/clash_subscription.txt", "https://q3dlaxpoaq.github.io/APIs/cg1.txt", "https://q3dlaxpoaq.github.io/APIs/cg3.txt", "https://q3dlaxpoaq.github.io/APIs/cg4.txt", "https://raw.githubusercontent.com/mahdibland/ShadowsocksAggregator/master/Eternity", "https://raw.githubusercontent.com/mahdibland/ShadowsocksAggregator/master/EternityAir", "https://raw.githubusercontent.com/snakem982/proxypool/main/source/v2ray.txt", "https://raw.githubusercontent.com/snakem982/proxypool/main/source/v2ray-2.txt" ]; // 存储唯一节点 $uniqueNodes = []; // CURL全局配置 $curl_options = [ CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 5, CURLOPT_CONNECTTIMEOUT => 3, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 3, CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' ]; // 分批次处理(每批5个URL) $batchSize = 5; foreach (array_chunk($urls, $batchSize) as $urlChunk) { $mh = curl_multi_init(); $handles = []; // 初始化批处理请求 foreach ($urlChunk as $url) { $ch = curl_init($url); curl_setopt_array($ch, $curl_options); curl_multi_add_handle($mh, $ch); $handles[] = $ch; } // 执行并行请求 $active = null; do { $status = curl_multi_exec($mh, $active); if ($active && curl_multi_select($mh) === -1) { usleep(100); } } while ($active && $status == CURLM_OK); // 处理响应 foreach ($handles as $ch) { $content = curl_multi_getcontent($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($httpCode == 200 && !empty($content)) { $content = preg_replace('/\s+/', '', trim($content)); if (preg_match('/^[a-zA-Z0-9+\/]+={0,2}$/', $content)) { $decoded = base64_decode($content, true); if ($decoded !== false) { // 分割节点并去重 $nodes = array_filter(explode("\n", $decoded), function($line) { return !empty(trim($line)); }); foreach ($nodes as $node) { $cleanNode = trim($node); $uniqueNodes[$cleanNode] = true; // 利用键名去重 } } } } // 清理句柄 curl_multi_remove_handle($mh, $ch); curl_close($ch); } curl_multi_close($mh); } // 生成最终内容 $finalContent = implode("\n", array_keys($uniqueNodes)); $finalBase64 = !empty($finalContent) ? base64_encode($finalContent) : base64_encode(''); // 原子化写入缓存 $tempCache = tempnam(__DIR__, 'cache_temp'); if ($tempCache && file_put_contents($tempCache, $finalBase64)) { rename($tempCache, $cache_file); } // 输出结果 header("Content-Type: text/plain"); echo $finalBase64; ?> ``` 最后修改:2025 年 04 月 15 日 © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏