API Documentation
Table of Contents
Namespaces
Constants
- CSP_NONCE = $cspNonce
- DB_CHARSET = $_ENV['DB_CHARSET'] ?? $_SERVER['DB_CHARSET'] ?? 'utf8mb4'
- DB_HOST = $_ENV['DB_HOST'] ?? $_SERVER['DB_HOST'] ?? '127.0.0.1'
- DB_NAME = $_ENV['DB_NAME'] ?? $_SERVER['DB_NAME'] ?? 'bdelive_test'
- DB_PASSWORD = $_ENV['DB_PASSWORD'] ?? $_SERVER['DB_PASSWORD'] ?? 'root'
- DB_USER = $_ENV['DB_USER'] ?? $_SERVER['DB_USER'] ?? 'root'
- FROM_EMAIL = (string) $_ENV['FROM_EMAIL']
Functions
- requireLogin() : void
- Require user authentication
- requireAdmin() : void
- Require events privileges
- generateCsrfToken() : string
- Generate a CSRF token and store it in session
- validateCsrfToken() : bool
- Validate CSRF token
- csrfField() : string
- Get CSRF token field HTML
- csrfField() : string
- Generate a CSRF token hidden input field
- validateCsrfToken() : bool
- Validate a CSRF token
- generateCsrfToken() : string
- Generate a new CSRF token
- requireLogin() : void
- Require user authentication
- requireAdmin() : void
- Require administrator rights (BDE)
- useCarousel() : void
- Carousel Component
- start_page() : void
- Renders the page header with navigation
- end_page() : void
- Renders the page footer
Constants
CSP_NONCE
public
mixed
CSP_NONCE
= $cspNonce
DB_CHARSET
public
mixed
DB_CHARSET
= $_ENV['DB_CHARSET'] ?? $_SERVER['DB_CHARSET'] ?? 'utf8mb4'
DB_HOST
public
mixed
DB_HOST
= $_ENV['DB_HOST'] ?? $_SERVER['DB_HOST'] ?? '127.0.0.1'
DB_NAME
public
mixed
DB_NAME
= $_ENV['DB_NAME'] ?? $_SERVER['DB_NAME'] ?? 'bdelive_test'
DB_PASSWORD
public
mixed
DB_PASSWORD
= $_ENV['DB_PASSWORD'] ?? $_SERVER['DB_PASSWORD'] ?? 'root'
DB_USER
public
mixed
DB_USER
= $_ENV['DB_USER'] ?? $_SERVER['DB_USER'] ?? 'root'
FROM_EMAIL
public
mixed
FROM_EMAIL
= (string) $_ENV['FROM_EMAIL']
Functions
requireLogin()
Require user authentication
requireLogin() : void
Checks if a user session is active and if the user is logged in. Redirects to the login page with an error message if the user is not authenticated.
Tags
requireAdmin()
Require events privileges
requireAdmin() : void
Checks if a user session is active, if the user is logged in, and if the user has events status ('BDE'). Redirects to login page if not authenticated, or returns 403 Forbidden if authenticated but not events.
Tags
generateCsrfToken()
Generate a CSRF token and store it in session
generateCsrfToken() : string
Generates a cryptographically secure random token (64 hex characters) and stores it in the session along with a timestamp.
Return values
string —The generated token (64 hex characters), or empty string if session is not active
validateCsrfToken()
Validate CSRF token
validateCsrfToken(string $token) : bool
Validates that the provided token matches the token stored in the session and that the token has not expired (1 hour expiration).
Parameters
- $token : string
-
The token to validate
Return values
bool —True if the token is valid and not expired, false otherwise
csrfField()
Get CSRF token field HTML
csrfField() : string
Generates an HTML hidden input field containing the CSRF token. Uses an existing token if available, otherwise generates a new one.
Return values
string —HTML input field with CSRF token, or empty string if session is not active
csrfField()
Generate a CSRF token hidden input field
csrfField() : string
Convenience function that wraps CsrfProtection::getTokenField().
Tags
Return values
string —HTML hidden input with CSRF token
validateCsrfToken()
Validate a CSRF token
validateCsrfToken(string $token) : bool
Convenience function that wraps CsrfProtection::validateToken().
Parameters
- $token : string
-
The CSRF token to validate
Tags
Return values
bool —True if valid, false otherwise
generateCsrfToken()
Generate a new CSRF token
generateCsrfToken() : string
Convenience function that wraps CsrfProtection::generateToken().
Tags
Return values
string —The generated CSRF token (64 hex characters)
requireLogin()
Require user authentication
requireLogin() : void
Checks if user is authenticated and redirects to login page if not. Convenience function that wraps AuthManager::requireAuthentication().
Tags
Return values
void —Redirects to login page if not authenticated
requireAdmin()
Require administrator rights (BDE)
requireAdmin() : void
Checks if user is authenticated and has admin (BDE) status. Redirects to login or home page with error message if requirements not met. Convenience function that wraps AuthManager::requireAdmin().
Tags
Return values
void —Redirects if not authenticated or not admin
useCarousel()
Carousel Component
useCarousel(string $carouselLabel, array<int, array{src: string, alt?: string}> $imageMap, string $carouselId, mixed $event) : void
Reusable carousel component for displaying sliding image content. Used on homepage and other pages for featured content display.
Parameters
- $carouselLabel : string
- $imageMap : array<int, array{src: string, alt?: string}>
- $carouselId : string
- $event : mixed
Tags
start_page()
Renders the page header with navigation
start_page(string $title[, bool $wouldNav = true ][, array<string, mixed>|null $user = null ]) : void
Generates the HTML head section and navigation bar with responsive hamburger menu for mobile devices. Includes user-specific navigation options based on authentication status and user role.
Parameters
- $title : string
-
Page title for the browser tab
- $wouldNav : bool = true
-
Whether to display the navigation bar
- $user : array<string, mixed>|null = null
-
Current user data or null if not logged in
Tags
end_page()
Renders the page footer
end_page() : void
Generates the HTML footer section with navigation links, social media icons, and copyright information. Also handles cookie consent popup display.