|
@@ -19,29 +19,46 @@ if (strpos($pageAddress, "?") !== false) {
|
|
|
parse_str(substr($pageAddress, strpos($pageAddress, "?") + 1), $_GET);
|
|
|
$pageAddress = substr($pageAddress, 0, strpos($pageAddress, "?"));
|
|
|
}
|
|
|
-if (substr($pageAddress, -1) === '/' OR $pageAddress === '')
|
|
|
- $pageAddress .= 'index';
|
|
|
-define("PAGE_ADDRESS", $pageAddress);
|
|
|
+
|
|
|
+define("PAGE_URL", $pageAddress);
|
|
|
+define("PAGE_ADDRESS", $pageAddress . ((substr($pageAddress, -1) === '/' OR $pageAddress === '') ? 'index' : ''));
|
|
|
+define("PAGE_LINEAGE", explode('/', PAGE_ADDRESS));
|
|
|
define("SERVICE", dirname(PAGE_ADDRESS));
|
|
|
define("PAGE", basename(PAGE_ADDRESS, '.php'));
|
|
|
|
|
|
require "pages.php";
|
|
|
|
|
|
-if (SERVICE !== '.') {
|
|
|
- if (!isset(TITLES[SERVICE]['index'])) {
|
|
|
+if (PAGE !== 'index') {
|
|
|
+ if (!isset(TITLES[SERVICE][PAGE])) {
|
|
|
http_response_code(404);
|
|
|
exit('Page not found.');
|
|
|
}
|
|
|
- $page['service'] = TITLES[SERVICE]['index'];
|
|
|
- if (PAGE !== 'index') {
|
|
|
- if (!isset(TITLES[SERVICE][PAGE])) {
|
|
|
+ if (SERVICE !== '.') {
|
|
|
+ if (!isset(TITLES[SERVICE]['index'])) {
|
|
|
http_response_code(404);
|
|
|
exit('Page not found.');
|
|
|
}
|
|
|
- $page['title'] = TITLES[SERVICE][PAGE];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+for (
|
|
|
+ $path_i = PAGE_LINEAGE , $results = [] , $firstIteration = true ;
|
|
|
+ $title = TITLES , $path_i !== [] ;
|
|
|
+ array_pop($path_i) , $results[] = $title
|
|
|
+) {
|
|
|
+ foreach ($path_i as $el) {
|
|
|
+ if (end($path_i) !== $el)
|
|
|
+ $title = $title[$el];
|
|
|
+ else {
|
|
|
+ if ($firstIteration AND end($path_i) !== 'index')
|
|
|
+ $results[] = $title[$el];
|
|
|
+ $firstIteration = false;
|
|
|
+ $title = $title['index'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+define('TITLES_LINEAGE', array_reverse($results));
|
|
|
+
|
|
|
require "html.php";
|
|
|
|
|
|
function executePage() {
|