?") !== false) { $message = "文件名包含非法字符,请使用字母、数字、点、下划线或横杠。"; logMessage($message); return $message; } if (!is_dir($download_path)) { if (!mkdir($download_path, 0755, true)) { $message = "无法创建目录:$download_path"; logMessage($message); return $message; } } $output_file = escapeshellarg($download_path . $filename); $command = "wget -q --no-check-certificate -O $output_file " . escapeshellarg($url); exec($command, $output, $return_var); if ($return_var !== 0) { $message = "wget 错误,无法获取订阅内容。请检查链接是否正确。"; logMessage($message); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $subscription_data = curl_exec($ch); if (curl_errno($ch)) { $error_msg = curl_error($ch); curl_close($ch); $message = "cURL 错误: $error_msg"; logMessage($message); return $message; } curl_close($ch); if (empty($subscription_data)) { $message = "无法获取订阅内容。请检查链接是否正确。"; logMessage($message); return $message; } $decoded_data = (base64_decode($subscription_data, true) !== false) ? base64_decode($subscription_data) : $subscription_data; $transformed_data = transformContent($decoded_data); $file_path = $download_path . $filename; $success = file_put_contents($file_path, $transformed_data) !== false; $message = $success ? "内容已成功保存到:$file_path" : "文件保存失败。"; logMessage($message); return $message; } function generateShellScript() { global $subscription_file, $download_path, $sh_script_path; $sh_script_content = << "\$DOWNLOAD_PATH/config.yaml" mv "\$DOWNLOAD_PATH/config.yaml" "\$DEST_PATH" if [ $? -eq 0 ]; then echo "配置文件已成功更新并移动到 \$DEST_PATH" else echo "配置文件移动失败" exit 1 fi EOD; $success = file_put_contents($sh_script_path, $sh_script_content) !== false; logMessage($success ? "Shell 脚本已成功创建并赋予执行权限。" : "无法创建 Shell 脚本文件。"); if ($success) { shell_exec("chmod +x $sh_script_path"); } return $success ? "Shell 脚本已成功创建并赋予执行权限。" : "无法创建 Shell 脚本文件。"; } function setupCronJob($cron_time) { global $sh_script_path; $cron_entry = "$cron_time $sh_script_path\n"; $current_cron = shell_exec('crontab -l 2>/dev/null'); if (empty($current_cron)) { $updated_cron = $cron_entry; } else { $updated_cron = preg_replace('/.*' . preg_quote($sh_script_path, '/') . '/m', $cron_entry, $current_cron); if ($updated_cron == $current_cron) { $updated_cron .= $cron_entry; } } $success = file_put_contents('/tmp/cron.txt', $updated_cron) !== false; if ($success) { shell_exec('crontab /tmp/cron.txt'); logMessage("Cron 作业已成功设置为 $cron_time 运行。"); return "Cron 作业已成功设置为 $cron_time 运行。"; } else { logMessage("无法写入临时 Cron 文件。"); return "无法写入临时 Cron 文件。"; } } $result = ''; $cron_result = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $templates = [ '1' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_NoAuto.ini?', '2' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_MultiCountry.ini?', '3' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full.ini?', '4' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_Google.ini?', '5' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_MultiMode.ini?', '6' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_Netflix.ini?', '7' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/default_with_clash_adg.yml?', '8' => 'https://raw.githubusercontent.com/WC-Dream/ACL4SSR/WD/Clash/config/ACL4SSR_Online_Full_Dream.ini?', '9' => 'https://raw.githubusercontent.com/WC-Dream/ACL4SSR/WD/Clash/config/ACL4SSR_Mini_Dream.ini?', '10' => 'https://raw.githubusercontent.com/justdoiting/ClashRule/main/GeneralClashRule.ini?', '11' => 'https://raw.githubusercontent.com/lhl77/sub-ini/main/tsutsu-full.ini?', '12' => 'https://raw.githubusercontent.com/Mazeorz/airports/master/Clash/Examine_Full.ini?', '13' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/lhie1_dler.ini?', '14' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/connershua_backtocn.in?', ]; $filename = isset($_POST['filename']) && $_POST['filename'] !== '' ? $_POST['filename'] : 'config.yaml'; $subscription_url = isset($_POST['subscription_url']) ? $_POST['subscription_url'] : ''; $backend_url = $_POST['backend_url'] ?? 'https://url.v1.mk/sub?'; $template_key = $_POST['template'] ?? ''; $include = $_POST['include'] ?? ''; $exclude = $_POST['exclude'] ?? ''; $template = $templates[$template_key] ?? ''; $final_url = buildFinalUrl($subscription_url, $template, $include, $exclude, $backend_url); if (saveSubscriptionUrlToFile($final_url, $subscription_file)) { $result = saveSubscriptionContentToYaml($final_url, $filename); $result .= generateShellScript() . "
"; if (isset($_POST['cron_time'])) { $cron_time = $_POST['cron_time']; $cron_result .= setupCronJob($cron_time) . "
"; } } else { echo "保存订阅链接到文件失败。"; } } function getSubscriptionUrlFromFile($file) { if (file_exists($file)) { return file_get_contents($file); } return ''; } ?> Personal - Neko
🏠 首页 📂 文件管理 🗂️ Mihomo 💹 Sing-box

Mihomo 订阅转换模板

帮助说明

欢迎使用 Mihomo 订阅程序!请按照以下步骤进行操作:

  • 输入订阅链接: 在文本框中输入您的 Clash 订阅链接。
  • 输入保存文件名: 指定保存配置文件的文件名,默认为 "config.yaml",无需添加后缀。
  • 点击 "生成订阅链接" 按钮,系统将下载订阅内容,并进行转换和保存。
  • 推荐使用文件管理的Mihomo订阅