From 9ae20a626b29eeea7697aa73ec438a643b630eb6 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 22 Jun 2024 19:32:11 +0200 Subject: [PATCH] Add a preflight script for the upgrade from 6.0 --- ...oltlab.wcf_6.1_checkSystemRequirements.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_checkSystemRequirements.php diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_checkSystemRequirements.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_checkSystemRequirements.php new file mode 100644 index 0000000000..d6521c53f4 --- /dev/null +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_checkSystemRequirements.php @@ -0,0 +1,37 @@ + + * @since 6.1 + */ + +use wcf\system\request\RouteHandler; +use wcf\system\WCF; + +$checkForTls = function () { + if (RouteHandler::secureConnection()) { + return true; + } + + // @see RouteHandler::secureContext() + $host = $_SERVER['HTTP_HOST']; + if ($host === '127.0.0.1' || $host === 'localhost' || \str_ends_with($host, '.localhost')) { + return true; + } + + return false; +}; + +if (!$checkForTls()) { + if (WCF::getLanguage()->getFixedLanguageCode() === 'de') { + $message = "Die Seite wird nicht über HTTPS aufgerufen. Wichtige Funktionen stehen dadurch nicht zur Verfügung, die für die korrekte Funktionsweise der Software erforderlich sind."; + } else { + $message = "The page is not accessed via HTTPS. Important features that are required for the proper operation of the software are therefore not available."; + } + + throw new \RuntimeException($message); +} -- 2.20.1