Auto commit: 2026-02-20T02:06:27.221Z

This commit is contained in:
Flatlogic Bot 2026-02-20 02:06:27 +00:00
parent 0eea8f587b
commit 63e2317448
2 changed files with 128 additions and 8 deletions

View File

@ -17,9 +17,35 @@ if ($method === 'POST') {
try {
if ($action === 'mark_played') {
$username = trim($_POST['username'] ?? '');
// Get request info before updating
$stmt = $db->prepare("SELECT is_priority, created_at, artist, song FROM song_requests WHERE id = ?");
$stmt->execute([$id]);
$req = $stmt->fetch();
$stmt = $db->prepare("UPDATE song_requests SET status = 'played' WHERE id = ?");
$stmt->execute([$id]);
echo json_encode(['success' => true]);
$bonus = false;
if ($req && $req['is_priority'] == 1 && !empty($username)) {
$createdAt = strtotime($req['created_at']);
$now = time();
$diff = $now - $createdAt;
// Award bonus if handled in less than 5 minutes (300 seconds)
if ($diff <= 300) {
require_once __DIR__ . '/../includes/points_helper.php';
awardLoyaltyPoints($username, 100);
// Announce bonus
$chatMsg = "⚡ ¡BONO DE EFICIENCIA! El DJ **$username** ha atendido un Salto VIP en récord (" . floor($diff/60) . "m " . ($diff%60) . "s). ¡Ha ganado **+100 LP**! 🎧👑";
$db->prepare("INSERT INTO messages (username, message, type) VALUES ('Sistema', ?, 'dj_power')")->execute([$chatMsg]);
$bonus = true;
}
}
echo json_encode(['success' => true, 'bonus_awarded' => $bonus]);
} elseif ($action === 'delete') {
$stmt = $db->prepare("DELETE FROM song_requests WHERE id = ?");
$stmt->execute([$id]);

108
index.php
View File

@ -3716,18 +3716,32 @@ $twitter_link = "https://twitter.com/";
return `
<div class="request-item" style="${isPriority ? 'border-left: 4px solid #facc15; background: rgba(250, 204, 21, 0.05);' : ''}">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px;">
<span class="artist" style="${isPriority ? 'color: #facc15;' : ''}">${isPriority ? '⭐ ' : ''}${req.artist}</span>
<div style="display: flex; align-items: center; gap: 8px;">
<span class="artist" style="${isPriority ? 'color: #facc15;' : ''}">${isPriority ? '⭐ ' : ''}${req.artist}</span>
${isPriority && isGuestDj ? `
<div class="vip-timer" data-start="${req.created_at}" style="font-size: 0.7rem; font-weight: 800; background: rgba(0,0,0,0.3); padding: 2px 8px; border-radius: 20px; color: #facc15; display: inline-flex; align-items: center; gap: 4px; border: 1px solid rgba(255,255,255,0.1);">
<i class="bi bi-stopwatch"></i> <span class="timer-value">--:--</span>
</div>
` : ''}
</div>
<span style="font-size: 0.6rem; opacity: 0.4;">${new Date(req.created_at).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}</span>
</div>
<div class="song">${req.song}</div>
<div style="display: flex; justify-content: space-between; align-items: center; margin-top: 5px;">
<div class="requester"><i class="bi bi-person-fill"></i> ${req.requester}</div>
${isGuestDj && !isPriority ? `
<button onclick="djPrioritizeSong(${req.id})" style="background: #facc15; color: black; border: none; font-size: 0.6rem; padding: 2px 8px; border-radius: 4px; font-weight: 800; cursor: pointer;">
<i class="bi bi-star-fill"></i> PRIORIZAR
</button>
` : ''}
${isPriority ? '<span style="color: #facc15; font-size: 0.6rem; font-weight: 800;"><i class="bi bi-lightning-fill"></i> PRIORIDAD DJ</span>' : ''}
<div style="display: flex; gap: 5px; align-items: center;">
${isGuestDj ? `
<button onclick="djMarkPlayed(${req.id})" style="background: #22c55e; color: white; border: none; font-size: 0.6rem; padding: 2px 8px; border-radius: 4px; font-weight: 800; cursor: pointer;">
<i class="bi bi-play-fill"></i> SONAR
</button>
` : ''}
${isGuestDj && !isPriority ? `
<button onclick="djPrioritizeSong(${req.id})" style="background: #facc15; color: black; border: none; font-size: 0.6rem; padding: 2px 8px; border-radius: 4px; font-weight: 800; cursor: pointer;">
<i class="bi bi-star-fill"></i> PRIORIZAR
</button>
` : ''}
${isPriority ? '<span style="color: #facc15; font-size: 0.6rem; font-weight: 800;"><i class="bi bi-lightning-fill"></i> PRIORIDAD DJ</span>' : ''}
</div>
</div>
</div>
`;
@ -3762,6 +3776,51 @@ $twitter_link = "https://twitter.com/";
}
}
async function djMarkPlayed(requestId) {
const username = document.getElementById('user-name').value.trim();
if (!username) return;
try {
const formData = new FormData();
formData.append('action', 'mark_played');
formData.append('id', requestId);
formData.append('username', username);
const response = await fetch('api/song_requests.php', {
method: 'POST',
body: formData
});
const result = await response.json();
if (result.success) {
if (result.bonus_awarded) {
confetti({
particleCount: 150,
spread: 70,
origin: { y: 0.6 },
colors: ['#22c55e', '#ffffff', '#facc15']
});
// Show quick toast if bonus
const toast = document.createElement('div');
toast.style = 'position: fixed; top: 20px; right: 20px; background: #22c55e; color: white; padding: 15px 25px; border-radius: 10px; z-index: 10000; font-weight: bold; animation: slideIn 0.3s ease-out;';
toast.innerHTML = '⚡ ¡BONO DE RAPIDEZ! +100 LP 🎧';
document.body.appendChild(toast);
setTimeout(() => {
toast.style.animation = 'fadeOut 0.5s ease-in';
setTimeout(() => toast.remove(), 500);
}, 4000);
fetchTopFans();
}
fetchSongRequests();
fetchMessages();
} else {
alert('Error: ' + result.error);
}
} catch (error) {
console.error('Error marking song as played:', error);
}
}
async function djPrioritizeSong(requestId) {
const username = document.getElementById('user-name').value.trim();
if (!username) return;
@ -4564,6 +4623,41 @@ $twitter_link = "https://twitter.com/";
setInterval(fetchLeaderboard, 60000);
setInterval(fetchUpcomingTracks, 30000);
setInterval(fetchActivePerks, 30000);
setInterval(updateVipTimers, 1000);
function updateVipTimers() {
document.querySelectorAll('.vip-timer').forEach(timer => {
const startStr = timer.dataset.start;
if (!startStr) return;
const start = new Date(startStr.replace(' ', 'T')).getTime();
const now = new Date().getTime();
const diff = 300 - Math.floor((now - start) / 1000); // 300 seconds = 5 min
const valueSpan = timer.querySelector('.timer-value');
if (diff <= 0) {
timer.innerHTML = '<i class="bi bi-clock-history"></i> BONO EXPIRADO';
timer.style.color = '#94a3b8';
timer.style.background = 'rgba(0,0,0,0.5)';
} else {
const m = Math.floor(diff / 60);
const s = diff % 60;
valueSpan.innerText = `${m}:${s.toString().padStart(2, '0')}`;
// Color logic
if (diff < 60) {
timer.style.color = '#ff4444';
timer.classList.add('counter-alert');
} else if (diff < 180) {
timer.style.color = '#facc15';
timer.classList.remove('counter-alert');
} else {
timer.style.color = '#22c55e';
timer.classList.remove('counter-alert');
}
}
});
}
// Initial fetch
updateMetadata();