From 741f402ca137fcfb8d69ca6974b2a728aa7aa2a1 Mon Sep 17 00:00:00 2001 From: mercury Date: Wed, 14 Aug 2024 23:52:21 +0400 Subject: [PATCH] fix singbox import --- app/bot.php | 10 +++++++--- app/index.php | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/bot.php b/app/bot.php index 0080bd1..2baacdb 100644 --- a/app/bot.php +++ b/app/bot.php @@ -4320,11 +4320,15 @@ DNS-over-HTTPS with IP: } if (!empty($_GET['r'])) { - $si = "$scheme://{$domain}/pac?h=$hash&t=si&s=$uid"; + $si = "$scheme://{$domain}/pac/" . base64_encode(serialize([ + 'h' => $hash, + 't' => 'si', + 's' => $uid, + ])); $v2 = "$scheme://{$domain}/pac?h=$hash&t=s&s=$uid"; switch ($_GET['r']) { case 'si': - header("Location: sing-box://import-remote-profile/?url=" . urlencode($si)); + header("Location: sing-box://import-remote-profile/?url=" . $si); exit; case 'st': header("Location: streisand://import/$v2"); @@ -4333,7 +4337,7 @@ DNS-over-HTTPS with IP: header("Location: v2rayng://install-config?url=" . urlencode($v2)); exit; case 'h': - header("Location: hiddify://install-config/?url=" . urlencode($si)); + header("Location: hiddify://install-config/?url=" . $si); exit; case 'w': $link = htmlspecialchars($si, ENT_XML1, 'UTF-8'); diff --git a/app/index.php b/app/index.php index 8fec39b..938f1d1 100644 --- a/app/index.php +++ b/app/index.php @@ -17,10 +17,13 @@ if ('POST' == $_SERVER['REQUEST_METHOD'] && $_GET['k'] == $c['key']) { } // pac -$type = $_GET['t'] ?? 'pac'; +if (!empty($t = unserialize(base64_decode(explode('/', $_SERVER['REQUEST_URI'])[2])))) { // fix sing-box import + $_GET = array_merge($_GET, $t); +} +$type = $_GET['t'] ?? 'pac'; $address = $_GET['a'] ?: '127.0.0.1'; -$port = $_GET['p'] ?: '1080'; -$hash = $_GET['h']; +$port = $_GET['p'] ?: '1080'; +$hash = $_GET['h']; if ($hash == substr(md5($c['key']), 0, 8)) { require __DIR__ . '/bot.php'; require __DIR__ . '/i18n.php';