diff --git a/src/index.php b/src/index.php index 3e8bd4a..fd5136d 100644 --- a/src/index.php +++ b/src/index.php @@ -1,40 +1,42 @@ $uriDir) { - $scriptDir = isset($scriptPathArray[$level]) ? $scriptPathArray[$level] : null; - if ($isBasePath && $scriptDir != $uriDir) { - // The URI path differs from the script path here -> We arrived at the level where the app is installed - $isBasePath = false; + $basePathArray = array(); + $requestPathArray = array(); + $isBasePath = true; + foreach ($uriPathArray as $level => $uriDir) { + $scriptDir = isset($scriptPathArray[$level]) ? $scriptPathArray[$level] : null; + if ($isBasePath && $scriptDir != $uriDir) { + // The URI path differs from the script path here -> We arrived at the level where the app is installed + $isBasePath = false; + } + + if ($isBasePath) { + $basePathArray[] = $uriDir; + } else { + $requestPathArray[] = $uriDir; + } } + $basePath = rtrim(implode('/', $basePathArray), '/') . '/'; - if ($isBasePath) { - $basePathArray[] = $uriDir; - } else { - $requestPathArray[] = $uriDir; + $https = false; + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { + $https = true; } + $baseUrl = 'http' . ($https ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $basePath; + + require_once __DIR__ . '/server/logic/Main.php'; + + Main::get()->dispatch($baseUrl, $basePath, $requestPathArray); } -$basePath = rtrim(implode('/', $basePathArray), '/') . '/'; -$https = false; -if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { - $https = true; -} -$baseUrl = 'http' . ($https ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $basePath; - -unset($uriPathArray, $scriptPathArray, $basePathArray, $isBasePath, $https); - -require_once __DIR__ . '/server/logic/Main.php'; - -Main::get()->dispatch($baseUrl, $basePath, $requestPathArray); +init();