From e6625de8bb88805066967c9f8aa65f656b61dc70 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Tue, 17 Feb 2026 17:08:28 +0000 Subject: [PATCH] Auto commit: 2026-02-17T17:08:28.722Z --- api/song_requests.php | 37 ++++ .../20260217_create_song_requests.sql | 1 + index.php | 163 ++++++++++++++++++ 3 files changed, 201 insertions(+) create mode 100644 api/song_requests.php create mode 100644 db/migrations/20260217_create_song_requests.sql diff --git a/api/song_requests.php b/api/song_requests.php new file mode 100644 index 0000000..81f3f68 --- /dev/null +++ b/api/song_requests.php @@ -0,0 +1,37 @@ + false, 'error' => 'Falta artista o canción']); + exit; + } + + try { + $stmt = $db->prepare("INSERT INTO song_requests (artist, song, requester) VALUES (?, ?, ?)"); + $stmt->execute([$artist, $song, $requester]); + echo json_encode(['success' => true]); + } catch (Exception $e) { + echo json_encode(['success' => false, 'error' => $e->getMessage()]); + } + exit; +} + +if ($method === 'GET') { + try { + $stmt = $db->query("SELECT * FROM song_requests ORDER BY created_at DESC LIMIT 10"); + $requests = $stmt->fetchAll(); + echo json_encode(['success' => true, 'requests' => $requests]); + } catch (Exception $e) { + echo json_encode(['success' => true, 'requests' => [], 'error' => $e->getMessage()]); + } + exit; +} diff --git a/db/migrations/20260217_create_song_requests.sql b/db/migrations/20260217_create_song_requests.sql new file mode 100644 index 0000000..862f0cb --- /dev/null +++ b/db/migrations/20260217_create_song_requests.sql @@ -0,0 +1 @@ +CREATE TABLE IF NOT EXISTS song_requests (id INT AUTO_INCREMENT PRIMARY KEY, artist VARCHAR(255) NOT NULL, song VARCHAR(255) NOT NULL, requester VARCHAR(100) DEFAULT 'Anónimo', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/index.php b/index.php index 7036d93..f6ed7d2 100644 --- a/index.php +++ b/index.php @@ -977,6 +977,48 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; font-size: 1.1rem; } } + + /* Song Requests Styles */ + .request-list { + display: flex; + flex-direction: column; + gap: 0.8rem; + max-height: 300px; + overflow-y: auto; + padding-right: 5px; + } + .request-item { + background: rgba(255, 255, 255, 0.05); + border: 1px solid rgba(255, 255, 255, 0.1); + padding: 0.8rem; + border-radius: 12px; + animation: fadeIn 0.5s ease; + } + .request-item .artist { + color: var(--primary-color); + font-weight: 800; + font-size: 0.8rem; + text-transform: uppercase; + } + .request-item .song { + font-weight: 600; + font-size: 0.95rem; + margin: 2px 0; + } + .request-item .requester { + font-size: 0.7rem; + opacity: 0.6; + font-style: italic; + } + .request-badge { + background: var(--primary-color); + color: white; + padding: 2px 6px; + border-radius: 4px; + font-size: 0.6rem; + font-weight: bold; + margin-right: 5px; + } @@ -1194,6 +1236,31 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; + + +
+

+ PETICIONES EN VIVO +

+
+
+
+ + +
+
+ + +
+
+ +
+
+
No hay peticiones recientes.
+
+
@@ -1754,6 +1821,102 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; setInterval(updatePhotoCounter, 30000); // Check limit status every 30s // --- End Chat Functionality --- + // --- Song Request Functionality --- + async function fetchSongRequests() { + try { + const response = await fetch('api/song_requests.php'); + const result = await response.json(); + if (result.success) { + const list = document.getElementById('song-requests-list'); + if (result.requests.length === 0) { + list.innerHTML = '
No hay peticiones recientes.
'; + return; + } + list.innerHTML = result.requests.map(req => ` +
+
+ ${req.artist} + ${new Date(req.created_at).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})} +
+
${req.song}
+
${req.requester}
+
+ `).join(''); + } + } catch (error) { + console.error('Error fetching requests:', error); + } + } + + async function submitSongRequest() { + const artistInput = document.getElementById('req-artist'); + const songInput = document.getElementById('req-song'); + const artist = artistInput.value.trim(); + const song = songInput.value.trim(); + const requester = document.getElementById('user-name').value.trim() || 'Anónimo'; + + if (!artist || !song) { + alert('Por favor, ingresa el artista y el nombre de la canción.'); + if (!artist) artistInput.style.borderColor = '#ff4444'; + if (!song) songInput.style.borderColor = '#ff4444'; + return; + } + + const btn = document.getElementById('submit-req-btn'); + btn.disabled = true; + btn.innerHTML = ' ENVIANDO...'; + + try { + const formData = new FormData(); + formData.append('artist', artist); + formData.append('song', song); + formData.append('requester', requester); + + const response = await fetch('api/song_requests.php', { + method: 'POST', + body: formData + }); + const result = await response.json(); + if (result.success) { + artistInput.value = ''; + songInput.value = ''; + artistInput.style.borderColor = ''; + songInput.style.borderColor = ''; + fetchSongRequests(); + + // Small visual feedback + btn.innerHTML = ' ¡PEDIDA!'; + btn.style.backgroundColor = 'var(--accent-color)'; + + confetti({ + particleCount: 50, + spread: 60, + origin: { y: 0.8 }, + colors: ['#38bdf8', '#00e676'] + }); + + setTimeout(() => { + btn.disabled = false; + btn.innerHTML = ' PEDIR CANCIÓN'; + btn.style.backgroundColor = ''; + }, 3000); + } else { + alert('Error: ' + (result.error || 'No se pudo enviar la petición')); + btn.disabled = false; + btn.innerHTML = ' PEDIR CANCIÓN'; + } + } catch (error) { + console.error('Error submitting request:', error); + btn.disabled = false; + btn.innerHTML = ' PEDIR CANCIÓN'; + } + } + + // Initial fetch and poll for requests + fetchSongRequests(); + setInterval(fetchSongRequests, 10000); // Update requests every 10s + // --- End Song Request Functionality --- + function openQRModal() { const modal = document.getElementById('qr-modal'); modal.style.display = 'flex';