adlerka.top/index.php
Bruno Rybársky 1c9f5cf3c0 Add PHPDocs generated by ChatGPT,
add additional clarification to some functions,
add addNewsComment function and API, currently untested and not implemented in the client,
fix a bunch of stuff that PHPStorm pointed out
2024-04-28 22:37:23 +02:00

41 lines
1.8 KiB
PHP

<?php
/** @noinspection PhpIncludeInspection */
// 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.
// Load configuration for the router from the configuration files.
$routerConfig = loadRouterConfig();
// Initialize the router to parse the request URI and determine the requested site/page.
$routerRequest = initRouter();
// Start or resume a session to manage user sessions across requests.
session_start();
// Set default session data if the user is not logged in.
if (!isLoggedIn()) {
setDefaultSessionData();
}
// 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.
}
// Handle API type requests by fetching and outputting the endpoint response.
if ($routerRequest["type"] == "api") {
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"]);
}