From 39ef6459d5a759f72f359f4d3084528370158417 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Tue, 17 Feb 2026 22:31:25 +0000 Subject: [PATCH] Auto commit: 2026-02-17T22:31:25.089Z --- api/chat.php | 15 ++++++++++++++- api/gallery.php | 13 +++++++++++++ index.php | 10 ++++++++-- uploads/img_6994cd080114f2.59031401.jpeg | Bin 315427 -> 0 bytes 4 files changed, 35 insertions(+), 3 deletions(-) delete mode 100644 uploads/img_6994cd080114f2.59031401.jpeg diff --git a/api/chat.php b/api/chat.php index a6a059e..38a117d 100644 --- a/api/chat.php +++ b/api/chat.php @@ -7,7 +7,20 @@ $method = $_SERVER['REQUEST_METHOD']; if ($method === 'GET') { try { - // Limpiar mensajes y archivos de más de 6 horas + // Borrar fotos (tipo image) que tengan más de 5 segundos + $stOld = db()->prepare("SELECT message FROM messages WHERE type = 'image' AND created_at < DATE_SUB(NOW(), INTERVAL 5 SECOND)"); + $stOld->execute(); + $imagesToDelete = $stOld->fetchAll(PDO::FETCH_ASSOC); + + foreach ($imagesToDelete as $img) { + $path = __DIR__ . '/../' . $img['message']; + if (file_exists($path) && is_file($path)) { + unlink($path); + } + } + db()->query("DELETE FROM messages WHERE type = 'image' AND created_at < DATE_SUB(NOW(), INTERVAL 5 SECOND)"); + + // Limpiar otros mensajes y archivos de más de 6 horas $oldImages = db()->prepare("SELECT message FROM messages WHERE type = 'image' AND created_at < DATE_SUB(NOW(), INTERVAL 6 HOUR)"); $oldImages->execute(); $filesToDelete = $oldImages->fetchAll(PDO::FETCH_ASSOC); diff --git a/api/gallery.php b/api/gallery.php index e9ecb08..629def0 100644 --- a/api/gallery.php +++ b/api/gallery.php @@ -7,6 +7,19 @@ $method = $_SERVER['REQUEST_METHOD']; if ($method === 'GET') { try { + // Borrar fotos de la galería que tengan más de 5 segundos + $stOld = db()->prepare("SELECT image_url FROM gallery WHERE created_at < DATE_SUB(NOW(), INTERVAL 5 SECOND)"); + $stOld->execute(); + $imagesToDelete = $stOld->fetchAll(PDO::FETCH_ASSOC); + foreach ($imagesToDelete as $img) { + $path = __DIR__ . '/../' . $img['image_url']; + if (file_exists($path) && is_file($path)) { + // unlink($path); // Opcional: borrar el archivo físico. + // Pero si viene del chat, el chat ya lo borra si habilitamos lo mismo ahí. + } + } + db()->query("DELETE FROM gallery WHERE created_at < DATE_SUB(NOW(), INTERVAL 5 SECOND)"); + $stmt = db()->prepare("SELECT * FROM gallery ORDER BY created_at DESC LIMIT 50"); $stmt->execute(); $images = $stmt->fetchAll(PDO::FETCH_ASSOC); diff --git a/index.php b/index.php index 279dea5..809e3ce 100644 --- a/index.php +++ b/index.php @@ -2374,7 +2374,12 @@ $twitter_link = "https://twitter.com/"; let content = ''; if (msg.type === 'image') { - content = ``; + content = ` +
+ +
5s
+
+ `; } else { content = `
${msg.message}
`; } @@ -2985,6 +2990,7 @@ $twitter_link = "https://twitter.com/"; container.innerHTML = data.images.map(img => `