diff --git a/api/chat.php b/api/chat.php index 624c1da..18e88d9 100644 --- a/api/chat.php +++ b/api/chat.php @@ -46,12 +46,13 @@ if ($method === 'GET') { "); $topRequester = $topStmt->fetchColumn(); - $stmt = db()->prepare("SELECT m.*, f.points, f.is_fan_of_month FROM messages m LEFT JOIN fans f ON m.username = f.name ORDER BY m.created_at DESC LIMIT 50"); + $stmt = db()->prepare("SELECT m.*, f.points, f.loyalty_points, f.is_fan_of_month FROM messages m LEFT JOIN fans f ON m.username = f.name ORDER BY m.created_at DESC LIMIT 50"); $stmt->execute(); $messages = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($messages as &$msg) { $points = $msg['points'] ?? 0; + $loyalty = $msg['loyalty_points'] ?? 0; $msg['level_color'] = '#94a3b8'; $msg['level_emoji'] = ''; @@ -62,6 +63,10 @@ if ($method === 'GET') { $msg['level_color'] = '#facc15'; $msg['level_emoji'] = '👑'; $msg['is_top_listener'] = true; + } elseif ($loyalty > 0) { + $msg['level_color'] = '#00e676'; // Neon Green for Loyalty + $msg['level_emoji'] = $loyalty >= 500 ? '🎖️' : '🏅'; + $msg['is_loyal'] = true; } elseif ($msg['is_fan_of_month']) { $msg['level_color'] = '#facc15'; } elseif ($points >= 2500) { diff --git a/api/get_online_users.php b/api/get_online_users.php index 613a75c..28b199b 100644 --- a/api/get_online_users.php +++ b/api/get_online_users.php @@ -12,6 +12,7 @@ $stmt = $db->prepare(" v.country_code, v.last_activity, f.points, + f.loyalty_points, f.is_fan_of_month FROM visitor_logs v LEFT JOIN fans f ON v.username = f.name diff --git a/api/thank_tip.php b/api/thank_tip.php index 69620f7..03d91c0 100644 --- a/api/thank_tip.php +++ b/api/thank_tip.php @@ -15,6 +15,16 @@ try { $stmt = $pdo->prepare("UPDATE dj_tips SET thanked_at = NOW() WHERE id = ?"); $stmt->execute([$tipId]); + // Award loyalty points to the sender + $stmt = $pdo->prepare("SELECT sender_name FROM dj_tips WHERE id = ?"); + $stmt->execute([$tipId]); + $sender = $stmt->fetchColumn(); + + if ($sender) { + $stmt = $pdo->prepare("UPDATE fans SET loyalty_points = loyalty_points + 50 WHERE name = ?"); + $stmt->execute([$sender]); + } + echo json_encode([ "success" => true, "message" => "¡Has agradecido la donación!" diff --git a/index.php b/index.php index 8f209a4..f768bcf 100644 --- a/index.php +++ b/index.php @@ -2603,12 +2603,13 @@ $twitter_link = "https://twitter.com/"; const isVeryActive = (new Date() - new Date(user.last_activity)) < 60000; const flagUrl = user.country_code ? `https://flagcdn.com/w20/${user.country_code.toLowerCase()}.png` : null; const isTopFan = user.points > 10 || user.is_fan_of_month == 1; - const userColor = getUserColor(user.username); + const isLoyal = user.loyalty_points > 0; + const userColor = isLoyal ? "#00e676" : getUserColor(user.username); return ` -