diff --git a/exec/lib/Http.php b/exec/lib/Http.php index aea8b71..74f752b 100644 --- a/exec/lib/Http.php +++ b/exec/lib/Http.php @@ -90,7 +90,25 @@ final class Http public static function redirect(string $url): void { + if (PHP_SAPI === 'cli') { + header('Content-Type: text/html; charset=UTF-8'); + echo self::redirectDocument($url); + exit; + } header('Location: ' . $url, true, 302); exit; } + + public static function redirectDocument(string $url): string + { + $safeUrl = htmlspecialchars($url, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); + $jsonUrl = json_encode($url, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT); + return '
' . + '' . + '' . + 'Przekierowanie... Kontynuuj
' . + '' . + ''; + } } diff --git a/plugin.conf b/plugin.conf index 6402ff9..bbfe99c 100644 --- a/plugin.conf +++ b/plugin.conf @@ -2,7 +2,7 @@ name=global-autoresponder id=global-autoresponder type=user author=HITME.PL -version=1.1.3 +version=1.1.4 active=no installed=no user_run_as=root diff --git a/tests/http_test.php b/tests/http_test.php new file mode 100644 index 0000000..f6817fb --- /dev/null +++ b/tests/http_test.php @@ -0,0 +1,13 @@ +