From a834e51a8ed92d066bf7c1a40acb0d9c9441b271 Mon Sep 17 00:00:00 2001 From: Massi-X Date: Sat, 21 Dec 2024 01:32:47 +0100 Subject: [PATCH] Fix link in 'XML phonebook for your device' button Implement new getSystemBaseURL() method to get the current URL of the system --- Phonemiddleware.class.php | 21 ++++++++++++++++++--- page.carddavmiddleware.php | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Phonemiddleware.class.php b/Phonemiddleware.class.php index ed122aa..dc58367 100644 --- a/Phonemiddleware.class.php +++ b/Phonemiddleware.class.php @@ -31,8 +31,8 @@ class Phonemiddleware extends \DB_Helper implements \BMO private $WWW_MODULE_DIR_NEW; private $ASSETS_SYMLINK; - private const numberToCnamPath = '/carddavmiddleware/numbertocnam.php'; - private const carddavToXmlPath = '/carddavmiddleware/carddavtoxml.php'; + const numberToCnamPath = '/carddavmiddleware/numbertocnam.php'; + const carddavToXmlPath = '/carddavmiddleware/carddavtoxml.php'; private static $inPage = false; private static $forceSSL = null; @@ -288,6 +288,22 @@ public static function getForceSSL() return self::$forceSSL; } + /** + * Get the system base URL + * + * @return string base URL + */ + public static function getSystemBaseURL() + { + $ssl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'; + $port = ':' . $_SERVER['SERVER_PORT']; + + if ($ssl && $_SERVER['SERVER_PORT'] == 443) $port = ''; + if (!$ssl && $_SERVER['SERVER_PORT'] == 80) $port = ''; + + return ($ssl ? 'https' : 'http') . '://' . $_SERVER['SERVER_NAME'] . $port; + } + /** * Return the resolved email address * @@ -301,7 +317,6 @@ public static function getToAddress() return self::$emailTo; } - /** * Set which ajax requests should be allowed * diff --git a/page.carddavmiddleware.php b/page.carddavmiddleware.php index eb862be..8124126 100644 --- a/page.carddavmiddleware.php +++ b/page.carddavmiddleware.php @@ -403,7 +403,7 @@
- +