<?php

require_once '../../../connection.php';
require '../../../controllers/GlobalController.php';
require '../../../models/inmueble.php';
foreach (Inmueble::obtImagenes($_GET['id']) as $img) {
    putImage($img['foto'], $img['id']);
}
function putImage($img, $id)
{
    ?>

<div class="col-md-4">
	<div class="imagen-container">
		<div class="imagen">
			<img src="assets/img/inmuebles/<?php 
    print $img;
    ?>
" id="<?php 
    print $id;
    ?>
" height="362" width="480" alt="" class="img-responsive imagen2">
		</div>
	</div>
</div>

<?php 
}
?>

    ob_clean();
    flush();
    readfile($image);
}
function putFont()
{
    $font = "../../resources/Ahem.ttf";
    header("Content-Type: font/truetype");
    header("Content-Length: " . filesize($font));
    header("Access-Control-Allow-Origin: *");
    ob_clean();
    flush();
    readfile($font);
}
$expectedReferrerPaths = array("document" => "/css/css-resources-referrer.html", "sheet" => "/css/resources/css-resources-referrer.css", "importedSheet" => "/css/resources/css-resources-referrer-import.css", "iframe" => "/from/iframe.html");
$from = $_GET["from"];
$resource = $_GET["resource"];
$referrerPath = getReferrerPath();
if ($referrerPath === $expectedReferrerPaths[$from]) {
    if ($resource === "image" || $resource === "image2") {
        putImage();
    } else {
        if ($resource === "font") {
            putFont();
        } else {
            header("HTTP/1.1 500 Internal Server Error");
        }
    }
} else {
    header("HTTP/1.1 500 Internal Server Error");
}