![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/public_html/api/ |
<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
// Handle preflight requests
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
exit(0);
}
require_once '../config/database.php';
try {
$pdo = getDBConnection();
// Check if player_messages table exists, if not create it
$stmt = $pdo->query("SHOW TABLES LIKE 'player_messages'");
if ($stmt->rowCount() === 0) {
// Create the table
$pdo->exec("
CREATE TABLE player_messages (
id INT AUTO_INCREMENT PRIMARY KEY,
text TEXT NOT NULL,
type VARCHAR(20) DEFAULT 'heart',
is_active BOOLEAN DEFAULT TRUE,
priority INT DEFAULT 0,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)
");
// Insert demo messages
$demoMessages = [
['You Are Amazing!! Keep making beautiful music!', 'heart'],
['Your music touches my soul! ❤️', 'star'],
['This track is fire! 🔥', 'fire'],
['Pure musical genius! 🎵', 'music'],
['You\'re creating magic! ✨', 'rainbow'],
['Love this vibe! Keep it up!', 'heart'],
['Your talent is incredible! 🌟', 'star'],
['This is what music should be! 🎶', 'music']
];
$stmt = $pdo->prepare("INSERT INTO player_messages (text, type) VALUES (?, ?)");
foreach ($demoMessages as $message) {
$stmt->execute($message);
}
}
// Fetch active messages ordered by priority and creation date
$stmt = $pdo->prepare("
SELECT id, text, type, priority
FROM player_messages
WHERE is_active = TRUE
ORDER BY priority DESC, created_at ASC
");
$stmt->execute();
$messages = [];
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$messages[] = [
'id' => $row['id'],
'text' => $row['text'],
'type' => $row['type'],
'priority' => $row['priority']
];
}
echo json_encode([
'success' => true,
'messages' => $messages,
'count' => count($messages)
]);
} catch (Exception $e) {
echo json_encode([
'success' => false,
'error' => $e->getMessage(),
'messages' => []
]);
}
?>