diff --git a/src/index.php b/src/index.php index a3d73fe..c40135e 100644 --- a/src/index.php +++ b/src/index.php @@ -9,32 +9,32 @@ ini_set('display_errors', 1); $uriPathArray = explode("/", parse_url($_SERVER['REQUEST_URI'])['path']); $scriptPathArray = explode("/", dirname($_SERVER['SCRIPT_NAME'])); -$appPathArray = array(); +$basePathArray = array(); $requestPathArray = array(); -$isAppPath = true; +$isBasePath = true; foreach ($uriPathArray as $level => $uriDir) { $scriptDir = isset($scriptPathArray[$level]) ? $scriptPathArray[$level] : null; - if ($isAppPath && $scriptDir != $uriDir) { + if ($isBasePath && $scriptDir != $uriDir) { // The URI path differs from the script path here -> We arrived at the level where the app is installed - $isAppPath = false; + $isBasePath = false; } - if ($isAppPath) { - $appPathArray[] = $uriDir; + if ($isBasePath) { + $basePathArray[] = $uriDir; } else { $requestPathArray[] = $uriDir; } } -$appPath = rtrim(implode('/', $appPathArray), '/'); +$basePath = rtrim(implode('/', $basePathArray), '/') . '/'; $https = false; if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $https = true; } -$baseUrl = 'http' . ($https ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $appPath; +$baseUrl = 'http' . ($https ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $basePath; -unset($uriPathArray, $scriptPathArray, $appPathArray, $isAppPath, $https); +unset($uriPathArray, $scriptPathArray, $basePathArray, $isBasePath, $https); require_once __DIR__ . '/server/logic/main.php'; -(new Main())->dispatch($baseUrl, $appPath, $requestPathArray); +(new Main())->dispatch($baseUrl, $basePath, $requestPathArray); diff --git a/src/server/logic/Main.php b/src/server/logic/Main.php index b5240e1..f64bc28 100644 --- a/src/server/logic/Main.php +++ b/src/server/logic/Main.php @@ -5,10 +5,10 @@ require_once __DIR__ . '/../lib/parsedown/Parsedown.php'; class Main { // Parameters: - // - $baseUrl: E.g. 'http://localhost/slim-wiki/' - // - $appPath: E.g. '/slim-wiki' + // - $baseUrl: E.g. 'http://localhost/slim-wiki/' + // - $basePath: E.g. '/slim-wiki/' // - $requestPathArray: E.g. array('myfolder', 'mypage') - public function dispatch($baseUrl, $appPath, $requestPathArray) { + public function dispatch($baseUrl, $basePath, $requestPathArray) { $articleBaseDir = realpath(__DIR__ . '/../../articles'); $articleFilename = $articleBaseDir . '/' . implode('/', $requestPathArray);