<?php
function redirect(string $path): void {
    header('Location: ' . $path);
    exit;
}

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

function current_user() {
    return $_SESSION['user'] ?? null;
}

function require_login(): void {
    if (!current_user()) redirect('/login.php');
}