<?php
declare(strict_types=1);

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

date_default_timezone_set('Asia/Baghdad');

$host = 'localhost';
$dbname = 'naysusam_v2';
$username = 'naysusam_v2';
$password = 'Osamanay123@';

$conn = new mysqli($host, $username, $password, $dbname);

if ($conn->connect_error) {
    die('Database Connection Failed: ' . $conn->connect_error);
}

$conn->set_charset('utf8mb4');

function e($value): string
{
    return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
}

function base_url(string $path = ''): string
{
    return '/app/' . ltrim($path, '/');
}

function admin_url(string $path = ''): string
{
    return '/app/admin/' . ltrim($path, '/');
}

function redirect_to(string $url): void
{
    header('Location: ' . $url);
    exit;
}
?>