forked from Adleraci/adlerka.top
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
This commit is contained in:
42
index.php
42
index.php
@@ -1,32 +1,40 @@
|
||||
<?php
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
require_once 'secrets/config.php';
|
||||
require_once 'lib/config.php';
|
||||
require_once 'lib/navigation.php';
|
||||
require_once 'lib/router.php';
|
||||
require_once 'lib/page.php';
|
||||
require_once 'lib/endpoint.php';
|
||||
require_once 'lib/account.php';
|
||||
// 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();
|
||||
setDefaultSessionData();
|
||||
}
|
||||
|
||||
if($routerRequest["site_name"] == "sitemap.xml") {
|
||||
require "lib/sitemap.php";
|
||||
generateSitemap();
|
||||
exit();
|
||||
// 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"]);
|
||||
|
||||
} elseif ($routerRequest["type"] == "page") {
|
||||
echo getPage($routerRequest["site_name"], $routerRequest["page_name"]);
|
||||
}
|
||||
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"]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user