<?php

	import_file(DIR_MODELS."Model.class.php");

	$slug_pagina = filter_input(INPUT_GET, "pagina", FILTER_SANITIZE_STRING);

	$model = new Model();

	$result = $model->query("
		SELECT * FROM pagina
		WHERE 
			slug_pagina = :slug_pagina
	", [
		":slug_pagina" => $slug_pagina
	]);

	if ($result->rowCount() == 0) {
		show_404();
	}

	$data = $result->fetch();

?>

<?php import_file(DIR_TEMPLATES."header_website.php", ["title" => $data->titulo_pagina]); ?>

<div class="container mt-4">
	<h3 class="mb-3"><?php echo $data->titulo_pagina; ?></h3>

	<div class="content-box">
		<?php echo htmlspecialchars_decode($data->conteudo_pagina); ?>
	</div>
</div>

<?php import_file(DIR_TEMPLATES."footer_website.php"); ?>