1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?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, "?"));
- }
- 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 (PAGE !== 'index') {
- if (!isset(TITLES[SERVICE][PAGE])) {
- http_response_code(404);
- exit('Page not found.');
- }
- if (SERVICE !== '.') {
- if (!isset(TITLES[SERVICE]['index'])) {
- http_response_code(404);
- exit('Page not found.');
- }
- }
- }
- 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() {
- require "pages/" . PAGE_ADDRESS . ".php";
- closeHtml();
- }
- executePage();
|