mirror of
https://github.com/til-schneider/slim-wiki.git
synced 2025-08-12 19:44:14 +02:00
Moved index.php code in function in order to prevent pollution of the global namespace (because former global variables are local now)
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
<?php
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
function init() {
|
||||
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')
|
||||
// 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']));
|
||||
$uriPathArray = explode("/", parse_url($_SERVER['REQUEST_URI'])['path']);
|
||||
$scriptPathArray = explode("/", dirname($_SERVER['SCRIPT_NAME']));
|
||||
|
||||
$basePathArray = array();
|
||||
$requestPathArray = array();
|
||||
$isBasePath = true;
|
||||
foreach ($uriPathArray as $level => $uriDir) {
|
||||
$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
|
||||
@@ -24,17 +25,18 @@ foreach ($uriPathArray as $level => $uriDir) {
|
||||
} else {
|
||||
$requestPathArray[] = $uriDir;
|
||||
}
|
||||
}
|
||||
$basePath = rtrim(implode('/', $basePathArray), '/') . '/';
|
||||
}
|
||||
$basePath = rtrim(implode('/', $basePathArray), '/') . '/';
|
||||
|
||||
$https = false;
|
||||
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
|
||||
$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);
|
||||
}
|
||||
$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();
|
||||
|
Reference in New Issue
Block a user