diff --git a/api/record_history.php b/api/record_history.php new file mode 100644 index 0000000..56f9830 --- /dev/null +++ b/api/record_history.php @@ -0,0 +1,35 @@ + false, 'error' => 'Invalid input']); + exit; +} + +$title = $input['title']; +$artist = $input['artist']; +$cover = $input['cover'] ?? null; + +try { + $db = db(); + + // Check if the last recorded song is the same to avoid duplicates on refresh + $stmt = $db->prepare("SELECT title, artist FROM song_history ORDER BY played_at DESC LIMIT 1"); + $stmt->execute(); + $last = $stmt->fetch(); + + if ($last && $last['title'] === $title && $last['artist'] === $artist) { + echo json_encode(['success' => true, 'message' => 'Already recorded']); + exit; + } + + $stmt = $db->prepare("INSERT INTO song_history (title, artist, cover) VALUES (?, ?, ?)"); + $stmt->execute([$title, $artist, $cover]); + + echo json_encode(['success' => true]); +} catch (PDOException $e) { + echo json_encode(['success' => false, 'error' => $e->getMessage()]); +} diff --git a/db/migrations/001_create_song_history.sql b/db/migrations/001_create_song_history.sql new file mode 100644 index 0000000..8c67f5e --- /dev/null +++ b/db/migrations/001_create_song_history.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS song_history ( + id INT AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(255) NOT NULL, + artist VARCHAR(255) NOT NULL, + cover VARCHAR(500), + played_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); diff --git a/history.php b/history.php new file mode 100644 index 0000000..696bb40 --- /dev/null +++ b/history.php @@ -0,0 +1,263 @@ +query("SELECT * FROM song_history WHERE played_at > DATE_SUB(NOW(), INTERVAL 24 HOUR) ORDER BY played_at DESC LIMIT 50"); +$history = $stmt->fetchAll(); +?> + + + + + + Historial - Lili Records Radio + + + + + + + + + +
+ +
+
+
+ + VOLVER + +

HISTORIAL

+ +
+ +
+ +
No hay canciones registradas en las Ășltimas 24 horas.
+ + +
+ Cover +
+ + +
+
+ +
+
+ + +
+
+
+ + + + diff --git a/index.php b/index.php index 7d666d9..42c5a8e 100644 --- a/index.php +++ b/index.php @@ -39,6 +39,16 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; --bg-overlay: rgba(0, 0, 0, 0.15); /* Even lighter for maximum transparency */ --glass-bg: rgba(255, 255, 255, 0.03); /* Almost invisible glass */ --glass-border: rgba(255, 255, 255, 0.2); + --text-color: #ffffff; + --card-shadow: rgba(0, 0, 0, 0.4); + } + + [data-theme="light"] { + --bg-overlay: rgba(255, 255, 255, 0.6); + --glass-bg: rgba(255, 255, 255, 0.8); + --glass-border: rgba(0, 0, 0, 0.1); + --text-color: #1a1a1a; + --card-shadow: rgba(0, 0, 0, 0.15); } body, html { @@ -47,8 +57,9 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; width: 100%; height: 100%; font-family: 'Inter', sans-serif; - color: #ffffff; + color: var(--text-color); background-color: transparent; + transition: color 0.3s ease; } .background { @@ -144,7 +155,7 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; font-size: 2.8rem; font-weight: 800; margin: 0 0 0.5rem; - background: linear-gradient(to right, #fff, var(--primary-color), var(--accent-color)); + background: linear-gradient(to right, var(--text-color), var(--primary-color), var(--accent-color)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: -1px; @@ -248,7 +259,7 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; overflow: hidden; text-overflow: ellipsis; transition: color 0.05s ease, transform 0.05s ease, text-shadow 0.05s ease, opacity 0.5s ease; - color: #ffffff; + color: var(--text-color); text-shadow: 0 0 15px rgba(56, 189, 248, 0.6); display: block; margin-top: 0.2rem; @@ -500,9 +511,9 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; width: 100%; padding: 0.8rem; border-radius: 12px; - border: 1px solid rgba(255, 255, 255, 0.2); - background-color: rgba(255, 255, 255, 0.05); /* Even more transparent */ - color: #ffffff; + border: 1px solid var(--glass-border); + background-color: var(--glass-bg); + color: var(--text-color); font-family: inherit; font-size: 0.95rem; box-sizing: border-box; @@ -518,7 +529,8 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; .interaction-form input::placeholder, .interaction-form textarea::placeholder { - color: rgba(255, 255, 255, 0.6); + color: var(--text-color); + opacity: 0.5; } .send-whatsapp-btn { @@ -900,6 +912,14 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489";
+
+ + + + +
@@ -1929,6 +1949,13 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; if (coverPlaceholder) coverPlaceholder.style.display = 'none'; trackCover.style.opacity = '1'; + // Record History in Database + fetch('api/record_history.php', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ title: title, artist: artist, cover: coverUrl }) + }).catch(err => console.error("Error recording history:", err)); + // Dynamic Color Extraction trackCover.onload = function() { try { @@ -2032,6 +2059,36 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489"; fetchTopSongs(); }, 30000); + // Theme Toggle Functionality + function toggleTheme() { + const body = document.body; + const currentTheme = body.getAttribute('data-theme'); + const newTheme = currentTheme === 'light' ? 'dark' : 'light'; + const themeBtn = document.getElementById('theme-toggle').querySelector('i'); + + body.setAttribute('data-theme', newTheme); + localStorage.setItem('theme', newTheme); + + if (newTheme === 'light') { + themeBtn.classList.remove('bi-moon-fill'); + themeBtn.classList.add('bi-sun-fill'); + } else { + themeBtn.classList.remove('bi-sun-fill'); + themeBtn.classList.add('bi-moon-fill'); + } + } + + // Initialize Theme + (function() { + const savedTheme = localStorage.getItem('theme') || 'dark'; + if (savedTheme === 'light') { + document.body.setAttribute('data-theme', 'light'); + const themeBtn = document.getElementById('theme-toggle').querySelector('i'); + themeBtn.classList.remove('bi-moon-fill'); + themeBtn.classList.add('bi-sun-fill'); + } + })(); + // Handle possible audio interruptions audio.addEventListener('error', function(e) { console.error('Audio error:', e);