From 10c658c9201f4cb74abf8a2281004332beb3db82 Mon Sep 17 00:00:00 2001 From: liu Date: Sun, 7 Apr 2024 15:51:41 +0800 Subject: [PATCH] Complete User-Agent Check. Fix style. --- plugin.php | 16 ++++++++++++++++ redirect_page.php | 1 + 2 files changed, 17 insertions(+) diff --git a/plugin.php b/plugin.php index acc783f..cb592f8 100644 --- a/plugin.php +++ b/plugin.php @@ -27,6 +27,22 @@ function safe_redirect($args) { if ($setting_option) { $setting = unserialize($setting_option); + // Check user agent + $user_agent = $setting['user_agent']; + if ($user_agent) { + $user_agent = explode("\r\n", $user_agent); + $is_redirect = false; + foreach ($user_agent as $ua) { + if (str_contains($_SERVER['HTTP_USER_AGENT'], $ua)) { + $is_redirect = true; + break; + } + } + if (!$is_redirect) { + return; + } + } + if ($setting['relay_domain'] && $setting['relay_domain'] != $_SERVER['HTTP_HOST']) { //redirect to relay domain header('Location: ' . ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? $_SERVER['REQUEST_SCHEME']) . '://' . $setting['relay_domain'] . $_SERVER['REQUEST_URI']); diff --git a/redirect_page.php b/redirect_page.php index 2c4b981..3cb4ce9 100644 --- a/redirect_page.php +++ b/redirect_page.php @@ -46,6 +46,7 @@ function countdown() { } p span { color: red; + word-wrap: break-word; }