<?php

// echo "static request handler";
$pathStaticFile = str_replace("public/", "", $mpathBase);

// echo "<pre>";
// echo "pathStaticFile: ";
// print_r($pathStaticFile);
// echo "</pre>";
$finalPathStaticFile = "bpublico/" . $pathStaticFile;

if (!file_exists($finalPathStaticFile)) {
    http_response_code(404);
    exit;
}

if(preg_match("/.+\.css$/",$pathStaticFile)){
    header("Content-type: text/css");
}else if(preg_match("/.+\.js$/",$pathStaticFile)){
    header("Content-type: application/javascript");
}else if(preg_match("/.+\.svg$/",$pathStaticFile)){
    header("Content-type: image/svg+xml");
}else if(preg_match("/.+\.png$/",$pathStaticFile)){
    header("Content-type: image/png");
}else if(preg_match("/.+\.ico$/",$pathStaticFile)){
    header("Content-type: image/x-icon");
}else if(preg_match("/.+\.jpg$/",$pathStaticFile)){
    header("Content-type: image/jpeg");
}else if(preg_match("/.+\.gif$/",$pathStaticFile)){
    header("Content-type: image/gif");
}else if(preg_match("/.+\.ttf$/",$pathStaticFile)){
    header("Content-type: application/octet-stream");
}else if(preg_match("/.+\.pdf$/",$pathStaticFile)){
    header("Content-type: application/pdf");
}else if(preg_match("/.+\.woff2$/",$pathStaticFile)){
    header("Content-type: font/woff2");
}

header("Pragma: cache");
header("Cache-Control: max-age=2592000"); //30days (60sec * 60min * 24hours * 30days)

readfile("bpublico/" . $pathStaticFile);