![]() 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/public_html/utils/ |
<?php
require_once 'config/database.php';
$pdo = getDBConnection();
echo "<h2>Regenerating 'Happy Song For Andrew' Track</h2>";
// Find the track with temporary task ID
$stmt = $pdo->prepare("
SELECT * FROM music_tracks
WHERE title = 'Happy Song For Andrew' AND task_id LIKE 'temp_%'
ORDER BY created_at DESC
");
$stmt->execute();
$track = $stmt->fetch();
if (!$track) {
echo "<p style='color: red;'>❌ Track not found or already has proper task ID</p>";
exit;
}
echo "<h3>Found Track: " . htmlspecialchars($track['title']) . " (ID: " . $track['id'] . ")</h3>";
echo "<p>Current Task ID: " . $track['task_id'] . "</p>";
echo "<p>Prompt: " . htmlspecialchars($track['prompt']) . "</p>";
echo "<p>Model: " . $track['model_version'] . "</p>";
// API.Box configuration with correct endpoint and format
$api_key = '63edba40620216c5aa2c04240ac41dbd';
$api_url = 'https://api.api.box/api/v1/generate';
// Prepare the request data in the correct format
$request_data = [
'prompt' => $track['prompt'],
'model' => 'V3_5',
'style' => 'Pop',
'title' => $track['title'],
'customMode' => false,
'instrumental' => false,
'callBackUrl' => 'https://soundstudiopro.com/callback.php'
];
echo "<p>Submitting to API.Box...</p>";
// Make the API request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $api_key,
'Content-Type: application/json',
'User-Agent: SoundStudioPro-Music/2.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_error = curl_error($ch);
curl_close($ch);
echo "<p>API Response Code: $http_code</p>";
if ($curl_error) {
echo "<p style='color: red;'>❌ cURL Error: " . htmlspecialchars($curl_error) . "</p>";
}
if ($http_code === 200) {
$response_data = json_decode($response, true);
if ($response_data && isset($response_data['data']['taskId'])) {
$new_task_id = $response_data['data']['taskId'];
echo "<p style='color: green;'>✅ Success! New Task ID: $new_task_id</p>";
// Update the track with the new task ID
$stmt = $pdo->prepare("
UPDATE music_tracks
SET task_id = ?, status = 'processing', updated_at = CURRENT_TIMESTAMP
WHERE id = ?
");
if ($stmt->execute([$new_task_id, $track['id']])) {
echo "<p style='color: green;'>✅ Track updated with new Task ID!</p>";
echo "<p>Track ID: " . $track['id'] . "</p>";
echo "<p>New Task ID: $new_task_id</p>";
echo "<p>Status: processing</p>";
// Now run the monitor to check if it's already complete
echo "<h3>Checking if track is already complete...</h3>";
// Wait a moment for the callback to process
sleep(2);
// Check if there's already a result file
$result_file = "task_results/{$new_task_id}.json";
if (file_exists($result_file)) {
echo "<p style='color: green;'>✅ Result file already exists!</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($new_task_id, 'complete', $audio_url, null, null, json_encode($result_data), $duration);
echo "<p style='color: green;'>✅ Track is already COMPLETE!</p>";
echo "<p>Audio URL: $audio_url</p>";
echo "<p>Duration: $duration seconds</p>";
}
}
} else {
echo "<p>Track is processing... check back in a few minutes!</p>";
}
} else {
echo "<p style='color: red;'>❌ Failed to update track in database</p>";
}
} else {
echo "<p style='color: red;'>❌ Invalid response format</p>";
echo "<p>Response: " . htmlspecialchars($response) . "</p>";
}
} else {
echo "<p style='color: red;'>❌ API request failed with HTTP $http_code</p>";
echo "<p>Response: " . htmlspecialchars($response) . "</p>";
}
echo "<h3>✅ Regeneration Complete!</h3>";
echo "<p>Refresh your My Library page to see the changes.</p>";
?>