<article>

    <div class="base-box2 mb-3">

        <div class="widget-head">
            <h3 class="widget-title">
                <span><?php echo $lang_100001; ?></span>
            </h3>
        </div>

        <?php
        $nu  = 0;
        $mes = date('m');
        $ano = date('Y');
        $tam = 16;

        $sql = "SELECT ID, carpetafoto, foto, ext_img, titulo, bajada, d, m, a, visitas
                FROM notas
                ORDER BY visitas DESC
                LIMIT 5";

        $consulta = $conn->query($sql);

        while ($row = $consulta->fetch_assoc()) {
            $nu++;

            $ID          = $row["ID"];
            $ID_NOTA     = $row["ID"];
            $carpetafoto = $row["carpetafoto"];
            $foto        = trim($row["foto"]);
            $ext_img     = $row["ext_img"];
            $titulo      = $row["titulo"];
            $bajada      = $row["bajada"];
            $d           = $row["d"];
            $m           = $row["m"];
            $a           = $row["a"];
            $visitas     = $row["visitas"];

            $tieneFoto = ($foto !== '');

            $srcFoto = '';
            if ($tieneFoto) {
                $fotojj = substr($foto, 0, 4);
                if ($fotojj === 'http') {
                    $srcFoto = $foto;
                } else {
                    $srcFoto = $dom . '/' . $carpetafoto . '/thumbnail_' . $foto . $ext_img;
                }
            }
        ?>

            <div class="container-fluid border-bottom" style="position:relative;">

                <div style="position:absolute;top:0;right:0;z-index:1;">
                    <h2 class="m-0" style="color:#e4e4e4;font-size:4rem;line-height:1;"><?php echo $nu; ?></h2>
                </div>

                <div class="row">

                    <?php if ($tieneFoto) { ?>

                        <div class="col-4 p-0">
                            <a href="<?php echo $dom; ?>/nota/<?php echo $ID; ?>/<?php echo urls_amigables($titulo); ?>" class="tita stretched-link">
                                <img
                                    loading="lazy"
                                    class="img-fluid lazy"
                                    src="<?php echo $srcFoto; ?>"
                                    alt="<?php echo htmlspecialchars($titulo, ENT_QUOTES, 'UTF-8'); ?>">
                            </a>
                        </div>

                        <div class="col-8 p-2" style="min-height:4rem;">
                            <a href="<?php echo $dom; ?>/nota/<?php echo $ID; ?>/<?php echo urls_amigables($titulo); ?>" class="tita stretched-link">
                                <h4 class="colorTitulo"><?php echo utf8_decode($titulo); ?></h4>
                            </a>
                        </div>

                    <?php } else { ?>

                        <div class="col-12 p-2" style="min-height:4rem;">
                            <a href="<?php echo $dom; ?>/nota/<?php echo $ID; ?>/<?php echo urls_amigables($titulo); ?>" class="tita stretched-link">
                                <h4 class="colorTitulo"><?php echo utf8_decode($titulo); ?></h4>
                            </a>
                        </div>

                    <?php } ?>

                </div>

            </div>

        <?php
        }

        if ($consulta) {
            $consulta->free_result();
        }
        ?>

    </div>

</article>