<?php
function can($page, $action = 'view')
{
    // Admin full access
    if (isset($_SESSION['role']) && $_SESSION['role'] === 'admin') {
        return true;
    }

    if (!isset($_SESSION['permissions'][$page])) {
        return false;
    }

    return !empty($_SESSION['permissions'][$page][$action]);
}
