![]() 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
session_start();
require_once 'config/database.php';
$task_id = 'b247fe61e027ed4983d5ff0f47afe8e0';
echo "<h1>📡 TRACK MONITORING</h1>";
echo "<p>Monitoring track: $task_id</p>";
$pdo = getDBConnection();
// Check local database
$stmt = $pdo->prepare("SELECT * FROM music_tracks WHERE task_id = ?");
$stmt->execute([$task_id]);
$track = $stmt->fetch();
if ($track) {
echo "<h2>📊 Local Database Status</h2>";
echo "<div style='border: 1px solid #ccc; padding: 15px; margin: 10px 0; border-radius: 5px;'>";
echo "<p><strong>Track ID:</strong> " . $track['id'] . "</p>";
echo "<p><strong>Title:</strong> " . htmlspecialchars($track['title']) . "</p>";
echo "<p><strong>Status:</strong> <span style='color: " . ($track['status'] === 'complete' ? 'green' : ($track['status'] === 'failed' ? 'red' : 'orange')) . "; font-weight: bold;'>" . $track['status'] . "</span></p>";
echo "<p><strong>Audio URL:</strong> " . ($track['audio_url'] ?: 'None') . "</p>";
echo "<p><strong>Created:</strong> " . $track['created_at'] . "</p>";
echo "<p><strong>Updated:</strong> " . $track['updated_at'] . "</p>";
echo "</div>";
// If still processing, check API.Box
if ($track['status'] === 'processing') {
echo "<h2>🔍 Checking API.Box Status</h2>";
$api_key = '63edba40620216c5aa2c04240ac41dbd';
$api_url = "https://api.api.box/api/v1/result/$task_id";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $api_key,
'Content-Type: application/json',
'User-Agent: MusicStudio-Pro/1.0'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "<p><strong>API.Box HTTP Code:</strong> $http_code</p>";
if ($http_code === 200) {
$api_data = json_decode($response, true);
if ($api_data && isset($api_data['data']['status'])) {
$api_status = $api_data['data']['status'];
echo "<p><strong>API.Box Status:</strong> <span style='color: " . ($api_status === 'complete' ? 'green' : ($api_status === 'failed' ? 'red' : 'orange')) . "; font-weight: bold;'>$api_status</span></p>";
if ($api_status === 'complete' && isset($api_data['data']['audioUrl'])) {
echo "<p style='color: green;'>✅ Track is complete! Audio URL: " . $api_data['data']['audioUrl'] . "</p>";
// Update local database
$stmt = $pdo->prepare("UPDATE music_tracks SET status = 'complete', audio_url = ? WHERE task_id = ?");
if ($stmt->execute([$api_data['data']['audioUrl'], $task_id])) {
echo "<p style='color: green;'>✅ Local database updated!</p>";
}
} elseif ($api_status === 'failed') {
echo "<p style='color: red;'>❌ Track failed in API.Box</p>";
} else {
echo "<p style='color: orange;'>⏳ Still processing...</p>";
}
} else {
echo "<p style='color: orange;'>⏳ Still processing or unknown status</p>";
}
} else {
echo "<p style='color: orange;'>⏳ Still processing (HTTP $http_code)</p>";
}
}
// If complete, show audio player
if ($track['status'] === 'complete' && $track['audio_url']) {
echo "<h2>🎵 Audio Player</h2>";
echo "<div style='border: 1px solid #ddd; padding: 20px; margin: 20px 0; border-radius: 10px; background: var(--bg-card);'>";
echo "<h3>🎵 Your Generated Music</h3>";
echo "<p><strong>Track:</strong> " . htmlspecialchars($track['title']) . "</p>";
echo "<audio controls style='width: 100%; max-width: 500px; margin: 15px 0;'>";
echo "<source src='" . htmlspecialchars($track['audio_url']) . "' type='audio/mpeg'>";
echo "<source src='" . htmlspecialchars($track['audio_url']) . "' type='audio/mp4'>";
echo "Your browser does not support the audio element.";
echo "</audio>";
echo "<div style='margin-top: 15px;'>";
echo "<a href='" . htmlspecialchars($track['audio_url']) . "' download='" . htmlspecialchars($track['title']) . ".mp3' ";
echo "style='background: var(--bg-card); color: var(--text-primary); padding: 10px 20px; text-decoration: none; border-radius: 5px; margin-right: 10px;'>";
echo "⬇️ Download MP3</a>";
echo "<a href='/library.php' style='background: var(--text-accent); color: var(--text-primary); padding: 10px 20px; text-decoration: none; border-radius: 5px;'>";
echo "📚 View in Library</a>";
echo "</div>";
echo "</div>";
}
} else {
echo "<p style='color: red;'>❌ Track not found in database</p>";
}
echo "<h2>🔄 Quick Actions</h2>";
echo "<div style='text-align: center; margin-top: 20px;'>";
echo "<a href='javascript:location.reload()' style='background: var(--text-accent); color: var(--text-primary); padding: 10px 20px; text-decoration: none; border-radius: 5px; margin: 0 10px;'>";
echo "🔄 Refresh Status</a>";
echo "<a href='/library.php' style='background: var(--bg-card); color: var(--text-primary); padding: 10px 20px; text-decoration: none; border-radius: 5px; margin: 0 10px;'>";
echo "📚 View Library</a>";
echo "<a href='/create_music.php' style='background: var(--text-accent); color: var(--text-primary); padding: 10px 20px; text-decoration: none; border-radius: 5px; margin: 0 10px;'>";
echo "🎵 Create New Track</a>";
echo "</div>";
echo "<script>";
echo "setTimeout(function() { location.reload(); }, 30000);"; // Auto-refresh every 30 seconds
echo "</script>";
?>