![]() 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
// Fix Task IDs Script
// This script helps identify and fix task IDs that don't match the API.box system
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'config/database.php';
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html>
<head>
<title>Fix Task IDs - SoundStudio Pro</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.success { color: green; }
.error { color: red; }
.warning { color: orange; }
pre { background: #f5f5f5; padding: 10px; border-radius: 5px; margin: 10px 0; }
.test-section { border: 1px solid #ddd; padding: 15px; margin: 15px 0; border-radius: 5px; }
</style>
</head>
<body>
<h1>🔧 Fix Task IDs</h1>
<?php
$API_KEY = '63edba40620216c5aa2c04240ac41dbd';
$API_BASE = 'https://api.api.box';
echo "<div class='test-section'>";
echo "<h2>🔍 Database Analysis</h2>";
$pdo = getDBConnection();
if (!$pdo) {
echo "<p class='error'>❌ Cannot connect to database</p>";
exit;
}
// Get tracks with old task IDs
$stmt = $pdo->prepare("
SELECT id, title, task_id, status, created_at
FROM music_tracks
WHERE task_id IS NOT NULL
AND task_id != ''
ORDER BY created_at DESC
LIMIT 10
");
$stmt->execute();
$tracks = $stmt->fetchAll();
echo "<p><strong>Found " . count($tracks) . " tracks with task IDs:</strong></p>";
foreach ($tracks as $track) {
echo "<div style='border: 1px solid #ccc; padding: 10px; margin: 10px 0; border-radius: 5px;'>";
echo "<h4>Track ID: {$track['id']} - {$track['title']}</h4>";
echo "<p><strong>Task ID:</strong> {$track['task_id']}</p>";
echo "<p><strong>Status:</strong> {$track['status']}</p>";
echo "<p><strong>Created:</strong> {$track['created_at']}</p>";
// Test if this task ID exists in API.box
$testUrl = $API_BASE . '/api/v1/result/' . $track['task_id'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $testUrl);
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);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
echo "<p class='success'>✅ Task ID exists in API.box</p>";
$data = json_decode($response, true);
if (isset($data['data']['lyrics'])) {
echo "<p class='success'>✅ Lyrics found!</p>";
echo "<div style='background: #e8f5e8; padding: 10px; border-radius: 5px;'>";
echo "<strong>Lyrics:</strong><br>";
echo "<pre>" . htmlspecialchars($data['data']['lyrics']) . "</pre>";
echo "</div>";
} else {
echo "<p class='warning'>⚠️ No lyrics found in response</p>";
}
} else {
echo "<p class='error'>❌ Task ID not found in API.box (HTTP $httpCode)</p>";
}
echo "</div>";
}
echo "</div>";
echo "<div class='test-section'>";
echo "<h2>🔍 API.box Task ID Format</h2>";
echo "<p>Let's check what a valid API.box task ID looks like by testing a recent one:</p>";
// Test with a recent task ID from our test
$recentTaskId = 'bfd066779de70845df01526724ad9ba7'; // From our earlier test
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_BASE . '/api/v1/result/' . $recentTaskId);
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);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "<p><strong>Testing recent task ID:</strong> $recentTaskId</p>";
echo "<p><strong>HTTP Code:</strong> $httpCode</p>";
if ($httpCode === 200) {
echo "<p class='success'>✅ Recent task ID works!</p>";
$data = json_decode($response, true);
echo "<pre>" . htmlspecialchars(json_encode($data, JSON_PRETTY_PRINT)) . "</pre>";
} else {
echo "<p class='error'>❌ Recent task ID not found</p>";
}
echo "</div>";
echo "<div class='test-section'>";
echo "<h2>🔍 Solution Options</h2>";
echo "<p><strong>The Problem:</strong> Database has old task IDs that don't exist in API.box</p>";
echo "<p><strong>Possible Solutions:</strong></p>";
echo "<ol>";
echo "<li><strong>Regenerate Task IDs:</strong> Create new API.box requests for existing tracks</li>";
echo "<li><strong>Update Database:</strong> Find the correct task IDs from API.box logs</li>";
echo "<li><strong>Manual Mapping:</strong> Manually map old task IDs to new ones</li>";
echo "</ol>";
echo "<p><strong>Recommended:</strong> Since 'Feel the Beat' has lyrics in API.box, we should find the correct task ID for it.</p>";
echo "</div>";
?>
</body>
</html>