![]() 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/ |
<?php
// Fix tracks missing task_id by looking up in task_results files
require_once 'config/database.php';
$pdo = getDBConnection();
// Find tracks with "Adagio" in title that might be missing task_id
$stmt = $pdo->prepare("SELECT * FROM music_tracks WHERE title LIKE '%Adagio%' LIMIT 10");
$stmt->execute();
$tracks = $stmt->fetchAll();
echo "<h1>Fix Missing Task IDs for Adagio Tracks</h1>";
foreach ($tracks as $track) {
echo "<h2>Track: {$track['title']} (ID: {$track['id']})</h2>";
echo "<p>Current task_id: " . ($track['task_id'] ?: 'NULL') . "</p>";
echo "<p>Audio URL: " . htmlspecialchars($track['audio_url'] ?: 'NULL') . "</p>";
// If track has no task_id, try to find it in task_results
if (empty($track['task_id'])) {
echo "<p style='color: orange;'>⚠️ Track is missing task_id!</p>";
// Search task_results directory for files containing this track's title
$taskResultsDir = __DIR__ . '/task_results/';
$foundTaskId = null;
if (is_dir($taskResultsDir)) {
$files = glob($taskResultsDir . '*.json');
foreach ($files as $file) {
$content = file_get_contents($file);
$data = json_decode($content, true);
if ($data && isset($data['data']['data'])) {
foreach ($data['data']['data'] as $item) {
if (isset($item['title']) && stripos($item['title'], 'Adagio') !== false) {
$taskId = $data['data']['task_id'] ?? basename($file, '.json');
$foundTaskId = $taskId;
echo "<p style='color: green;'>✅ Found task_id in task_results: {$taskId}</p>";
break 2;
}
}
}
}
}
if ($foundTaskId) {
// Update the track with the found task_id
$updateStmt = $pdo->prepare("UPDATE music_tracks SET task_id = ? WHERE id = ?");
if ($updateStmt->execute([$foundTaskId, $track['id']])) {
echo "<p style='color: green; font-weight: bold;'>✅ Updated track with task_id: {$foundTaskId}</p>";
} else {
echo "<p style='color: red;'>❌ Failed to update track</p>";
}
} else {
echo "<p style='color: red;'>❌ Could not find task_id in task_results files</p>";
}
} else {
echo "<p style='color: green;'>✅ Track has task_id: {$track['task_id']}</p>";
}
echo "<hr>";
}
// Also check for the specific task_id from the task_results file
$knownTaskId = '9bf0fc77de4c62243425086e8ff1763e';
$stmt = $pdo->prepare("SELECT * FROM music_tracks WHERE task_id = ? OR (title LIKE '%Adagio%' AND task_id IS NULL)");
$stmt->execute([$knownTaskId]);
$matchingTracks = $stmt->fetchAll();
if (!empty($matchingTracks)) {
echo "<h2>Found Tracks Matching Known Task ID</h2>";
foreach ($matchingTracks as $track) {
echo "<p>Track ID: {$track['id']}, Title: {$track['title']}, Task ID: " . ($track['task_id'] ?: 'NULL') . "</p>";
if (empty($track['task_id'])) {
$updateStmt = $pdo->prepare("UPDATE music_tracks SET task_id = ? WHERE id = ?");
if ($updateStmt->execute([$knownTaskId, $track['id']])) {
echo "<p style='color: green;'>✅ Updated track {$track['id']} with task_id {$knownTaskId}</p>";
}
}
}
}
?>