?") !== 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_Full_AdblockPlus.ini?', '3' => 'https://raw.githubusercontent.com/youshandefeiyang/webcdn/main/SONY.ini', '4' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/default_with_clash_adg.yml?', '5' => 'https://raw.githubusercontent.com/WC-Dream/ACL4SSR/WD/Clash/config/ACL4SSR_Online_Full_Dream.ini?', '6' => 'https://raw.githubusercontent.com/WC-Dream/ACL4SSR/WD/Clash/config/ACL4SSR_Mini_Dream.ini?', '7' => 'https://raw.githubusercontent.com/justdoiting/ClashRule/main/GeneralClashRule.ini?', '8' => 'https://raw.githubusercontent.com/cutethotw/ClashRule/main/GeneralClashRule.ini?', '9' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online.ini?', '10' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_NoAuto.ini?', '11' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_AdblockPlus.ini?', '12' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_MultiCountry.ini?', '13' => 'ttps://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_NoReject.ini?', '14' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_NoAuto.ini?', '15' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full.ini?', '16' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_Google.ini?', '17' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_MultiMode.ini?', '18' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_Netflix.ini?', '19' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini.ini?', '20' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_AdblockPlus.ini?', '21' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_Fallback.ini?', '22' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_MultiCountry.ini?', '23' => 'https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_MultiMode.ini?', '24' => 'https://raw.githubusercontent.com/flyhigherpi/merlinclash_clash_related/master/Rule_config/ZHANG.ini?', '25' => 'https://raw.githubusercontent.com/xiaoshenxian233/cool/rule/complex.ini?', '26' => 'https://subweb.s3.fr-par.scw.cloud/RemoteConfig/special/phaors.ini?', '27' => 'https://raw.githubusercontent.com/flyhigherpi/merlinclash_clash_related/master/Rule_config/ZHANG_Area_Fallback.ini?', '28' => 'https://raw.githubusercontent.com/flyhigherpi/merlinclash_clash_related/master/Rule_config/ZHANG_Area_Urltest.ini?', '29' => 'https://raw.githubusercontent.com/flyhigherpi/merlinclash_clash_related/master/Rule_config/ZHANG_Area_NoAuto.ini?', '30' => 'https://raw.githubusercontent.com/OoHHHHHHH/ini/master/config.ini?', '31' => 'https://raw.githubusercontent.com/OoHHHHHHH/ini/master/cfw-tap.ini?', '32' => 'https://raw.githubusercontent.com/lhl77/sub-ini/main/tsutsu-full.ini?', '33' => 'https://raw.githubusercontent.com/lhl77/sub-ini/main/tsutsu-mini-gfw.ini?', '34' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/connershua_new.ini?', '35' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/connershua_backtocn.ini?', '36' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/lhie1_clash.ini?', '37' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/lhie1_dler.ini?', '38' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/ehpo1_main.ini?', '39' => 'https://raw.nameless13.com/api/public/dl/ROzQqi2S/white.ini?', '40' => 'https://raw.nameless13.com/api/public/dl/ptLeiO3S/mayinggfw.ini?', '41' => 'https://raw.nameless13.com/api/public/dl/FWSh3dXz/easy3.ini?', '42' => 'https://raw.nameless13.com/api/public/dl/L_-vxO7I/youtube.ini?', '43' => 'https://raw.nameless13.com/api/public/dl/zKF9vFbb/easy.ini?', '44' => 'https://raw.nameless13.com/api/public/dl/E69bzCaE/easy2.ini?', '45' => 'https://raw.nameless13.com/api/public/dl/XHr0miMg/ipip.ini?', '46' => 'https://raw.nameless13.com/api/public/dl/BBnfb5lD/MAYINGVIP.ini?', '47' => 'https://raw.githubusercontent.com/Mazeorz/airports/master/Clash/Examine.ini?', '48' => 'https://raw.githubusercontent.com/Mazeorz/airports/master/Clash/Examine_Full.ini?', '49' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/nzw9314_custom.ini?', '50' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/maicoo-l_custom.ini?', '51' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/dlercloud_lige_platinum.ini?', '52' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/dlercloud_lige_gold.ini?', '53' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/dlercloud_lige_silver.ini?', '54' => 'https://unpkg.com/proxy-script/config/Clash/clash.ini?', '55' => 'https://github.com/UlinoyaPed/ShellClash/raw/master/rules/ShellClash.ini?', '56' => 'https://gist.github.com/jklolixxs/16964c46bad1821c70fa97109fd6faa2/raw/EXFLUX.ini?', '57' => 'https://gist.github.com/jklolixxs/32d4e9a1a5d18a92beccf3be434f7966/raw/NaNoport.ini?', '58' => 'https://gist.github.com/jklolixxs/dfbe0cf71ffc547557395c772836d9a8/raw/CordCloud.ini?', '59' => 'https://gist.github.com/jklolixxs/e2b0105c8be6023f3941816509a4c453/raw/BigAirport.ini?', '60' => 'https://gist.github.com/jklolixxs/9f6989137a2cfcc138c6da4bd4e4cbfc/raw/PaoLuCloud.ini?', '61' => 'https://gist.github.com/jklolixxs/fccb74b6c0018b3ad7b9ed6d327035b3/raw/WaveCloud.ini?', '62' => 'https://gist.github.com/jklolixxs/bfd5061dceeef85e84401482f5c92e42/raw/JiJi.ini?', '63' => 'https://gist.github.com/jklolixxs/6ff6e7658033e9b535e24ade072cf374/raw/SJ.ini?', '64' => 'https://gist.github.com/jklolixxs/24f4f58bb646ee2c625803eb916fe36d/raw/ImmTelecom.ini?', '65' => 'https://gist.github.com/jklolixxs/b53d315cd1cede23af83322c26ce34ec/raw/AmyTelecom.ini?', '66' => 'https://subweb.s3.fr-par.scw.cloud/RemoteConfig/customized/convenience.ini?', '67' => 'https://gist.github.com/jklolixxs/ff8ddbf2526cafa568d064006a7008e7/raw/Miaona.ini?', '68' => 'https://gist.github.com/jklolixxs/df8fda1aa225db44e70c8ac0978a3da4/raw/Foo&Friends.ini?', '69' => 'https://gist.github.com/jklolixxs/b1f91606165b1df82e5481b08fd02e00/raw/ABCloud.ini?', '70' => 'https://raw.githubusercontent.com/SleepyHeeead/subconverter-config/master/remote-config/customized/xianyu.ini?', '71' => 'https://subweb.oss-cn-hongkong.aliyuncs.com/RemoteConfig/customized/convenience.ini?', '72' => 'https://raw.githubusercontent.com/Mazeorz/airports/master/Clash/SSRcloud.ini?', '73' => 'https://raw.githubusercontent.com/Mazetsz/ACL4SSR/master/Clash/config/V2rayPro.ini?', '74' => 'https://raw.githubusercontent.com/Mazeorz/airports/master/Clash/V2Pro.ini?', '75' => 'https://raw.githubusercontent.com/Mazeorz/airports/master/Clash/Stitch.ini?', '76' => 'https://raw.githubusercontent.com/Mazeorz/airports/master/Clash/Stitch-Balance.ini?', '77' => 'https://raw.githubusercontent.com/SleepyHeeead/subconverter-config/master/remote-config/customized/maying.ini?', '78' => 'https://subweb.s3.fr-par.scw.cloud/RemoteConfig/customized/ytoo.ini?', '79' => 'https://raw.nameless13.com/api/public/dl/M-We_Fn7/w8ves.ini?', '80' => 'https://raw.githubusercontent.com/SleepyHeeead/subconverter-config/master/remote-config/customized/nyancat.ini?', '81' => 'https://subweb.s3.fr-par.scw.cloud/RemoteConfig/customized/nexitally.ini?', '82' => 'https://raw.githubusercontent.com/SleepyHeeead/subconverter-config/master/remote-config/customized/socloud.ini?', '83' => 'https://raw.githubusercontent.com/SleepyHeeead/subconverter-config/master/remote-config/customized/ark.ini?', '84' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/n3ro_optimized.ini?', '85' => 'https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/scholar_optimized.ini?', '86' => 'https://subweb.s3.fr-par.scw.cloud/RemoteConfig/customized/flower.ini?', '88' => 'https://raw.githubusercontent.com/SleepyHeeead/subconverter-config/master/remote-config/special/netease.ini?', '89' => 'https://raw.githubusercontent.com/SleepyHeeead/subconverter-config/master/remote-config/special/basic.ini?' ]; $emoji = isset($_POST['emoji']) ? $_POST['emoji'] === 'true' : true; $udp = isset($_POST['udp']) ? $_POST['udp'] === 'true' : true; $xudp = isset($_POST['xudp']) ? $_POST['xudp'] === 'true' : true; $tfo = isset($_POST['tfo']) ? $_POST['tfo'] === 'true' : true; $fdn = isset($_POST['fdn']) ? $_POST['fdn'] === 'true' : true; $sort = isset($_POST['sort']) ? $_POST['sort'] === 'true' : true; $tls13 = isset($_POST['tls13']) ? $_POST['tls13'] === 'true' : true; $filename = isset($_POST['filename']) && $_POST['filename'] !== '' ? $_POST['filename'] : 'config.yaml'; $subscription_url = isset($_POST['subscription_url']) ? $_POST['subscription_url'] : ''; $backend_url = isset($_POST['backend_url']) && $_POST['backend_url'] === 'custom' && !empty($_POST['custom_backend_url']) ? rtrim($_POST['custom_backend_url'], '?') . '?' : ($_POST['backend_url'] ?? 'https://url.v1.mk/sub?'); $template_key = $_POST['template'] ?? ''; $include = $_POST['include'] ?? ''; $exclude = $_POST['exclude'] ?? ''; $template = $templates[$template_key] ?? ''; $rename = isset($_POST['rename']) ? $_POST['rename'] : ''; if (isset($_POST['action'])) { if ($_POST['action'] === 'generate_subscription') { $final_url = buildFinalUrl($subscription_url, $template, $include, $exclude, $backend_url, $emoji, $udp, $xudp, $tfo, $rename, $tls13, $fdn, $sort); 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 "保存订阅链接到文件失败。"; } } elseif ($_POST['action'] === 'update_cron') { if (isset($_POST['cron_time']) && $_POST['cron_time']) { $cron_time = $_POST['cron_time']; $cron_result = setupCronJob($cron_time); } } } } function getSubscriptionUrlFromFile($file) { if (file_exists($file)) { return file_get_contents($file); } return ''; } ?> Mihomo - Nekobox
Home Manager Template I Template II Template III

>
>
>
>
>
>
>