1
0
mirror of https://github.com/til-schneider/slim-wiki.git synced 2025-10-23 12:36:06 +02:00

Added basic markdown page rendering

This commit is contained in:
til-schneider
2015-12-19 19:59:20 +01:00
parent 4d04fe0b6c
commit dbc509c004
6 changed files with 92 additions and 0 deletions

40
src/index.php Normal file
View File

@@ -0,0 +1,40 @@
<?php
ini_set('display_errors', 1);
// Split URI example: 'http://localhost/slim-wiki/myfolder/mypage?action=bla'
// into $appPath example: '/slim-wiki'
// and $requestPathArray example: array('myfolder', 'mypage')
$uriPathArray = explode("/", parse_url($_SERVER['REQUEST_URI'])['path']);
$scriptPathArray = explode("/", dirname($_SERVER['SCRIPT_NAME']));
$appPathArray = array();
$requestPathArray = array();
$isAppPath = true;
foreach ($uriPathArray as $level => $uriDir) {
$scriptDir = isset($scriptPathArray[$level]) ? $scriptPathArray[$level] : null;
if ($isAppPath && $scriptDir != $uriDir) {
// The URI path differs from the script path here -> We arrived at the level where the app is installed
$isAppPath = false;
}
if ($isAppPath) {
$appPathArray[] = $uriDir;
} else {
$requestPathArray[] = $uriDir;
}
}
$appPath = rtrim(implode('/', $appPathArray), '/');
$https = false;
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$https = true;
}
$baseUrl = 'http' . ($https ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $appPath;
unset($uriPathArray, $scriptPathArray, $appPathArray, $isAppPath, $https);
require_once __DIR__ . '/server/logic/main.php';
(new Main())->dispatch($baseUrl, $appPath, $requestPathArray);