Add update_com.woltlab.wcf_5.5_checkUpdateServers.php
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 11 May 2022 14:25:45 +0000 (16:25 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 11 May 2022 14:34:50 +0000 (16:34 +0200)
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.5_checkUpdateServers.php [new file with mode: 0644]

diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.5_checkUpdateServers.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.5_checkUpdateServers.php
new file mode 100644 (file)
index 0000000..7b547ed
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * Checks for non-TLS update servers.
+ *
+ * @author  Tim Duesterhus
+ * @copyright   2001-2022 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core
+ */
+
+use Laminas\Diactoros\Uri;
+use wcf\data\package\update\server\PackageUpdateServerList;
+use wcf\system\WCF;
+
+$list = new PackageUpdateServerList();
+$list->readObjects();
+
+foreach ($list as $server) {
+    $uri = new Uri($server->serverURL);
+
+    if ($uri->getScheme() !== 'https') {
+        if (WCF::getLanguage()->getFixedLanguageCode() === 'de') {
+            $message = "Der Paketserver '{$uri}' verwendet das unverschl&uuml;sselte http-Protokoll.";
+        } else {
+            $message = "The package server '{$uri}' uses the unencrypted 'http' scheme.";
+        }
+
+        throw new \RuntimeException($message);
+    }
+    if ($uri->getPort()) {
+        if (WCF::getLanguage()->getFixedLanguageCode() === 'de') {
+            $message = "Der Paketserver '{$uri}' verwendet nicht den Standard-Port.";
+        } else {
+            $message = "The package server '{$uri}' uses a non-standard port.";
+        }
+
+        throw new \RuntimeException($message);
+    }
+}