2022-09-01 02:21:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
define("CONF", parse_ini_file(__DIR__ . "/config.ini", true, INI_SCANNER_TYPED));
|
|
|
|
|
|
|
|
foreach (array_diff(scandir(CONF['common']['root_path'] . "/fn"), array('..', '.')) as $file)
|
|
|
|
require CONF['common']['root_path'] . '/fn/' . $file;
|
|
|
|
|
|
|
|
define("DB_PATH", CONF['common']['root_path'] . "/db/niver.db");
|
|
|
|
|
|
|
|
define("PLACEHOLDER_DOMAIN", "example"); // From RFC2606: Reserved Top Level DNS Names > 2. TLDs for Testing, & Documentation Examples
|
|
|
|
define("PLACEHOLDER_IPV6", "2001:db8::3"); // From RFC3849: IPv6 Address Prefix Reserved for Documentation
|
|
|
|
define("PLACEHOLDER_IPV4", "203.0.113.42"); // From RFC5737: IPv4 Address Blocks Reserved for Documentation
|
|
|
|
|
|
|
|
if ($_SERVER['REQUEST_URI'] === '/sftpgo-auth.php')
|
|
|
|
return;
|
|
|
|
|
|
|
|
$pageAddress = substr($_SERVER['REQUEST_URI'], strlen(CONF['common']['prefix']) + 1);
|
|
|
|
if (strpos($pageAddress, "?") !== false) {
|
|
|
|
parse_str(substr($pageAddress, strpos($pageAddress, "?") + 1), $_GET);
|
|
|
|
$pageAddress = substr($pageAddress, 0, strpos($pageAddress, "?"));
|
|
|
|
}
|
2022-09-09 18:15:10 +00:00
|
|
|
|
|
|
|
define("PAGE_URL", $pageAddress);
|
|
|
|
define("PAGE_ADDRESS", $pageAddress . ((substr($pageAddress, -1) === '/' OR $pageAddress === '') ? 'index' : ''));
|
|
|
|
define("PAGE_LINEAGE", explode('/', PAGE_ADDRESS));
|
2022-09-01 02:21:17 +00:00
|
|
|
define("SERVICE", dirname(PAGE_ADDRESS));
|
|
|
|
define("PAGE", basename(PAGE_ADDRESS, '.php'));
|
|
|
|
|
|
|
|
require "pages.php";
|
|
|
|
|
2022-09-09 18:15:10 +00:00
|
|
|
if (PAGE !== 'index') {
|
|
|
|
if (!isset(TITLES[SERVICE][PAGE])) {
|
2022-09-01 02:21:17 +00:00
|
|
|
http_response_code(404);
|
|
|
|
exit('Page not found.');
|
|
|
|
}
|
2022-09-09 18:15:10 +00:00
|
|
|
if (SERVICE !== '.') {
|
|
|
|
if (!isset(TITLES[SERVICE]['index'])) {
|
2022-09-01 02:21:17 +00:00
|
|
|
http_response_code(404);
|
|
|
|
exit('Page not found.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-09 18:16:48 +00:00
|
|
|
function getTitlesLineage($titles, $pageElements) {
|
|
|
|
if (!isset($titles['index']) OR $pageElements[0] === 'index')
|
|
|
|
return [$titles[$pageElements[0]]];
|
|
|
|
$result = $titles['index'];
|
|
|
|
if (!isset($pageElements[1]))
|
|
|
|
unset($titles['index']);
|
|
|
|
else
|
|
|
|
$titles = $titles[array_shift($pageElements)];
|
|
|
|
$results = getTitlesLineage($titles, $pageElements);
|
|
|
|
$results[] = $result;
|
|
|
|
return $results;
|
2022-09-09 18:15:10 +00:00
|
|
|
}
|
2022-09-09 18:16:48 +00:00
|
|
|
define('TITLES_LINEAGE', array_reverse(getTitlesLineage(TITLES, PAGE_LINEAGE)));
|
2022-09-09 18:15:10 +00:00
|
|
|
|
2022-09-01 02:21:17 +00:00
|
|
|
require "html.php";
|
|
|
|
|
2022-09-07 16:44:49 +00:00
|
|
|
function executePage() {
|
|
|
|
require "pages/" . PAGE_ADDRESS . ".php";
|
|
|
|
closeHtml();
|
|
|
|
}
|
|
|
|
executePage();
|