<?php

session_start();

require '../../config.php';
require '../admin_config.php';
require '../functions.php';

if (isset($_SESSION['user_email'])){

$connect = connect($database);

$check_access = check_access($connect);

if ($check_access['user_role'] == 1){

// Get all popups
$query = $connect->query("SELECT * FROM popups ORDER BY popup_priority DESC, popup_id DESC");
$popups = $query->fetchAll(PDO::FETCH_ASSOC);

require '../views/header.view.php';
require '../views/popups.view.php';

}else{
    header('Location:'.SITE_URL);
}

require '../views/footer.view.php';

}else{
    header('Location: ./login.php');
}

?>
