![]() 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/private_html/utils/ |
<?php
// Debug script to check all tracks and their status
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'config/database.php';
echo "<h1>🔍 SoundStudioPro Track Debug</h1>";
$pdo = getDBConnection();
if (!$pdo) {
echo "<p style='color: red;'>❌ Database connection failed</p>";
exit;
}
// Get all tracks
$stmt = $pdo->prepare("
SELECT id, task_id, title, prompt, status, audio_url, created_at, updated_at
FROM music_tracks
ORDER BY created_at DESC
");
$stmt->execute();
$tracks = $stmt->fetchAll();
echo "<h2>📊 All Tracks in Database</h2>";
echo "<table border='1' style='border-collapse: collapse; margin: 20px 0; width: 100%;'>";
echo "<tr style='background: #f0f0f0;'>";
echo "<th>ID</th><th>Task ID</th><th>Title</th><th>Status</th><th>Audio URL</th><th>Created</th><th>Updated</th><th>Actions</th>";
echo "</tr>";
foreach ($tracks as $track) {
$statusColor = $track['status'] === 'complete' ? 'green' : ($track['status'] === 'failed' ? 'red' : 'orange');
$audioUrl = $track['audio_url'] ? '✅ Has URL' : '❌ No URL';
echo "<tr>";
echo "<td>{$track['id']}</td>";
echo "<td style='font-family: monospace;'>{$track['task_id']}</td>";
echo "<td>{$track['title']}</td>";
echo "<td style='color: $statusColor;'>{$track['status']}</td>";
echo "<td>$audioUrl</td>";
echo "<td>{$track['created_at']}</td>";
echo "<td>{$track['updated_at']}</td>";
echo "<td>";
echo "<a href='/check_track_status.php?track_id={$track['id']}' style='color: #667eea; margin-right: 10px;'>🔍 Check</a>";
if ($track['status'] === 'processing') {
echo "<button onclick='forceComplete({$track['id']})' style='background: #48bb78; color: white; border: none; padding: 5px 10px; border-radius: 3px; cursor: pointer;'>✅ Force Complete</button>";
}
echo "</td>";
echo "</tr>";
}
echo "</table>";
// Check for tracks with "happy" in title
echo "<h2>🎵 Tracks with 'happy' in title</h2>";
$stmt = $pdo->prepare("
SELECT id, task_id, title, prompt, status, audio_url, created_at
FROM music_tracks
WHERE title LIKE '%happy%'
ORDER BY created_at DESC
");
$stmt->execute();
$happyTracks = $stmt->fetchAll();
if ($happyTracks) {
echo "<table border='1' style='border-collapse: collapse; margin: 20px 0; width: 100%;'>";
echo "<tr style='background: #f0f0f0;'>";
echo "<th>ID</th><th>Task ID</th><th>Title</th><th>Status</th><th>Audio URL</th><th>Created</th><th>Actions</th>";
echo "</tr>";
foreach ($happyTracks as $track) {
$statusColor = $track['status'] === 'complete' ? 'green' : ($track['status'] === 'failed' ? 'red' : 'orange');
$audioUrl = $track['audio_url'] ? '✅ Has URL' : '❌ No URL';
echo "<tr>";
echo "<td>{$track['id']}</td>";
echo "<td style='font-family: monospace;'>{$track['task_id']}</td>";
echo "<td>{$track['title']}</td>";
echo "<td style='color: $statusColor;'>{$track['status']}</td>";
echo "<td>$audioUrl</td>";
echo "<td>{$track['created_at']}</td>";
echo "<td>";
echo "<a href='/check_track_status.php?track_id={$track['id']}' style='color: #667eea; margin-right: 10px;'>🔍 Check API</a>";
echo "<button onclick='checkApiBox(\"{$track['task_id']}\")' style='background: #667eea; color: white; border: none; padding: 5px 10px; border-radius: 3px; cursor: pointer;'>🌐 API.Box</button>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "<p>No tracks found with 'happy' in the title.</p>";
}
// Summary statistics
echo "<h2>📈 Summary Statistics</h2>";
$stmt = $pdo->prepare("
SELECT
COUNT(*) as total,
SUM(CASE WHEN status = 'complete' THEN 1 ELSE 0 END) as completed,
SUM(CASE WHEN status = 'processing' THEN 1 ELSE 0 END) as processing,
SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) as failed
FROM music_tracks
");
$stmt->execute();
$stats = $stmt->fetch();
echo "<div style='display: flex; gap: 20px; margin: 20px 0;'>";
echo "<div style='background: #48bb78; color: white; padding: 20px; border-radius: 10px; text-align: center;'>";
echo "<h3>Total</h3><p style='font-size: 2rem;'>{$stats['total']}</p>";
echo "</div>";
echo "<div style='background: #48bb78; color: white; padding: 20px; border-radius: 10px; text-align: center;'>";
echo "<h3>Completed</h3><p style='font-size: 2rem;'>{$stats['completed']}</p>";
echo "</div>";
echo "<div style='background: #ed8936; color: white; padding: 20px; border-radius: 10px; text-align: center;'>";
echo "<h3>Processing</h3><p style='font-size: 2rem;'>{$stats['processing']}</p>";
echo "</div>";
echo "<div style='background: #e53e3e; color: white; padding: 20px; border-radius: 10px; text-align: center;'>";
echo "<h3>Failed</h3><p style='font-size: 2rem;'>{$stats['failed']}</p>";
echo "</div>";
echo "</div>";
echo "<h3>🔗 Quick Links</h3>";
echo "<p><a href='/library.php' style='color: #667eea;'>📚 View Library</a> | ";
echo "<a href='/api.php' style='color: #667eea;'>🔧 API Endpoint</a> | ";
echo "<a href='/callback.php' style='color: #667eea;'>🔄 Callback</a></p>";
?>
<script>
async function forceComplete(trackId) {
if (confirm('Force mark this track as complete?')) {
try {
const response = await fetch('/force_complete.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
track_id: trackId,
audio_url: 'https://example.com/placeholder_audio.mp3'
})
});
const data = await response.json();
if (data.success) {
alert('Track marked as complete!');
location.reload();
} else {
alert('Failed: ' + data.error);
}
} catch (error) {
alert('Error: ' + error.message);
}
}
}
async function checkApiBox(taskId) {
const apiKey = '63edba40620216c5aa2c04240ac41dbd';
const apiUrl = `https://api.api.box/api/v1/status/${taskId}`;
try {
const response = await fetch(apiUrl, {
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
});
const data = await response.json();
alert(`API.Box Status for ${taskId}:\n\n${JSON.stringify(data, null, 2)}`);
} catch (error) {
alert('Error checking API.Box: ' + error.message);
}
}
</script>