![]() 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
require_once 'config/database.php';
$pdo = getDBConnection();
echo "<h2>Fixing 'Happy Song For Andrew' Track</h2>";
// Find the track by title
$stmt = $pdo->prepare("
SELECT * FROM music_tracks
WHERE title LIKE '%Happy Song For Andrew%' OR title LIKE '%andrew%'
ORDER BY created_at DESC
");
$stmt->execute();
$tracks = $stmt->fetchAll();
if (empty($tracks)) {
echo "<p style='color: red;'>❌ No tracks found with 'Happy Song For Andrew' or 'andrew' in the title</p>";
// Let's check all recent tracks
echo "<h3>Recent Tracks:</h3>";
$stmt = $pdo->query("
SELECT id, title, status, task_id, created_at
FROM music_tracks
ORDER BY created_at DESC
LIMIT 10
");
$recent_tracks = $stmt->fetchAll();
foreach ($recent_tracks as $track) {
echo "<p>ID: {$track['id']} - Title: " . htmlspecialchars($track['title']) . " - Status: {$track['status']} - Task: " . substr($track['task_id'], 0, 20) . "...</p>";
}
} else {
foreach ($tracks as $track) {
echo "<h3>Found Track: " . htmlspecialchars($track['title']) . " (ID: " . $track['id'] . ")</h3>";
echo "<p>Current Status: " . $track['status'] . "</p>";
echo "<p>Task ID: " . $track['task_id'] . "</p>";
echo "<p>Created: " . $track['created_at'] . "</p>";
// Check if there's a result file for this task
$result_file = "task_results/{$track['task_id']}.json";
if (file_exists($result_file)) {
echo "<p style='color: green;'>✅ Found result file!</p>";
$result_data = json_decode(file_get_contents($result_file), true);
if ($result_data && isset($result_data['data']['callbackType']) && $result_data['data']['callbackType'] === 'complete') {
$audio_data = $result_data['data']['data'][0] ?? null;
if ($audio_data && isset($audio_data['audio_url'])) {
$audio_url = $audio_data['audio_url'];
$duration = $audio_data['duration'] ?? 30;
// Update the track to complete
updateMusicTrack($track['task_id'], 'complete', $audio_url, null, null, json_encode($result_data), $duration);
echo "<p style='color: green;'>✅ FIXED: Track " . $track['id'] . " set to COMPLETE!</p>";
echo "<p>Audio URL: $audio_url</p>";
echo "<p>Duration: $duration seconds</p>";
// Show metadata
if (isset($audio_data['title'])) {
echo "<p>Generated Title: " . htmlspecialchars($audio_data['title']) . "</p>";
}
if (isset($audio_data['tags'])) {
echo "<p>Tags: " . htmlspecialchars($audio_data['tags']) . "</p>";
}
if (isset($audio_data['model_name'])) {
echo "<p>Model: " . htmlspecialchars($audio_data['model_name']) . "</p>";
}
}
} else {
echo "<p style='color: orange;'>⚠️ Result file exists but not complete</p>";
echo "<p>Callback Type: " . ($result_data['data']['callbackType'] ?? 'unknown') . "</p>";
}
} else {
echo "<p style='color: red;'>❌ No result file found for task: " . $track['task_id'] . "</p>";
// Check if this task was actually sent to API.Box
$api_key = '63edba40620216c5aa2c04240ac41dbd';
$task_id = $track['task_id'];
// Try to check if this task exists in API.Box
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.api.box/api/v1/status/$task_id");
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $api_key,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "<p>API.Box check: HTTP $http_code</p>";
echo "<p>Response: " . htmlspecialchars($response) . "</p>";
// If the task doesn't exist in API.Box, mark it as failed
if ($http_code === 404) {
updateMusicTrack($track['task_id'], 'failed');
echo "<p style='color: red;'>❌ Task not found in API.Box - marked as FAILED</p>";
}
}
echo "<hr>";
}
}
echo "<h3>✅ Fix Complete!</h3>";
echo "<p>Refresh your My Library page to see the changes.</p>";
?>