<?php
include "includes/db.php";
include "includes/funcoes.php";
include "includes/head.php";
$mat_end_base = basename($_SERVER['PHP_SELF'], ".php");
$serie_selo = "selo.jpg"; //Virá da Editoria a que estiver associada

// Prepare an SQL statement for execution
$stmt = $connection->prepare("SELECT * FROM materias WHERE mat_end_base = ?");

// Bind variables to a prepared statement as parameters
$stmt->bind_param("s", $mat_end_base);

// Execute a prepared Query
$stmt->execute();

// Get the result of the query
$result = $stmt->get_result();

$row = $result->fetch_assoc();
$materia_titulo = $row['materia_titulo'];
$materia_editoria = $row['materia_editoria'];
$materia_abertura = $row['materia_abertura'];
$materia_creditos = $row['materia_creditos'];
$materia_status = $row['materia_status'];
$materia_img_principal = $row['materia_img_principal'];
$materia_referencias = $row['materia_referencias'];
$materia_conteudo = html_entity_decode(($row['materia_conteudo']), ENT_QUOTES);
$materia_texto_1 = html_entity_decode(($row['materia_texto_1']), ENT_QUOTES);
$materia_texto_2 = html_entity_decode(($row['materia_texto_2']), ENT_QUOTES);
$materia_texto_3 = html_entity_decode(($row['materia_texto_3']), ENT_QUOTES);
$materia_texto_4 = html_entity_decode(($row['materia_texto_4']), ENT_QUOTES);
$materia_texto_5 = html_entity_decode(($row['materia_texto_5']), ENT_QUOTES);
$materia_texto_6 = html_entity_decode(($row['materia_texto_6']), ENT_QUOTES);

$materia_data = date('d/m/Y', (strtotime($row['materia_data'])));

$imagem = "./materias/" . $mat_end_base . "/" . $materia_img_principal;

// Close statement
$stmt->close();

?>

<body>
    <?php
    include("Mobile_Detect.php");
    $detect = new Mobile_Detect();

    if ($detect->isMobile()) {
        include "includes/cabecario_m.php";
        include "materiaCelular.php";
        include "includes/rodape_m.php";
    } else {
        include "includes/cabecario.php";
        include "materiaDesktop.php";
        include "includes/rodape.php";
    }
    // Close statement
    
    ?>