From a419eff23a4a1412115862db24f3d5d476ec01d7 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 11 Oct 2018 08:49:52 -0400 Subject: [PATCH 1/2] Replace missing App->getURLPath in mod/install --- mod/install.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mod/install.php b/mod/install.php index 7a69a731ba..97677344a0 100644 --- a/mod/install.php +++ b/mod/install.php @@ -42,7 +42,6 @@ function install_post(App $a) { return; break; // just in case return don't return :) case 3: - $urlpath = $a->get_path(); $dbhost = notags(trim($_POST['dbhost'])); $dbuser = notags(trim($_POST['dbuser'])); $dbpass = notags(trim($_POST['dbpass'])); @@ -57,7 +56,7 @@ function install_post(App $a) { return; break; case 4: - $urlpath = $a->get_path(); + $urlpath = $a->getURLPath(); $dbhost = notags(trim($_POST['dbhost'])); $dbuser = notags(trim($_POST['dbuser'])); $dbpass = notags(trim($_POST['dbpass'])); @@ -97,8 +96,6 @@ function install_content(App $a) { $wizard_status = ""; $install_title = L10n::t('Friendica Communications Server - Setup'); - - if (x($a->data, 'db_conn_failed')) { $install_wizard_pass = 2; $wizard_status = L10n::t('Could not connect to database.'); From ac1ff6c8ce9f23eebf5e53ce799c3b8b84d6de93 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 11 Oct 2018 08:54:45 -0400 Subject: [PATCH 2/2] Try additional $_SERVER properties to get relative path of Friendica --- src/App.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/App.php b/src/App.php index 9bfb10f7ce..d763cfa43f 100644 --- a/src/App.php +++ b/src/App.php @@ -522,20 +522,29 @@ class App */ private function determineURLPath() { + /* Relative script path to the web server root + * Not all of those $_SERVER properties can be present, so we do by inverse priority order + */ + $relative_script_path = ''; + $relative_script_path = defaults($_SERVER, 'REDIRECT_URL' , $relative_script_path); + $relative_script_path = defaults($_SERVER, 'REDIRECT_URI' , $relative_script_path); + $relative_script_path = defaults($_SERVER, 'REDIRECT_SCRIPT_URL', $relative_script_path); + $relative_script_path = defaults($_SERVER, 'SCRIPT_URL' , $relative_script_path); + $this->urlPath = $this->getConfigValue('system', 'urlpath'); - /* SCRIPT_URL gives /path/to/friendica/module/parameter + /* $relative_script_path gives /relative/path/to/friendica/module/parameter * QUERY_STRING gives pagename=module/parameter * - * To get /path/to/friendica we perform dirname() for as many levels as there are slashes in the QUERY_STRING + * To get /relative/path/to/friendica we perform dirname() for as many levels as there are slashes in the QUERY_STRING */ - if (!empty($_SERVER['SCRIPT_URL'])) { + if (!empty($relative_script_path)) { // Module if (!empty($_SERVER['QUERY_STRING'])) { - $path = trim(dirname($_SERVER['SCRIPT_URL'], substr_count(trim($_SERVER['QUERY_STRING'], '/'), '/') + 1), '/'); + $path = trim(dirname($relative_script_path, substr_count(trim($_SERVER['QUERY_STRING'], '/'), '/') + 1), '/'); } else { // Root page - $path = trim($_SERVER['SCRIPT_URL'], '/'); + $path = trim($relative_script_path, '/'); } if ($path && $path != $this->urlPath) {