![]() 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/.cursor-server/data/User/History/-2adbbf4e/ |
<?php
// Test community tracks API
header('Content-Type: application/json');
require_once 'config/database.php';
echo "<h1>Community Tracks API Test</h1>";
try {
$pdo = getDBConnection();
// Test the exact query used in the API
$stmt = $pdo->prepare("
SELECT
mt.id,
mt.title,
mt.audio_url,
mt.created_at,
u.name as artist_name,
u.id as user_id
FROM music_tracks mt
LEFT JOIN users u ON mt.user_id = u.id
WHERE mt.status = 'complete'
AND mt.audio_url IS NOT NULL
AND mt.audio_url != ''
ORDER BY mt.created_at DESC
LIMIT 50
");
$stmt->execute();
$tracks = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo "<h2>API Response:</h2>";
echo "<pre>" . json_encode([
'success' => true,
'tracks' => $tracks,
'count' => count($tracks)
], JSON_PRETTY_PRINT) . "</pre>";
echo "<h2>Track Details:</h2>";
foreach ($tracks as $index => $track) {
echo "<div style='border: 1px solid #ccc; padding: 10px; margin: 10px 0;'>";
echo "<strong>Track " . ($index + 1) . ":</strong><br>";
echo "<strong>ID:</strong> " . $track['id'] . "<br>";
echo "<strong>Title:</strong> " . htmlspecialchars($track['title']) . "<br>";
echo "<strong>Artist:</strong> " . htmlspecialchars($track['artist_name'] ?? 'Unknown') . "<br>";
echo "<strong>Audio URL:</strong> " . htmlspecialchars($track['audio_url']) . "<br>";
echo "<strong>Created:</strong> " . $track['created_at'] . "<br>";
echo "</div>";
}
// Also test the raw API endpoint
echo "<h2>Raw API Test:</h2>";
echo "<p><a href='/api/get_community_tracks.php' target='_blank'>Click here to test raw API</a></p>";
} catch (Exception $e) {
echo "<p>❌ Error: " . htmlspecialchars($e->getMessage()) . "</p>";
}
?>