<?php

error_reporting(E_ERROR);
ini_set('display_errors', '1');

defined('VERSION') || define('VERSION', '/home/coresuite/versions/prod-last'); // caminho físico ( php )
defined('VERSION_PUBLIC') || define('VERSION_PUBLIC', 's12.core.bigarsenal.com/prod-last'); // caminho URL ( css, js )
defined('VERSION_PUBLIC_REAL_PATH') || define('VERSION_PUBLIC_REAL_PATH', '/home/coresuite/public_html/prod-last'); // caminho físico da url publica

if(!isset($GLOBALS['argv'])){
    if ( isset($_SERVER['REQUEST_METHOD'])  AND ($_SERVER['REQUEST_METHOD'] == 'OPTIONS')  ) {
        // Defina cabeçalhos para permitir CORS
        header("Access-Control-Allow-Origin: *"); // Ajuste conforme necessário
        header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE"); // Métodos permitidos
        header("Access-Control-Allow-Headers: *"); // Cabeçalhos permitidos
        exit(0); // Encerra a execução do script para requisições OPTIONS
    }else{
        header("Access-Control-Allow-Origin: *");
        header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE"); // Métodos permitidos
        header("Access-Control-Allow-Headers: *");
    }
}

$benchMark = false;
$carregamento = 1;
if($benchMark == true){
    $benchX = microtime(true);
    //$menInitial = 'Memória inicial: '.intval(memory_get_usage() / 1024).'K'."\n <br/>";
    $menInitial = intval(memory_get_usage() / 1024);
}

defined('HOME') || define('HOME', realpath(dirname(__FILE__) . '/..'));
defined('LOG_ACTIVE') || define('LOG_ACTIVE', true); // true para logar. false para nao logar
date_default_timezone_set('America/Sao_Paulo'); // time

require_once HOME . '/data/config-global.php';

//new autoload
require_once VERSION.'/vendors/autoload.php';

$application = new \Mismif\Mvc\Application();

if(($benchMark == true) AND !isset($GLOBALS['argv'])){

    $bench = microtime(true) - $benchX;
    //$processTime = 'Tempo de processamento: '.$bench.'<br/>';
    $menFinal = intval(memory_get_usage() / 1024);
    $memoryUsed = ($menFinal - $menInitial);

 }
?>