2024-02-03 16:46:09 +01:00
|
|
|
<?php
|
2024-02-06 16:24:57 +01:00
|
|
|
/** @noinspection PhpIncludeInspection */
|
2024-04-28 22:37:23 +02:00
|
|
|
// Include essential configuration and function libraries.
|
|
|
|
require_once 'secrets/config.php'; // Load sensitive configuration such as database credentials.
|
|
|
|
require_once 'lib/config.php'; // Load general site configuration settings.
|
|
|
|
require_once 'lib/navigation.php'; // Include functions related to navigation generation.
|
|
|
|
require_once 'lib/router.php'; // Include routing functionality to manage URL routing.
|
|
|
|
require_once 'lib/page.php'; // Functions related to page content generation and management.
|
|
|
|
require_once 'lib/endpoint.php'; // Functions for handling API endpoints.
|
|
|
|
require_once 'lib/account.php'; // Include user account management functionality.
|
2024-02-03 16:54:04 +01:00
|
|
|
|
2024-04-28 22:37:23 +02:00
|
|
|
// Load configuration for the router from the configuration files.
|
2024-02-06 16:24:57 +01:00
|
|
|
$routerConfig = loadRouterConfig();
|
2024-02-03 16:54:04 +01:00
|
|
|
|
2024-04-28 22:37:23 +02:00
|
|
|
// Initialize the router to parse the request URI and determine the requested site/page.
|
2024-02-06 16:24:57 +01:00
|
|
|
$routerRequest = initRouter();
|
2024-02-03 16:54:04 +01:00
|
|
|
|
2024-04-28 22:37:23 +02:00
|
|
|
// Start or resume a session to manage user sessions across requests.
|
2024-02-06 16:24:57 +01:00
|
|
|
session_start();
|
2024-02-03 16:54:04 +01:00
|
|
|
|
2024-04-28 22:37:23 +02:00
|
|
|
// Set default session data if the user is not logged in.
|
2024-02-06 16:24:57 +01:00
|
|
|
if (!isLoggedIn()) {
|
2024-04-28 22:37:23 +02:00
|
|
|
setDefaultSessionData();
|
2024-02-06 16:24:57 +01:00
|
|
|
}
|
2024-02-03 16:54:04 +01:00
|
|
|
|
2024-04-28 22:37:23 +02:00
|
|
|
// Handle requests for the sitemap.
|
|
|
|
if ($routerRequest["site_name"] == "sitemap.xml") {
|
|
|
|
require "lib/sitemap.php"; // Include sitemap generation functions.
|
|
|
|
echo generateSitemap(); // Generate and output the sitemap XML.
|
|
|
|
exit(); // Stop script execution after sitemap generation.
|
2024-02-15 10:17:09 +01:00
|
|
|
}
|
|
|
|
|
2024-04-28 22:37:23 +02:00
|
|
|
// Handle API type requests by fetching and outputting the endpoint response.
|
2024-02-06 16:24:57 +01:00
|
|
|
if ($routerRequest["type"] == "api") {
|
2024-04-28 22:37:23 +02:00
|
|
|
echo getEndpoint($routerRequest["site_name"]);
|
|
|
|
}
|
|
|
|
// Handle page type requests by fetching and rendering the page content.
|
|
|
|
elseif ($routerRequest["type"] == "page") {
|
|
|
|
echo getPage($routerRequest["site_name"], $routerRequest["page_name"]);
|
|
|
|
}
|