![]() 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/-72710c21/ |
<?php
header('Content-Type: application/json');
require_once __DIR__ . '/../config/database.php';
// Get pagination parameters
$page = max(1, intval($_GET['page'] ?? 1));
$per_page = intval($_GET['per_page'] ?? 10); // Smaller for VIP samples
$offset = ($page - 1) * $per_page;
try {
$pdo = getDBConnection();
// Get VIP sample tracks ordered by playlist_order
$stmt = $pdo->prepare("
SELECT
mt.id,
mt.title,
mt.audio_url,
mt.video_url,
mt.prompt,
mt.created_at,
mt.playlist_order,
u.name as artist_name,
u.id as user_id,
COALESCE(play_count.count, 0) as play_count,
COALESCE(like_count.count, 0) as like_count
FROM music_tracks mt
JOIN users u ON mt.user_id = u.id
LEFT JOIN (
SELECT track_id, COUNT(*) as count
FROM track_plays
GROUP BY track_id
) play_count ON mt.id = play_count.track_id
LEFT JOIN (
SELECT track_id, COUNT(*) as count
FROM track_likes
GROUP BY track_id
) like_count ON mt.id = like_count.track_id
WHERE mt.status = 'complete'
AND mt.audio_url IS NOT NULL
AND mt.is_vip_sample = 1
ORDER BY mt.playlist_order ASC, mt.created_at DESC
LIMIT ? OFFSET ?
");
$stmt->execute([$per_page, $offset]);
$tracks = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Get total count for pagination
$count_stmt = $pdo->prepare("
SELECT COUNT(*) as total
FROM music_tracks mt
WHERE mt.status = 'complete'
AND mt.audio_url IS NOT NULL
AND mt.is_vip_sample = 1
");
$count_stmt->execute();
$total_count = $count_stmt->fetch(PDO::FETCH_ASSOC)['total'];
// Format the response
$response = [
'success' => true,
'tracks' => $tracks,
'pagination' => [
'page' => $page,
'per_page' => $per_page,
'total' => $total_count,
'total_pages' => ceil($total_count / $per_page)
],
'playlist_info' => [
'name' => 'SoundStudioPro VIP Samples',
'description' => 'Handpicked premium tracks showcasing the best of AI music generation',
'type' => 'vip_sample'
]
];
echo json_encode($response);
} catch (Exception $e) {
http_response_code(500);
echo json_encode([
'success' => false,
'error' => 'Failed to load VIP sample tracks',
'message' => $e->getMessage()
]);
}
?>