Merge pull request #5882 from MrPetovan/bug/fix-urlpath-determination

Fix URLPath determination
This commit is contained in:
Tobias Diekershoff 2018-10-11 15:38:37 +02:00 committed by GitHub
commit 71a60c5f66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View file

@ -42,7 +42,6 @@ function install_post(App $a) {
return; return;
break; // just in case return don't return :) break; // just in case return don't return :)
case 3: case 3:
$urlpath = $a->get_path();
$dbhost = notags(trim($_POST['dbhost'])); $dbhost = notags(trim($_POST['dbhost']));
$dbuser = notags(trim($_POST['dbuser'])); $dbuser = notags(trim($_POST['dbuser']));
$dbpass = notags(trim($_POST['dbpass'])); $dbpass = notags(trim($_POST['dbpass']));
@ -57,7 +56,7 @@ function install_post(App $a) {
return; return;
break; break;
case 4: case 4:
$urlpath = $a->get_path(); $urlpath = $a->getURLPath();
$dbhost = notags(trim($_POST['dbhost'])); $dbhost = notags(trim($_POST['dbhost']));
$dbuser = notags(trim($_POST['dbuser'])); $dbuser = notags(trim($_POST['dbuser']));
$dbpass = notags(trim($_POST['dbpass'])); $dbpass = notags(trim($_POST['dbpass']));
@ -97,8 +96,6 @@ function install_content(App $a) {
$wizard_status = ""; $wizard_status = "";
$install_title = L10n::t('Friendica Communications Server - Setup'); $install_title = L10n::t('Friendica Communications Server - Setup');
if (x($a->data, 'db_conn_failed')) { if (x($a->data, 'db_conn_failed')) {
$install_wizard_pass = 2; $install_wizard_pass = 2;
$wizard_status = L10n::t('Could not connect to database.'); $wizard_status = L10n::t('Could not connect to database.');

View file

@ -522,20 +522,29 @@ class App
*/ */
private function determineURLPath() 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'); $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 * 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 // Module
if (!empty($_SERVER['QUERY_STRING'])) { 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 { } else {
// Root page // Root page
$path = trim($_SERVER['SCRIPT_URL'], '/'); $path = trim($relative_script_path, '/');
} }
if ($path && $path != $this->urlPath) { if ($path && $path != $this->urlPath) {