![]() 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>Force Updating Tracks</h2>";
// Get the specific tracks that should be complete
$stmt = $pdo->query("
SELECT * FROM music_tracks
WHERE title IN ('fun fun', 'dom') AND status = 'processing'
ORDER BY created_at DESC
");
$tracks = $stmt->fetchAll();
foreach ($tracks as $track) {
echo "<h3>Checking track: " . htmlspecialchars($track['title']) . " (ID: " . $track['id'] . ")</h3>";
echo "<p>Current status: " . $track['status'] . "</p>";
echo "<p>Task ID: " . $track['task_id'] . "</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;
// Force update the track to complete
$stmt = $pdo->prepare("
UPDATE music_tracks
SET status = 'complete', audio_url = ?, duration = ?, metadata = ?
WHERE id = ?
");
$stmt->execute([$audio_url, $duration, json_encode($result_data), $track['id']]);
echo "<p style='color: green;'>✅ FORCED UPDATE: Track " . $track['id'] . " set to COMPLETE!</p>";
echo "<p>Audio URL: $audio_url</p>";
echo "<p>Duration: $duration seconds</p>";
}
} else {
echo "<p style='color: orange;'>⚠️ Result file exists but not complete</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) {
$stmt = $pdo->prepare("UPDATE music_tracks SET status = 'failed' WHERE id = ?");
$stmt->execute([$track['id']]);
echo "<p style='color: red;'>❌ Task not found in API.Box - marked as FAILED</p>";
}
}
}
// Also check for any tracks that might have been missed
echo "<h3>Checking All Processing Tracks</h3>";
$stmt = $pdo->query("
SELECT * FROM music_tracks
WHERE status = 'processing'
ORDER BY created_at DESC
");
$all_processing = $stmt->fetchAll();
echo "<p>Found " . count($all_processing) . " tracks still processing</p>";
foreach ($all_processing as $track) {
echo "<p>Track " . $track['id'] . ": " . htmlspecialchars($track['title']) . " (Task: " . substr($track['task_id'], 0, 20) . "...)</p>";
}
echo "<h3>✅ Force Update Complete!</h3>";
echo "<p>Refresh your My Library page to see the changes.</p>";
?>