From 244b6eca24b0f4e768e777fb699dfb4b46098ba1 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Mon, 8 Jun 2020 22:44:49 +0200 Subject: [PATCH] Added base_uri to config classes --- Core/Frameworks/Baikal/Model/Config/Standard.php | 5 +++-- Core/Frameworks/Flake/Framework.php | 11 ++++------- config/baikal.yaml.dist | 1 + 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Core/Frameworks/Baikal/Model/Config/Standard.php b/Core/Frameworks/Baikal/Model/Config/Standard.php index 804a3c2..1ef5a51 100644 --- a/Core/Frameworks/Baikal/Model/Config/Standard.php +++ b/Core/Frameworks/Baikal/Model/Config/Standard.php @@ -65,8 +65,9 @@ class Standard extends \Baikal\Model\Config { "cal_enabled" => true, "dav_auth_type" => "Digest", "admin_passwordhash" => "", - "auth_realm" => "BaikalDAV" -]; + "auth_realm" => "BaikalDAV", + "base_uri" => "" + ]; function __construct() { $this->aData["invite_from"] = "noreply@" . $_SERVER['SERVER_NAME']; // Default value diff --git a/Core/Frameworks/Flake/Framework.php b/Core/Frameworks/Flake/Framework.php index e395b44..b3fc227 100644 --- a/Core/Frameworks/Flake/Framework.php +++ b/Core/Frameworks/Flake/Framework.php @@ -204,24 +204,21 @@ class Framework extends \Flake\Core\Framework { } protected static function defineBaseUri() { - $usedBaseUriFromConfig = false; try { $config = Yaml::parseFile(PROJECT_PATH_CONFIG . "baikal.yaml"); if (isset($config["system"]["base_uri"]) && $config["system"]["base_uri"] !== "") { // SabreDAV needs a "/" at the beginning of BASEURL - define("PROJECT_BASEURI", self::prependSlash($config["system"]["base_uri"])); + define("PROJECT_BASEURI", + self::prependSlash(self::appendSlash($config["system"]["base_uri"]))); define("PROJECT_URI", \Flake\Util\Tools::getCurrentProtocol() . "://" . $_SERVER["HTTP_HOST"] . PROJECT_BASEURI); - $usedBaseUriFromConfig = true; + + return; } } catch (\Exception $e) { error_log($e); } - if ($usedBaseUriFromConfig) { - return; - } - $sScript = substr($_SERVER["SCRIPT_FILENAME"], strlen($_SERVER["DOCUMENT_ROOT"])); $sDirName = str_replace("\\", "/", dirname($sScript)); // fix windows backslashes diff --git a/config/baikal.yaml.dist b/config/baikal.yaml.dist index cc2c01b..5ccbc2f 100644 --- a/config/baikal.yaml.dist +++ b/config/baikal.yaml.dist @@ -7,6 +7,7 @@ system: dav_auth_type: 'Digest' admin_passwordhash: 5fe794627e1f841f8debba065e2c807a auth_realm: BaikalDAV + base_uri: '' database: encryption_key: 5d3f0fa0192e3058ea70f1bb20924add sqlite_file: "absolute/path/to/Specific/db/db.sqlite"