From 091c0442e8d5d0e0641b9be51e00578b9d3220ff Mon Sep 17 00:00:00 2001 From: Lorenzo Yario Date: Sat, 11 May 2024 04:42:45 -0700 Subject: [PATCH] allow cloudflare and other proxies to still count as https --- inc/functions/net.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/inc/functions/net.php b/inc/functions/net.php index ab08c3cb..ebf578e7 100644 --- a/inc/functions/net.php +++ b/inc/functions/net.php @@ -6,5 +6,13 @@ namespace Vichan\Functions\Net; * @return bool Returns if the client-server connection is an encrypted one (HTTPS). */ function is_connection_secure(): bool { - return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'; + if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') { + return true; + } + elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { + return true; + } + else { + return false; + } }