1
0
mirror of https://github.com/til-schneider/slim-wiki.git synced 2025-08-06 16:46:31 +02:00

Renamed $appPath to $basePath (analog to $baseUrl)

This commit is contained in:
til-schneider
2015-12-21 09:17:48 +01:00
parent 4d253598ba
commit ec191181cb
2 changed files with 13 additions and 13 deletions

View File

@@ -9,32 +9,32 @@ ini_set('display_errors', 1);
$uriPathArray = explode("/", parse_url($_SERVER['REQUEST_URI'])['path']); $uriPathArray = explode("/", parse_url($_SERVER['REQUEST_URI'])['path']);
$scriptPathArray = explode("/", dirname($_SERVER['SCRIPT_NAME'])); $scriptPathArray = explode("/", dirname($_SERVER['SCRIPT_NAME']));
$appPathArray = array(); $basePathArray = array();
$requestPathArray = array(); $requestPathArray = array();
$isAppPath = true; $isBasePath = true;
foreach ($uriPathArray as $level => $uriDir) { foreach ($uriPathArray as $level => $uriDir) {
$scriptDir = isset($scriptPathArray[$level]) ? $scriptPathArray[$level] : null; $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 // 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) { if ($isBasePath) {
$appPathArray[] = $uriDir; $basePathArray[] = $uriDir;
} else { } else {
$requestPathArray[] = $uriDir; $requestPathArray[] = $uriDir;
} }
} }
$appPath = rtrim(implode('/', $appPathArray), '/'); $basePath = rtrim(implode('/', $basePathArray), '/') . '/';
$https = false; $https = false;
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$https = true; $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'; require_once __DIR__ . '/server/logic/main.php';
(new Main())->dispatch($baseUrl, $appPath, $requestPathArray); (new Main())->dispatch($baseUrl, $basePath, $requestPathArray);

View File

@@ -5,10 +5,10 @@ require_once __DIR__ . '/../lib/parsedown/Parsedown.php';
class Main { class Main {
// Parameters: // Parameters:
// - $baseUrl: E.g. 'http://localhost/slim-wiki/' // - $baseUrl: E.g. 'http://localhost/slim-wiki/'
// - $appPath: E.g. '/slim-wiki' // - $basePath: E.g. '/slim-wiki/'
// - $requestPathArray: E.g. array('myfolder', 'mypage') // - $requestPathArray: E.g. array('myfolder', 'mypage')
public function dispatch($baseUrl, $appPath, $requestPathArray) { public function dispatch($baseUrl, $basePath, $requestPathArray) {
$articleBaseDir = realpath(__DIR__ . '/../../articles'); $articleBaseDir = realpath(__DIR__ . '/../../articles');
$articleFilename = $articleBaseDir . '/' . implode('/', $requestPathArray); $articleFilename = $articleBaseDir . '/' . implode('/', $requestPathArray);