<?php
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
ob_start();

function checkSession() {
    if (!isset($_SESSION['phone']) || empty($_SESSION['phone'])) {
        header("Location: ../login.php");
        exit;
    }
}

function checkAdmin($type) {
    return in_array($type, ['admin', 'superadmin', 'master', 'Admin', 'SuperAdmin', 'Master']);
}

function loginAsAdmin() {
    if (isset($_SESSION['adminusername']) && !empty($_SESSION['adminusername'])) {
        $_SESSION['phone'] = $_SESSION['adminusername'];
        unset($_SESSION['adminasuser']);
        unset($_SESSION['adminusername']);
    }
}
?>