<?php
// ====== BLOQUE NOTAS (NO destacadas) + NOTAS DESTACADAS (TODO mysqli / PHP 8.2) ======

declare(strict_types=1);

$Y = $a ?? null;
$D = $d ?? null;

include __DIR__ . '/marco1desx.php';
include __DIR__ . '/concha.php'; // debe definir: $conn (mysqli), $basedatos, $dom, etc.

if (!isset($conn) || !($conn instanceof mysqli)) {
    http_response_code(500);
    exit('Error: concha.php debe definir $conn como mysqli.');
}
$conn->set_charset('utf8mb4');

function e(string $s): string { return htmlspecialchars($s, ENT_QUOTES, 'UTF-8'); }

function mes_nombre(string $mm): string {
    static $map = [
        '01' => 'enero', '02' => 'febrero', '03' => 'marzo', '04' => 'abril',
        '05' => 'mayo',  '06' => 'junio',   '07' => 'julio', '08' => 'agosto',
        '09' => 'septiembre', '10' => 'octubre', '11' => 'noviembre', '12' => 'diciembre',
    ];
    return $map[$mm] ?? $mm;
}

$cantidad_notas = isset($cantidad_notas) ? (int)$cantidad_notas : 10;
$i_publi = isset($i_publi) ? (int)$i_publi : 0;
$i       = isset($i) ? (int)$i : 0;

// ----------------------------------------------------
// Helpers preparados (mejor rendimiento y seguridad)
// ----------------------------------------------------
$stmtUpdImp = $conn->prepare("UPDATE `notas` SET `impresiones` = ? WHERE `ID` = ?");
$stmtCat    = $conn->prepare("SELECT `nombre`,`color` FROM `categorias` WHERE `ID` = ? LIMIT 1");
$stmtComCnt = $conn->prepare("SELECT COUNT(*) AS c FROM `comentarios` WHERE `IDD` = ? AND `ver` = 'si'");
$stmtFotoGal= $conn->prepare("SELECT `ID` FROM `fotos_notas` WHERE `noticia` = ? LIMIT 1");

$stmtPubJpg = $conn->prepare("SELECT `img`,`url`,`carpetafoto` FROM `publicidades` WHERE `lugar` = ?");
$stmtPubGif = $conn->prepare("SELECT `img`,`url`,`carpetafoto` FROM `publicidades_gif` WHERE `lugar` = ?");
$stmtPubSld = $conn->prepare("SELECT `ID` FROM `publicidades_slide` WHERE `lugar` = ?");
$stmtPubSwf = $conn->prepare("SELECT `ID`,`swf`,`carpetafoto`,`ancho`,`alto`,`lugar` FROM `publicidades_swf` WHERE `lugar` = ?");

// ----------------------------------------------------
// 1) NOTAS NO DESTACADAS
// ----------------------------------------------------
$sql = "
    SELECT ID,titulo,texto,bajada,audio,youtube,d,m,a,carpetafoto,foto,cat,home,impresiones,ext_img
    FROM notas
    WHERE destacado = 'no' AND ver = 'si'
    ORDER BY ID DESC
    LIMIT ?
";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $cantidad_notas);
$stmt->execute();
$res = $stmt->get_result();

while ($row = $res->fetch_assoc()) {

    $ID     = (int)$row['ID'];
    $i_publi++;

    $titulo = (string)$row['titulo'];
    $bajada = (string)$row['bajada'];
    $texto  = (string)$row['texto'];
    $audio  = (string)$row['audio'];
    $youtube= (string)$row['youtube'];

    $d      = (string)$row['d'];
    $m      = (string)$row['m'];
    $a      = (string)$row['a'];
    $fecha  = $d . " - " . $m . " - " . $a;

    $carpetafoto  = (string)$row['carpetafoto'];
    $foto         = $row['foto']; // puede ser null
    $ext_img      = (string)$row['ext_img'];

    $cat_id       = (string)$row['cat'];
    $home         = (string)$row['home'];

    // ---- impresiones +1 (UPDATE)
    $impresiones = (int)$row['impresiones'] + 1;
    if ($stmtUpdImp) {
        $stmtUpdImp->bind_param("ii", $impresiones, $ID);
        $stmtUpdImp->execute();
    }

    $M = $m;
    $m_txt = mes_nombre($M);

    // ---- categoria (si corresponde)
    $cat = $cat_id;
    $color_cat = '';
    if ($cat_id !== '0' && $cat_id !== '' && $stmtCat) {
        $cid = (int)$cat_id;
        $stmtCat->bind_param("i", $cid);
        $stmtCat->execute();
        $rCat = $stmtCat->get_result();
        if ($r = $rCat->fetch_assoc()) {
            $cat = (string)$r['nombre'];
            $color_cat = (string)$r['color'];
        }
        $rCat->free();
    }

    // ---- comentarios COUNT(*)
    $n = 0;
    if ($stmtComCnt) {
        $stmtComCnt->bind_param("i", $ID);
        $stmtComCnt->execute();
        $rC = $stmtComCnt->get_result();
        if ($rc = $rC->fetch_assoc()) {
            $n = (int)$rc['c'];
        }
        $rC->free();
    }

    $marco1px1 = $marco1px ?? '100%';
    $marco1px  = "100%";
    ?>
    <div class="grid-item col-xs-12 col-sm-6 col-md-6 col-lg-6">
        <?php if ($home !== 'no') { ?>

            <?php if ($cat_id !== '0') { ?>
                <div style="margin:3px 0;">
                    <span style="letter-spacing:0.5px;line-height:1em;padding:2px 7px;background-color:<?php
                        echo ($color_cat === '' || $color_cat === '#FFFFFF') ? '#666666' : e($color_cat);
                    ?>;font-family:<?php echo e((string)$style_titulo); ?>;font-size:11px;color:#FFFFFF;">
                        <?php echo e((string)$cat); ?>
                    </span>
                </div>
            <?php } ?>

            <style>.tita:hover span{}</style>

            <div style="margin:3px 0;padding:5px;">
                <a style="color:#fff;" href="<?php echo e((string)$dom); ?>/nota/<?php echo $ID; ?>/<?php echo e(urls_amigables($titulo)); ?>" class="tita">
                    <span style="line-height:<?php echo e((string)$d_ta_titulo); ?>;display:block;font-family:<?php echo e((string)$style_titulo); ?>;font-size:<?php echo e((string)$d_ta_titulo); ?>;color:<?php echo e((string)$d_color_titulo); ?>;">
                        <?php echo e($titulo); ?>
                    </span>
                </a>
            </div>

            <?php if (!empty($foto)) { ?>
                <div>
                    <?php
                    // OJO: getimagesize remoto puede fallar si allow_url_fopen=0. Si te rompe, lo sacamos.
                    $file = rtrim((string)$dom, '/') . '/' . ltrim($carpetafoto, '/') . '/thumbnail_' . $foto . $ext_img;
                    $alto_new = 0;

                    $imagen = @getimagesize($file);
                    if (is_array($imagen)) {
                        $ancho = (int)$imagen[0];
                        $alto  = (int)$imagen[1];
                        if ($ancho > 0) {
                            if (!empty($estiloweb) && (int)$estiloweb === 1) {
                                $alto_new = (int)round($alto * 322 / $ancho);
                            } else {
                                $alto_new = (int)round($alto * 410 / $ancho);
                            }
                        }
                    }
                    ?>
                    <style>
                        .img-contenedor { width:<?php echo e($marco1px); ?>; overflow:hidden; }
                    </style>

                    <div class="img-contenedor img-responsive">
                        <?php if (($funcion2 ?? '') === 'si') { ?>
                            <div class="fecha_cuadrada" style="background-color:<?php echo e((string)$d_color_fondo_menu); ?>">
                                <a href="<?php echo e((string)$dom); ?>/nota/<?php echo $ID; ?>/<?php echo e(urls_amigables($titulo)); ?>">
                                    <span style="font-family:<?php echo e((string)$style_titulo); ?>;font-size:20px;color:#FFFFFF;"><?php echo e($d); ?></span><br/>
                                    <span style="font-family:<?php echo e((string)$style_titulo); ?>;font-size:12px;color:#FFFFFF;"><?php echo e($m_txt); ?></span>
                                </a>
                            </div>
                        <?php } ?>

                        <a style="display:block;" href="<?php echo e((string)$dom); ?>/nota/<?php echo $ID; ?>/<?php echo e(urls_amigables($titulo)); ?>">
                            <img
                                src="<?php echo e((string)$dom); ?>/<?php echo e($carpetafoto); ?>/thumbnail_<?php echo e((string)$foto); ?><?php echo e($ext_img); ?>"
                                alt="<?php echo e($titulo); ?>"
                                width="<?php echo e($marco1px); ?>"
                                border="0"
                                loading="lazy"
                            />
                        </a>
                    </div>

                    <?php
                    // icono fotogaleria
                    $hasGaleria = false;
                    if ($stmtFotoGal) {
                        $stmtFotoGal->bind_param("i", $ID);
                        $stmtFotoGal->execute();
                        $rg = $stmtFotoGal->get_result();
                        if ($rg->fetch_assoc()) $hasGaleria = true;
                        $rg->free();
                    }
                    if ($hasGaleria) { ?>
                        <div align="right">
                            <a href="<?php echo e((string)$dom); ?>/nota/<?php echo $ID; ?>/<?php echo e(urls_amigables($titulo)); ?>">
                                <img src="<?php echo e((string)$dom); ?>/fotogaleria.png" width="140" loading="lazy" />
                            </a>
                        </div>
                    <?php } ?>
                </div>
            <?php } ?>

            <?php if (!empty($youtube)) { ?>
                <div style="display:block;margin-top:10px;">
                    <iframe width="<?php echo e($marco1px); ?>" height="315"
                            src="https://www.youtube.com/embed/<?php echo e($youtube); ?>"
                            frameborder="0" allowfullscreen></iframe>
                </div>
            <?php } ?>

            <div style="display:block;">
                <div align="justify" style="margin-top:10px;">
                    <span style="font-family:<?php echo e((string)$d_fu_texto); ?>;font-size:<?php echo e((string)$d_ta_texto); ?>;color:#6B6B6B;line-height:<?php echo e((string)$d_ta_texto); ?>;">
                        <?php echo e($bajada); ?>
                    </span>
                </div>

                <?php include __DIR__ . '/audio.php'; ?>
            </div>

            <div style="display:block;position:relative;right:0;margin:3px 0;">
                <div align="right">
                    <?php if ($n <= 0) { ?>
                        <a style="color:#6B6B6B;" href="<?php echo e((string)$dom); ?>/nota/<?php echo $ID; ?>/<?php echo e(urls_amigables($titulo)); ?>">
                            Dejar un comentario<?php if ($texto !== '') { ?> - Leer m&aacute;s...<?php } ?>
                        </a>
                    <?php } else { ?>
                        <a style="color:#6B6B6B;" href="<?php echo e((string)$dom); ?>/nota/<?php echo $ID; ?>/<?php echo e(urls_amigables($titulo)); ?>">
                            <?php echo (int)$n; ?> comentarios<?php if ($texto !== '') { ?> - Leer m&aacute;s...<?php } ?>
                        </a>
                    <?php } ?>

                    <?php include __DIR__ . '/compartir_nota_facebook.php'; ?>
                </div>
            </div>

            <div style="margin:3px 0;width:100%;height:3px;border-top:0.5px solid rgba(0,0,0,0.1)!important;"></div>

        <?php } ?>

        <?php
        // -------- Publicidades JPG (mysqli)
        if ($stmtPubJpg) {
            $stmtPubJpg->bind_param("i", $i_publi);
            $stmtPubJpg->execute();
            $rPub = $stmtPubJpg->get_result();
            while ($p = $rPub->fetch_assoc()) {
                $img = (string)$p['img'];
                $url = $p['url'];
                $carp = (string)$p['carpetafoto'];
                ?>
                <div style="text-align:center;">
                    <?php if (!empty($url)) { ?><a href="<?php echo e((string)$url); ?>" target="_blank"><?php } ?>
                        <img class="lazy img-responsive" src="<?php echo e($carp); ?>/resize_<?php echo e($img); ?>.jpg" width="100%" loading="lazy">
                    <?php if (!empty($url)) { ?></a><?php } ?>
                </div>
                <div style="margin:3px 0;width:100%;height:3px;border-top:0.5px solid rgba(0,0,0,0.1)!important;"></div>
                <?php
            }
            $rPub->free();
        }

        // -------- Publicidades GIF (mysqli)
        if ($stmtPubGif) {
            $stmtPubGif->bind_param("i", $i_publi);
            $stmtPubGif->execute();
            $rGif = $stmtPubGif->get_result();
            while ($g = $rGif->fetch_assoc()) {
                $img = (string)$g['img'];
                $url = $g['url'];
                $carp = (string)$g['carpetafoto'];
                ?>
                <div style="text-align:center;">
                    <?php if (!empty($url)) { ?><a href="<?php echo e((string)$url); ?>" target="_blank" class="Estilo1"><?php } ?>
                        <img class="lazy" src="<?php echo e((string)$dom); ?>/<?php echo e($carp); ?>/<?php echo e($img); ?>" width="100%" alt="PUBLICIDAD" border="0" loading="lazy" />
                    <?php if (!empty($url)) { ?></a><?php } ?>
                </div>
                <div style="text-align:center;">
                    <img src="linea.gif" align="middle" class="img-responsive" loading="lazy" />
                </div>
                <?php
            }
            $rGif->free();
        }

        // -------- Publicidades SLIDE (mysqli)
        if ($stmtPubSld) {
            $stmtPubSld->bind_param("i", $i_publi);
            $stmtPubSld->execute();
            $rS = $stmtPubSld->get_result();
            while ($s = $rS->fetch_assoc()) {
                $ID_p = (int)$s['ID'];
                $width_slide = $marco1px;
                include __DIR__ . '/publicidad_slider_virgen.php';
            }
            $rS->free();
        }

        // -------- Publicidades SWF (mysqli) (ojo: tecnología vieja)
        $tam_ancho = 300;
        if ($stmtPubSwf) {
            $stmtPubSwf->bind_param("i", $i_publi);
            $stmtPubSwf->execute();
            $rSwf = $stmtPubSwf->get_result();
            while ($sw = $rSwf->fetch_assoc()) {
                $swf = (string)$sw['swf'];
                $carp = (string)$sw['carpetafoto'];
                $ancho = (int)$sw['ancho'];
                $alto  = (int)$sw['alto'];
                $tam_alto = ($ancho > 0) ? (int)round($alto * $tam_ancho / $ancho) : 0;
                ?>
                <div style="text-align:center;">
                    <object width="<?php echo (int)$tam_ancho; ?>" height="<?php echo (int)$tam_alto; ?>">
                        <param name="src" value="<?php echo e((string)$dom); ?>/<?php echo e($carp); ?>/<?php echo e($swf); ?>" />
                        <embed src="<?php echo e((string)$dom); ?>/<?php echo e($carp); ?>/<?php echo e($swf); ?>"
                               pluginspage="https://www.adobe.com/shockwave/download/"
                               width="<?php echo (int)$tam_ancho; ?>" height="<?php echo (int)$tam_alto; ?>"></embed>
                    </object>
                </div>
                <div style="text-align:center;">
                    <img src="linea.gif" align="middle" class="img-responsive" loading="lazy" />
                </div>
                <?php
            }
            $rSwf->free();
        }
        ?>
    </div>

    <?php
    if (($i_publi % 5) === 0) {
        if (($adsense ?? '') !== ' ') {
            ?>
            <div class="grid-item col-xs-12 col-sm-6 col-md-6 col-lg-6" style="text-align:center;">
                <?php echo (string)$adsense; ?>
            </div>
            <?php
        }
    }

    $i++;
} // end while notas no destacadas

$res->free();
$stmt->close();

// ----------------------------------------------------
// 2) NOTAS DESTACADAS (ANTES ERA mysql_*). PASADO A mysqli.
// ----------------------------------------------------
$sqlD = "
    SELECT ID,titulo,bajada,texto,audio,youtube,d,m,a,carpetafoto,foto,cat,home,impresiones,ext_img
    FROM notas
    WHERE destacado = 'si' AND ver = 'si'
    ORDER BY ID DESC
";
$resD = $conn->query($sqlD);
if ($resD) {
    while ($row = $resD->fetch_assoc()) {
        $i_publi++;

        $ID     = (int)$row['ID'];
        $youtube= (string)$row['youtube'];
        $titulo = (string)$row['titulo'];
        $bajada = (string)$row['bajada'];
        $texto  = (string)$row['texto'];
        $audio  = (string)$row['audio'];

        $d      = (string)$row['d'];
        $m      = (string)$row['m'];
        $a      = (string)$row['a'];
        $fecha  = $d . " - " . $m . " - " . $a;

        $carpetafoto = (string)$row['carpetafoto'];
        $foto        = $row['foto'];
        $ext_img     = (string)$row['ext_img'];

        $cat_id      = (string)$row['cat'];

        // impresiones +1
        $impresiones = (int)$row['impresiones'] + 1;
        if ($stmtUpdImp) {
            $stmtUpdImp->bind_param("ii", $impresiones, $ID);
            $stmtUpdImp->execute();
        }

        // categoria
        $cat = $cat_id;
        $color_cat = '';
        if ($cat_id !== '0' && $cat_id !== '' && $stmtCat) {
            $cid = (int)$cat_id;
            $stmtCat->bind_param("i", $cid);
            $stmtCat->execute();
            $rCat = $stmtCat->get_result();
            if ($r = $rCat->fetch_assoc()) {
                $cat = (string)$r['nombre'];
                $color_cat = (string)$r['color'];
            }
            $rCat->free();
        }

        // comentarios count
        $n = 0;
        if ($stmtComCnt) {
            $stmtComCnt->bind_param("i", $ID);
            $stmtComCnt->execute();
            $rC = $stmtComCnt->get_result();
            if ($rc = $rC->fetch_assoc()) $n = (int)$rc['c'];
            $rC->free();
        }
        ?>
        <div class="grid-item col-12 col-sm-6 col-md-6 col-lg-6 mb-3 border">
            <b>LUGAR: <?php echo (int)$i_publi; ?></b>

            <div class="col-12" style="background-color:<?php echo e((string)$d_color_destacada); ?>;">
                <?php if ($cat_id !== '0') { ?>
                    <div class="col-12">
                        <p><?php echo e((string)$cat); ?></p>
                    </div>
                <?php } ?>

                <div class="col-12">
                    <a href="<?php echo e((string)$dom); ?>/nota/<?php echo $ID; ?>/<?php echo e(urls_amigables($titulo)); ?>">
                        <h4 style="color:#fff;"><?php echo e($titulo); ?></h4>
                    </a>
                </div>

                <?php if (!empty($foto)) { ?>
                    <div class="col-12">
                        <a href="<?php echo e((string)$dom); ?>/nota/<?php echo $ID; ?>/<?php echo e(urls_amigables($titulo)); ?>">
                            <?php
                            $fotoStr = (string)$foto;
                            $fotojj = substr($fotoStr, 0, 4);
                            $srcImg = ($fotojj === 'http')
                                ? $fotoStr
                                : (rtrim((string)$dom, '/') . '/' . ltrim($carpetafoto, '/') . '/thumbnail_' . $fotoStr . $ext_img);
                            ?>
                            <img loading="lazy" class="img-fluid" src="<?php echo e($srcImg); ?>" alt="<?php echo e($titulo); ?>">
                        </a>
                    </div>

                    <?php
                    // fotogaleria
                    $hasGaleria = false;
                    if ($stmtFotoGal) {
                        $stmtFotoGal->bind_param("i", $ID);
                        $stmtFotoGal->execute();
                        $rg = $stmtFotoGal->get_result();
                        if ($rg->fetch_assoc()) $hasGaleria = true;
                        $rg->free();
                    }
                    if ($hasGaleria) { ?>
                        <div class="col-12">
                            <a href="<?php echo e((string)$dom); ?>/nota/<?php echo $ID; ?>/<?php echo e(urls_amigables($titulo)); ?>">
                                <img src="fotogaleria.png" class="img-fluid" loading="lazy" />
                            </a>
                        </div>
                    <?php } ?>
                <?php } ?>

                <?php if (!empty($youtube)) { ?>
                    <div class="col-12">
                        <iframe width="<?php echo e((string)$marco1px); ?>" height="315"
                                src="https://www.youtube.com/embed/<?php echo e($youtube); ?>"
                                frameborder="0" allowfullscreen></iframe>
                    </div>
                <?php } ?>

                <div class="col-12">
                    <div class="col-12">
                        <p style="color:#fff;"><?php echo e($bajada); ?></p>
                        <p style="color:#fff;"><?php echo e($fecha); ?></p>
                    </div>

                    <?php include __DIR__ . '/audio.php'; ?>
                </div>

                <div class="col-12">
                    <ul>
                        <?php if ($n <= 0) { ?>
                            <li>
                                <a href="<?php echo e((string)$dom); ?>/nota/<?php echo $ID; ?>/<?php echo e(urls_amigables($titulo)); ?>">
                                    Dejar un comentario<?php if ($texto !== '') { ?> - Leer m&aacute;s...<?php } ?>
                                </a>
                            </li>
                        <?php } else { ?>
                            <li>
                                <a href="<?php echo e((string)$dom); ?>/nota/<?php echo $ID; ?>/<?php echo e(urls_amigables($titulo)); ?>">
                                    <?php echo (int)$n; ?> comentarios<?php if ($texto !== '') { ?> - Leer m&aacute;s...<?php } ?>
                                </a>
                            </li>
                        <?php } ?>
                    </ul>
                </div>

                <div class="col-12">
                    <?php include __DIR__ . '/compartir_nota_facebook.php'; ?>
                </div>

                <?php
                // Publicidades JPG (destacadas)
                if ($stmtPubJpg) {
                    $stmtPubJpg->bind_param("i", $i_publi);
                    $stmtPubJpg->execute();
                    $rPub = $stmtPubJpg->get_result();
                    while ($p = $rPub->fetch_assoc()) {
                        $img = (string)$p['img'];
                        $url = $p['url'];
                        $carp = (string)$p['carpetafoto'];
                        ?>
                        <div class="col-12">
                            <?php if (!empty($url)) { ?><a href="<?php echo e((string)$url); ?>" target="_blank"><?php } ?>
                                <img src="<?php echo e($carp); ?>/resize_<?php echo e($img); ?>.jpg"
                                     width="<?php echo e((string)$marco1px); ?>" alt="PUBLICIDAD" class="img-fluid" loading="lazy" />
                            <?php if (!empty($url)) { ?></a><?php } ?>
                        </div>
                        <?php
                    }
                    $rPub->free();
                }

                // Publicidades GIF
                if ($stmtPubGif) {
                    $stmtPubGif->bind_param("i", $i_publi);
                    $stmtPubGif->execute();
                    $rGif = $stmtPubGif->get_result();
                    while ($g = $rGif->fetch_assoc()) {
                        $img = (string)$g['img'];
                        $url = $g['url'];
                        $carp = (string)$g['carpetafoto'];
                        ?>
                        <div class="col-12">
                            <?php if (!empty($url)) { ?><a href="<?php echo e((string)$url); ?>" target="_blank" class="Estilo1"><?php } ?>
                                <img src="<?php echo e((string)$dom); ?>/<?php echo e($carp); ?>/<?php echo e($img); ?>"
                                     width="<?php echo e((string)$marco1px); ?>" class="img-fluid" loading="lazy" />
                            <?php if (!empty($url)) { ?></a><?php } ?>
                        </div>
                        <?php
                    }
                    $rGif->free();
                }

                // SLIDE
                if ($stmtPubSld) {
                    $stmtPubSld->bind_param("i", $i_publi);
                    $stmtPubSld->execute();
                    $rS = $stmtPubSld->get_result();
                    while ($s = $rS->fetch_assoc()) {
                        $ID_p = (int)$s['ID'];
                        $width_slide = (string)$marco1px;
                        include __DIR__ . '/publicidad_slider_virgen.php';
                        ?>
                        <a class="btn btn-outline-primary" href="quitar_publicidad_slide_noticias.php?ID=<?php echo $ID_p; ?>">QUITAR SLIDE DEL LUGAR</a>
                        <?php
                    }
                    $rS->free();
                }

                // SWF
                $tam_ancho = 300;
                if ($stmtPubSwf) {
                    $stmtPubSwf->bind_param("i", $i_publi);
                    $stmtPubSwf->execute();
                    $rSwf = $stmtPubSwf->get_result();
                    while ($sw = $rSwf->fetch_assoc()) {
                        $swf = (string)$sw['swf'];
                        $carp = (string)$sw['carpetafoto'];
                        $ancho = (int)$sw['ancho'];
                        $alto  = (int)$sw['alto'];
                        $tam_alto = ($ancho > 0) ? (int)round($alto * $tam_ancho / $ancho) : 0;
                        ?>
                        <div class="col-12">
                            <object width="<?php echo (int)$tam_ancho; ?>" height="<?php echo (int)$tam_alto; ?>">
                                <param name="src" value="<?php echo e((string)$dom); ?>/<?php echo e($carp); ?>/<?php echo e($swf); ?>" />
                                <embed src="<?php echo e((string)$dom); ?>/<?php echo e($carp); ?>/<?php echo e($swf); ?>"
                                       pluginspage="http://www.adobe.com/shockwave/download/"
                                       width="<?php echo (int)$tam_ancho; ?>" height="<?php echo (int)$tam_alto; ?>"></embed>
                            </object>
                        </div>
                        <?php
                    }
                    $rSwf->free();
                }
                ?>
            </div>

            <div class="col-12">
                <form id="form1" name="form1" method="POST" action="panel/poner_publicidad_en_noticias.php">
                    <p>Agregar publi</p>
                    <div class="d-flex justify-content-between mb-3">
                        <input name="button" type="submit" class="btn btn-outline-primary" value="Flash" />
                        <input name="lugar" type="hidden" value="<?php echo (int)$i_publi; ?>" />
                        <input name="button" type="submit" class="btn btn-outline-primary" value="Jpg" />
                        <input name="button" type="submit" class="btn btn-outline-primary" value="Gif/Png" />
                        <input name="button" type="submit" class="btn btn-outline-primary" value="Slider" />
                    </div>
                </form>
            </div>
        </div>
        <?php
    }
    $resD->free();
}

// cerrar statements
if ($stmtUpdImp) $stmtUpdImp->close();
if ($stmtCat)    $stmtCat->close();
if ($stmtComCnt) $stmtComCnt->close();
if ($stmtFotoGal)$stmtFotoGal->close();

if ($stmtPubJpg) $stmtPubJpg->close();
if ($stmtPubGif) $stmtPubGif->close();
if ($stmtPubSld) $stmtPubSld->close();
if ($stmtPubSwf) $stmtPubSwf->close();
?>