Auto commit: 2026-01-31T15:20:47.692Z
This commit is contained in:
parent
042de94bd3
commit
16a82414c9
@ -1,7 +0,0 @@
|
||||
CREATE TABLE IF NOT EXISTS songs (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
artist VARCHAR(255) NOT NULL,
|
||||
is_active TINYINT(1) DEFAULT 0,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
155
index.php
155
index.php
@ -26,22 +26,11 @@ $promoImage = "assets/pasted-20260130-234122-115a4b49.png";
|
||||
$qrImage = "assets/pasted-20260131-000858-4fff58f0.jpg";
|
||||
$logoImage = "assets/pasted-20260131-002028-7985dfae.png";
|
||||
|
||||
// Fetch latest requests and songs
|
||||
// Fetch latest requests
|
||||
$requests = [];
|
||||
$songs = [];
|
||||
$activeSong = null;
|
||||
try {
|
||||
$stmt = db()->query("SELECT name, phone, message, created_at FROM listener_requests ORDER BY created_at DESC LIMIT 20");
|
||||
$requests = $stmt->fetchAll();
|
||||
|
||||
$stmtSongs = db()->query("SELECT * FROM songs ORDER BY created_at ASC");
|
||||
$songs = $stmtSongs->fetchAll();
|
||||
foreach ($songs as $s) {
|
||||
if ($s["is_active"]) {
|
||||
$activeSong = $s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// Silently fail if table doesn't exist yet or other DB error
|
||||
}
|
||||
@ -417,65 +406,6 @@ try {
|
||||
.qr-container:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
/* Song Management Styles */
|
||||
.song-item-modal {
|
||||
background: rgba(255,255,255,0.05);
|
||||
border: 1px solid rgba(255,255,255,0.08);
|
||||
border-radius: 20px;
|
||||
padding: 1rem 1.5rem;
|
||||
margin-bottom: 1rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.song-item-modal:hover {
|
||||
background: rgba(255,255,255,0.1);
|
||||
}
|
||||
.song-active-modal {
|
||||
border-color: var(--primary-color);
|
||||
background: rgba(255, 45, 85, 0.1);
|
||||
}
|
||||
.song-title-text {
|
||||
font-weight: 700;
|
||||
display: block;
|
||||
color: #fff;
|
||||
}
|
||||
.song-artist-text {
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.6;
|
||||
color: #fff;
|
||||
}
|
||||
.btn-toggle-song {
|
||||
background: rgba(255,255,255,0.1);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
padding: 5px 15px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.btn-toggle-song.active {
|
||||
background: var(--primary-color);
|
||||
}
|
||||
.btn-delete-song {
|
||||
background: rgba(255,0,0,0.1);
|
||||
color: #ff4444;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.btn-delete-song:hover {
|
||||
background: #ff4444;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -492,8 +422,8 @@ try {
|
||||
</div>
|
||||
|
||||
<div class="song-info mb-4">
|
||||
<span class="d-block fw-bold fs-5" id="songTitle"><?= ($activeSong ? htmlspecialchars($activeSong["title"]) : "Conectando...") ?></span>
|
||||
<span class="d-block opacity-50 small" id="artistName"><?= ($activeSong ? htmlspecialchars($activeSong["artist"]) : "Lili Records Radio") ?></span>
|
||||
<span class="d-block fw-bold fs-5" id="songTitle">Conectando...</span>
|
||||
<span class="d-block opacity-50 small" id="artistName">Lili Records Radio</span>
|
||||
</div>
|
||||
|
||||
<div class="player-controls-row d-flex align-items-center gap-3 justify-content-center">
|
||||
@ -509,9 +439,6 @@ try {
|
||||
<canvas id="visualizer"></canvas>
|
||||
|
||||
<div class="mt-4 pt-3 border-top border-white border-opacity-10 position-relative" style="z-index: 2;">
|
||||
<button class="btn btn-sm btn-outline-light rounded-pill px-4 mb-2 w-100" data-bs-toggle="modal" data-bs-target="#playlistModal">
|
||||
<i class="fas fa-list-ul me-2"></i> <?= $isAdmin ? 'Gestión de Playlist' : 'Ver Playlist' ?>
|
||||
</button>
|
||||
<?php if ($isAdmin): ?>
|
||||
<div class="mt-2 small text-primary fw-bold"><i class="fas fa-user-shield me-1"></i> PANEL ADMINISTRADOR</div>
|
||||
<a href="?logout=1" class="btn btn-sm btn-outline-danger px-4 rounded-pill mt-2 w-100">Cerrar Sesión</a>
|
||||
@ -603,80 +530,6 @@ try {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Playlist -->
|
||||
<div class="modal fade" id="playlistModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content border-0" style="background: rgba(15,15,15,0.98); border-radius: 35px; backdrop-filter: blur(30px);">
|
||||
<div class="modal-header border-white border-opacity-10 px-5 py-4">
|
||||
<h5 class="modal-title fw-bold"><i class="fas fa-list-ul me-2 text-primary"></i>LISTA DE REPRODUCCIÓN</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body px-5 py-4">
|
||||
<?php if ($isAdmin): ?>
|
||||
<div class="mb-4 p-3 rounded-4" style="background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border);">
|
||||
<h6 class="small fw-bold mb-3 text-uppercase text-primary">Añadir Nueva Canción</h6>
|
||||
<form action="manage_songs.php" method="POST" class="row g-2">
|
||||
<input type="hidden" name="action" value="add">
|
||||
<div class="col-sm-5">
|
||||
<input type="text" name="title" class="form-control form-control-glass" placeholder="Título" required>
|
||||
</div>
|
||||
<div class="col-sm-5">
|
||||
<input type="text" name="artist" class="form-control form-control-glass" placeholder="Artista" required>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<button type="submit" class="btn btn-send-request text-white w-100 h-100">
|
||||
<i class="fas fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="comments-list" style="max-height: 450px;">
|
||||
<?php if (empty($songs)): ?>
|
||||
<div class="text-center py-4 opacity-30">
|
||||
<i class="fas fa-music fa-3x mb-3"></i>
|
||||
<p>No hay canciones en la lista.</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($songs as $song): ?>
|
||||
<div class="song-item-modal <?= $song['is_active'] ? 'song-active-modal' : '' ?>">
|
||||
<div>
|
||||
<span class="song-title-text"><?= htmlspecialchars($song['title']) ?></span>
|
||||
<span class="song-artist-text"><?= htmlspecialchars($song['artist']) ?></span>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<?php if ($isAdmin): ?>
|
||||
<form action="manage_songs.php" method="POST" class="m-0">
|
||||
<input type="hidden" name="action" value="toggle_active">
|
||||
<input type="hidden" name="id" value="<?= $song['id'] ?>">
|
||||
<button type="submit" class="btn-toggle-song <?= $song['is_active'] ? 'active' : '' ?>">
|
||||
<?= $song['is_active'] ? 'AL AIRE' : 'PONER AL AIRE' ?>
|
||||
</button>
|
||||
</form>
|
||||
<form action="manage_songs.php" method="POST" class="m-0" onsubmit="return confirm('¿Eliminar canción?')">
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<input type="hidden" name="id" value="<?= $song['id'] ?>">
|
||||
<button type="submit" class="btn-delete-song">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
</form>
|
||||
<?php elseif ($song['is_active']): ?>
|
||||
<span class="badge rounded-pill bg-primary px-3 py-2">SONANDO AHORA</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer border-0 px-5 pb-5">
|
||||
<button type="button" class="btn btn-outline-light px-5 py-2 rounded-pill fw-bold" data-bs-dismiss="modal">CERRAR</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Política de Privacidad -->
|
||||
<div class="modal fade" id="policyModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
@ -734,7 +587,6 @@ try {
|
||||
const artistName = document.getElementById('artistName');
|
||||
const canvas = document.getElementById('visualizer');
|
||||
const ctx = canvas.getContext('2d');
|
||||
const hasActiveSong = <?= json_encode(!empty($activeSong)) ?>;
|
||||
|
||||
let isPlaying = false;
|
||||
let audioContext;
|
||||
@ -829,7 +681,6 @@ try {
|
||||
});
|
||||
|
||||
async function fetchMetadata() {
|
||||
if (hasActiveSong) return;
|
||||
try {
|
||||
const response = await fetch('https://api.radioking.io/widget/radio/lili-record-s-radio/track/current');
|
||||
const data = await response.json();
|
||||
|
||||
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
session_start();
|
||||
|
||||
if (empty($_SESSION['is_admin'])) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$action = $_POST['action'] ?? '';
|
||||
|
||||
if ($action === 'add') {
|
||||
$title = $_POST['title'] ?? '';
|
||||
$artist = $_POST['artist'] ?? '';
|
||||
if ($title && $artist) {
|
||||
$stmt = db()->prepare("INSERT INTO songs (title, artist) VALUES (?, ?)");
|
||||
$stmt->execute([$title, $artist]);
|
||||
}
|
||||
} elseif ($action === 'delete') {
|
||||
$id = $_POST['id'] ?? '';
|
||||
if ($id) {
|
||||
$stmt = db()->prepare("DELETE FROM songs WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
}
|
||||
} elseif ($action === 'toggle_active') {
|
||||
$id = $_POST['id'] ?? '';
|
||||
if ($id) {
|
||||
// First, check the current status
|
||||
$stmt = db()->prepare("SELECT is_active FROM songs WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$current = $stmt->fetchColumn();
|
||||
|
||||
if ($current) {
|
||||
// Deactivate it
|
||||
$stmt = db()->prepare("UPDATE songs SET is_active = 0 WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
} else {
|
||||
// Activate this one and deactivate ALL others
|
||||
$stmt = db()->prepare("UPDATE songs SET is_active = 0");
|
||||
$stmt->execute();
|
||||
$stmt = db()->prepare("UPDATE songs SET is_active = 1 WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: index.php?admin=lili');
|
||||
exit;
|
||||
Loading…
x
Reference in New Issue
Block a user