Skip to content

Commit

Permalink
Complete User-Agent Check.
Browse files Browse the repository at this point in the history
Fix style.
  • Loading branch information
imydou committed Apr 7, 2024
1 parent 5b7dee6 commit 10c658c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
1 change: 1 addition & 0 deletions redirect_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function countdown() {
}
p span {
color: red;
word-wrap: break-word;
}
</style>
</head>
Expand Down

0 comments on commit 10c658c

Please sign in to comment.