![]() 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/ |
<?php
/**
* Simple Direct Check for Track Variations
* Directly queries the database to see what's wrong
*/
require_once 'config/database.php';
$pdo = getDBConnection();
// Find Jabëla's user ID
$stmt = $pdo->prepare("SELECT id, name FROM users WHERE name LIKE '%Jab%' OR name LIKE '%jab%' OR id = 22 LIMIT 1");
$stmt->execute();
$artist = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$artist) {
die("Could not find Jabëla. Trying with artist_id=22...");
}
$artist_id = $artist['id'] ?? 22;
echo "<h2>Direct Database Check for Jabëla's Tracks</h2>";
echo "<p><strong>Artist:</strong> " . ($artist['name'] ?? 'ID 22') . " (ID: {$artist_id})</p>";
echo "<hr>";
// Get the two "Elle débarque" tracks
$stmt = $pdo->prepare("
SELECT
mt.id,
mt.task_id,
mt.title,
mt.duration,
mt.status,
mt.created_at,
mt.variations_count as stored_count,
(SELECT COUNT(*) FROM audio_variations WHERE track_id = mt.id) as actual_count
FROM music_tracks mt
WHERE mt.user_id = ?
AND mt.title LIKE '%Elle débarque%'
ORDER BY mt.created_at DESC
LIMIT 10
");
$stmt->execute([$artist_id]);
$tracks = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (empty($tracks)) {
// Try without title filter
$stmt = $pdo->prepare("
SELECT
mt.id,
mt.task_id,
mt.title,
mt.duration,
mt.status,
mt.created_at,
mt.variations_count as stored_count,
(SELECT COUNT(*) FROM audio_variations WHERE track_id = mt.id) as actual_count
FROM music_tracks mt
WHERE mt.user_id = ?
ORDER BY mt.created_at DESC
LIMIT 10
");
$stmt->execute([$artist_id]);
$tracks = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
echo "<h3>Found " . count($tracks) . " track(s):</h3>";
foreach ($tracks as $track) {
echo "<div style='border: 2px solid #ccc; padding: 15px; margin: 10px 0;'>";
echo "<h4>Track ID: {$track['id']}</h4>";
echo "<p><strong>Title:</strong> " . ($track['title'] ?: 'NULL') . "</p>";
echo "<p><strong>Task ID:</strong> {$track['task_id']}</p>";
echo "<p><strong>Duration:</strong> {$track['duration']}</p>";
echo "<p><strong>Status:</strong> {$track['status']}</p>";
echo "<p><strong>Created:</strong> {$track['created_at']}</p>";
echo "<p><strong>Stored variations_count:</strong> {$track['stored_count']}</p>";
echo "<p><strong>Actual variations in DB:</strong> {$track['actual_count']}</p>";
// Check what UI query would return
$stmt2 = $pdo->prepare("
SELECT COALESCE(COUNT(*), 0) as ui_count
FROM audio_variations
WHERE track_id = ?
");
$stmt2->execute([$track['id']]);
$ui_result = $stmt2->fetch(PDO::FETCH_ASSOC);
$ui_count = $ui_result['ui_count'] ?? 0;
echo "<p><strong>UI variation_count (what button checks):</strong> <span style='font-size: 20px; color: " . ($ui_count > 0 ? 'green' : 'red') . ";'><strong>{$ui_count}</strong></span></p>";
echo "<p><strong>Button will show:</strong> " . ($ui_count > 0 ? "✅ YES" : "❌ NO") . "</p>";
// Get actual variations
$stmt3 = $pdo->prepare("
SELECT
variation_index,
audio_url,
source_audio_url,
stream_audio_url,
duration,
title
FROM audio_variations
WHERE track_id = ?
ORDER BY variation_index ASC
");
$stmt3->execute([$track['id']]);
$variations = $stmt3->fetchAll(PDO::FETCH_ASSOC);
if (empty($variations)) {
echo "<p style='color: red; font-weight: bold;'>❌ NO VARIATIONS IN DATABASE!</p>";
// Check if task_results exists
$taskResultsFile = __DIR__ . "/task_results/{$track['task_id']}.json";
if (file_exists($taskResultsFile)) {
echo "<p style='color: green;'>✅ Found task_results JSON file</p>";
$jsonContent = file_get_contents($taskResultsFile);
$callbackData = json_decode($jsonContent, true);
if ($callbackData && isset($callbackData['data']['data']) && is_array($callbackData['data']['data'])) {
$audioData = $callbackData['data']['data'];
echo "<p><strong>Callback data has " . count($audioData) . " variation(s) that should be stored:</strong></p>";
foreach ($audioData as $index => $item) {
$audioUrl = $item['audio_url'] ?? $item['source_audio_url'] ?? $item['stream_audio_url'] ?? null;
$hasUrl = !empty($audioUrl);
echo "<p>Variation {$index}: " . ($hasUrl ? "✅ Has audio URL" : "❌ No audio URL") . " - " . ($item['title'] ?? 'No title') . "</p>";
}
echo "<p style='color: orange;'><strong>⚠️ Variations exist in callback data but weren't stored in database!</strong></p>";
echo "<p><a href='restore_variations.php?track_id={$track['id']}&confirm=yes' style='background: #4CAF50; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px;'>🔧 Restore Variations</a></p>";
}
} else {
echo "<p style='color: orange;'>⚠️ task_results JSON file not found: {$taskResultsFile}</p>";
}
} else {
echo "<p style='color: green;'>✅ Found " . count($variations) . " variation(s) in database:</p>";
echo "<table border='1' cellpadding='5' style='border-collapse: collapse;'>";
echo "<tr><th>Index</th><th>Audio URL</th><th>Source URL</th><th>Stream URL</th><th>Duration</th><th>Title</th></tr>";
foreach ($variations as $var) {
echo "<tr>";
echo "<td>{$var['variation_index']}</td>";
echo "<td>" . ($var['audio_url'] ? '✅' : '❌') . "</td>";
echo "<td>" . ($var['source_audio_url'] ? '✅' : '❌') . "</td>";
echo "<td>" . ($var['stream_audio_url'] ? '✅' : '❌') . "</td>";
echo "<td>{$var['duration']}</td>";
echo "<td>" . ($var['title'] ?: 'NULL') . "</td>";
echo "</tr>";
}
echo "</table>";
}
echo "</div>";
}
echo "<hr>";
echo "<h3>Quick Fix Options:</h3>";
echo "<ol>";
echo "<li>If variations exist in callback data but not in DB, click 'Restore Variations' button above</li>";
echo "<li>If variations_count is wrong, run: <code>fix_missing_title_and_variations.php?artist_id={$artist_id}&confirm=yes</code></li>";
echo "<li>Check callback logs for errors: <code>tail -100 callback_log.txt | grep '{$tracks[0]['task_id']}'</code></li>";
echo "</ol>";