<?php

require_once("auth.php");
require_once("functions.php");

$server_name = $_SERVER["SERVER_NAME"];

$url = $_SERVER["REQUEST_URI"];
$parts = explode("/", $url);

if($server_name == "localhost"){
    if(count($parts) > 3){
        $page = $parts[2] . "/" . $parts[3];
    }else{
        $page = end($parts);
    }
}else{
    if(count($parts) > 2){
        $page = $parts[1] . "/" . $parts[2];
    }else{
        $page = end($parts);
    }
}

$autorizado = consulta_permissao_menu($perfil_usuario, $page);

if (!$autorizado) {
    header('Location: ./404');
    return;
}
