/dev/null'); $updatedCrons = preg_replace( "/^.*".preg_quote($shellScriptPath, '/').".*$/m", '', $currentCrons ); $updatedCrons = trim($updatedCrons) . "\n" . $cronJob . "\n"; $tempCronFile = tempnam(sys_get_temp_dir(), 'cron'); file_put_contents($tempCronFile, $updatedCrons); exec("crontab $tempCronFile"); unlink($tempCronFile); echo "
定时任务已设置: $cronExpression
"; } else { echo "
无效的 Cron 表达式,请检查格式。
"; } } ?> 订阅链接不能为空。"; exit; } echo "
提交成功: 订阅链接已保存为 $SUBSCRIBE_URL
"; } if (isset($_POST['createShellScript'])) { $shellScriptContent = <<> "\$LOG_FILE" exit 1 fi echo "\$(date): 使用的订阅链接: \$SUBSCRIBE_URL" >> "\$LOG_FILE" CONFIG_DIR="/etc/neko/config" if [ ! -d "\$CONFIG_DIR" ]; then mkdir -p "\$CONFIG_DIR" if [ \$? -ne 0 ]; then echo "\$(date): 无法创建配置目录: \$CONFIG_DIR" >> "\$LOG_FILE" exit 1 fi fi CONFIG_FILE="\$CONFIG_DIR/sing-box.json" wget -O "\$CONFIG_FILE" "\$SUBSCRIBE_URL" >> "\$LOG_FILE" 2>&1 if [ \$? -eq 0 ]; then echo "\$(date): 配置文件更新成功,保存路径: \$CONFIG_FILE" >> "\$LOG_FILE" else echo "\$(date): 配置文件更新失败,请检查链接或网络。" >> "\$LOG_FILE" exit 1 fi EOL; if (file_put_contents($shellScriptPath, $shellScriptContent) !== false) { chmod($shellScriptPath, 0755); echo "
Shell 脚本已创建成功!路径: $shellScriptPath
"; } else { echo "
无法创建 Shell 脚本,请检查权限。
"; } } } ?> singbox - Nekobox
🏠 首页 🗃️ 文件管理 🏪 模板 一 🏦 模板 二 🏣 模板 三

Sing-box 订阅转换模板 一

帮助信息

请选择一个模板以生成配置文件:根据订阅节点信息选择相应的模板。若选择带有地区分组的模板,请确保您的节点包含以下线路。

  • 模板 1:无地区 无分组 通用。
  • 模板 2:无地区 带分流规则 通用。
  • 模板 3:香港 日本 美国 分组 带分流规则。
  • 模板 4:香港 新加坡 日本 美国 分组 带分流规则。
  • 模板 5:新加坡 日本 美国 韩国 分组 带分流规则。
  • 模板 6:香港 台湾 新加坡 日本 美国 韩国 分组 带分流规则。
  • 模板 7:同上多规则。
选择模板
10) { array_shift($logEntries); } file_put_contents($dataFilePath, implode("\n\n", $logEntries) . "\n\n"); $subscribeUrlEncoded = urlencode($subscribeUrl); if (isset($_POST['defaultTemplate']) && $_POST['defaultTemplate'] == '0') { $templateUrlEncoded = ''; } elseif ($templateOption === 'custom' && !empty($customTemplateUrl)) { $templateUrlEncoded = urlencode($customTemplateUrl); } else { $defaultTemplates = [ '1' => "https://raw.githubusercontent.com/Thaolga/Rules/main/Clash/json/config_7.json", '2' => "https://raw.githubusercontent.com/Thaolga/Rules/main/Clash/json/config_6.json", '3' => "https://raw.githubusercontent.com/Thaolga/Rules/main/Clash/json/config_9.json", '4' => "https://raw.githubusercontent.com/Thaolga/Rules/main/Clash/json/config_10.json", '5' => "https://raw.githubusercontent.com/Thaolga/Rules/main/Clash/json/config_11.json", '6' => "https://raw.githubusercontent.com/Thaolga/Rules/main/Clash/json/config_8.json", '7' => "https://raw.githubusercontent.com/Thaolga/Rules/main/Clash/json/config_12.json" ]; $templateUrlEncoded = urlencode($defaultTemplates[$_POST['defaultTemplate']] ?? ''); } if (empty($templateUrlEncoded)) { $completeSubscribeUrl = "https://sing-box-subscribe-doraemon.vercel.app/config/{$subscribeUrlEncoded}"; } else { $completeSubscribeUrl = "https://sing-box-subscribe-doraemon.vercel.app/config/{$subscribeUrlEncoded}&file={$templateUrlEncoded}"; } $tempFilePath = '/etc/neko/' . $customFileName; $logMessages = []; $command = "wget -O " . escapeshellarg($tempFilePath) . " " . escapeshellarg($completeSubscribeUrl); exec($command, $output, $returnVar); if ($returnVar !== 0) { $command = "curl -s -L -o " . escapeshellarg($tempFilePath) . " " . escapeshellarg($completeSubscribeUrl); exec($command, $output, $returnVar); if ($returnVar !== 0) { $logMessages[] = "无法下载内容: " . htmlspecialchars($completeSubscribeUrl); } } if ($returnVar === 0) { $downloadedContent = file_get_contents($tempFilePath); if ($downloadedContent === false) { $logMessages[] = "无法读取下载的文件内容"; } else { if (isset($_POST['defaultTemplate']) && $_POST['defaultTemplate'] == '0') { $replacement = ' "clash_api": { "external_ui": "/etc/neko/ui/", "external_controller": "0.0.0.0:9090", "secret": "Akun", "external_ui_download_url": "" },'; $downloadedContent = preg_replace('/"clash_api":\s*\{.*?\},/s', $replacement, $downloadedContent); } $tmpFileSavePath = '/etc/neko/tmp/' . $fixedFileName; if (file_put_contents($tmpFileSavePath, $completeSubscribeUrl) === false) { $logMessages[] = "无法保存订阅URL到文件: " . $tmpFileSavePath; } else { $logMessages[] = "订阅URL已成功保存到文件: " . $tmpFileSavePath; } $configFilePath = '/etc/neko/config/' . $customFileName; if (file_put_contents($configFilePath, $downloadedContent) === false) { $logMessages[] = "无法保存修改后的内容到: " . $configFilePath; } else { $logMessages[] = "配置文件生成并保存成功: " . $configFilePath; } } } echo "
"; echo "
"; echo "
"; echo ""; echo "
"; echo "
"; echo ""; echo ""; echo ""; echo "
"; echo "
"; echo "
"; echo "
"; foreach ($logMessages as $message) { echo $message . "
"; } echo "
"; } if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['saveContent'])) { if (isset($_POST['configContent'])) { $editedContent = trim($_POST['configContent']); if (file_put_contents($configFilePath, $editedContent) === false) { echo "
无法保存修改后的内容到: " . htmlspecialchars($configFilePath) . "
"; } else { echo "
内容已成功保存到: " . htmlspecialchars($configFilePath) . "
"; } } } if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['clearData'])) { if (file_exists($dataFilePath)) { file_put_contents($dataFilePath, ''); echo "
保存的数据已清空。
"; } } if (file_exists($dataFilePath)) { $savedData = file_get_contents($dataFilePath); echo "
"; echo "
"; echo "

保存的数据

"; echo "
" . htmlspecialchars($savedData) . "
"; echo "
"; echo ""; echo "
"; echo "
"; echo "
"; } ?>