<?php
session_start();
$_SESSION['last_activity'] = time();
if(isset($_SESSION['token'] ))
{
   $activePage = 'Dashboard'; 
   //include("master.php");
  // echo $_SESSION['password'];
  // echo  ($_SESSION['token'] );
   //echo $_SESSION['acesslevel'];
   if (isset($_SESSION['acesslevel'])) {

    switch ($_SESSION['acesslevel']) {
        case "ALL":
            include("master.php");
            break;
        case "NONE":
            include("index.php");
            break;
        case "User Manager":
            include("user_manager_master.php");
            break;
        case "Node Manager":
            include("node_master.php");
            break;
        case "Node Manager"&&"User Manager":
            include("node_master.php");
            break;
        default:
            include("hell");
            break;
    }
} else {
    // Access level is not set, include a default page or show an error
    include("no_access_level.php");
}
}
elseif(!isset($_SESSION['token'])) {
  include('../user/token_exp.php');
}
else
{

    header('Location:index.php');
}
// Debugging: Output token expiry and current time
//echo "Token Expiry: " . $_SESSION['token_expiry'] . "<br>";
//echo "Current Time: " . time() . "<br>";

if ($tokenExpiredOrMissing) {
    echo "Token has expired or is missing.";
} else {
    echo "Token is still valid.";
}

?>



