Use IRequest's `getScriptName` functionality instead of $_SERVER['SCRIPT_NAME']

This commit is contained in:
Lukas Reschke 2015-10-21 17:33:49 +02:00
parent 8133d46620
commit 23e22c52b0
1 changed files with 13 additions and 1 deletions

View File

@ -133,7 +133,18 @@ class OC {
OC_Config::$object = new \OC\Config(self::$configDir);
OC::$SUBURI = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen(OC::$SERVERROOT)));
$scriptName = $_SERVER['SCRIPT_NAME'];
/**
* FIXME: The following lines are required because we can't yet instantiiate
* \OC::$server->getRequest() since \OC::$server does not yet exist.
*/
$params = [
'server' => [
'SCRIPT_NAME' => $_SERVER['SCRIPT_NAME'],
'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'],
],
];
$fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig()));
$scriptName = $fakeRequest->getScriptName();
if (substr($scriptName, -1) == '/') {
$scriptName .= 'index.php';
//make sure suburi follows the same rules as scriptName
@ -145,6 +156,7 @@ class OC {
}
}
if (OC::$CLI) {
OC::$WEBROOT = OC_Config::getValue('overwritewebroot', '');
} else {