mirror of
https://github.com/til-schneider/slim-wiki.git
synced 2025-08-05 16:17:29 +02:00
Renamed $appPath to $basePath (analog to $baseUrl)
This commit is contained in:
@@ -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);
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user