![]() 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/.cursor-server/data/User/History/-163ada05/ |
<?php
// Regenerate Correct Task IDs Script
// Creates new API.box requests for existing tracks to get the correct task IDs
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('max_execution_time', 0);
require_once 'config/database.php';
// Logging
$logFile = 'regenerate_task_ids_log.txt';
function logMessage($message) {
global $logFile;
$timestamp = date('Y-m-d H:i:s');
$logEntry = "[$timestamp] $message\n";
file_put_contents($logFile, $logEntry, FILE_APPEND | LOCK_EX);
echo $logEntry;
}
// Function to create new API.box request
function createNewAPIBoxRequest($trackId, $title, $prompt) {
$apiUrl = 'https://api.api.box/api/v1/generate';
$requestData = [
'prompt' => $prompt,
'model' => 'V3_5',
'style' => 'Pop',
'title' => $title,
'customMode' => 'false',
'instrumental' => 'false',
'duration' => 30,
'callBackUrl' => 'https://soundstudiopro.com/callback.php'
];
$headers = [
'Content-Type: application/json',
'Authorization: Bearer 63edba40620216c5aa2c04240ac41dbd',
'User-Agent: SoundStudioPro/1.0'
];
$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' => implode("\r\n", $headers),
'content' => json_encode($requestData),
'timeout' => 60
]
]);
$response = file_get_contents($apiUrl, false, $context);
if ($response === false) {
return null;
}
$responseData = json_decode($response, true);
if (isset($responseData['code']) && $responseData['code'] === 200) {
if (isset($responseData['data']['taskId'])) {
return $responseData['data']['taskId'];
}
}
return null;
}
// Function to update track with new task ID
function updateTrackTaskId($trackId, $newTaskId) {
$pdo = getDBConnection();
if (!$pdo) return false;
try {
$stmt = $pdo->prepare("
UPDATE music_tracks
SET task_id = ?, updated_at = CURRENT_TIMESTAMP
WHERE id = ?
");
return $stmt->execute([$newTaskId, $trackId]);
} catch (Exception $e) {
logMessage("Database error: " . $e->getMessage());
return false;
}
}
// Main execution
logMessage("=== REGENERATING CORRECT TASK IDs ===");
$pdo = getDBConnection();
if (!$pdo) {
logMessage("ERROR: Cannot connect to database");
exit(1);
}
// Get tracks that need new task IDs (focus on "Feel the Beat" first)
try {
$stmt = $pdo->prepare("
SELECT id, title, prompt, task_id, status
FROM music_tracks
WHERE title LIKE '%Feel the Beat%'
OR title LIKE '%Dancing in Circles%'
OR title LIKE '%The Law Revolves%'
ORDER BY created_at DESC
LIMIT 5
");
$stmt->execute();
$tracksToFix = $stmt->fetchAll();
$totalTracks = count($tracksToFix);
logMessage("Found $totalTracks tracks to fix");
if ($totalTracks === 0) {
logMessage("No tracks found to fix!");
exit(0);
}
$successCount = 0;
$errorCount = 0;
foreach ($tracksToFix as $track) {
logMessage("Processing track {$track['id']}: {$track['title']}");
logMessage("Old task ID: {$track['task_id']}");
// Create new API.box request
$newTaskId = createNewAPIBoxRequest($track['id'], $track['title'], $track['prompt']);
if ($newTaskId) {
logMessage("✅ Generated new task ID: $newTaskId");
// Update track with new task ID
if (updateTrackTaskId($track['id'], $newTaskId)) {
$successCount++;
logMessage("✅ Updated track {$track['id']} with new task ID");
} else {
$errorCount++;
logMessage("❌ Failed to update track {$track['id']}");
}
} else {
$errorCount++;
logMessage("❌ Failed to generate new task ID for track {$track['id']}");
}
// Delay between requests
sleep(3);
}
// Summary
logMessage("=== COMPLETE ===");
logMessage("Total: $totalTracks, Success: $successCount, Errors: $errorCount");
} catch (Exception $e) {
logMessage("ERROR: " . $e->getMessage());
exit(1);
}
logMessage("=== SCRIPT COMPLETED ===");
?>