![]() 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
// check_all_audio_urls.php - Comprehensive check for external audio URLs
require_once 'config/database.php';
$pdo = getDBConnection();
if (!$pdo) {
die("❌ Database connection failed\n");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Audio URL Audit</title>
<style>
body { font-family: Arial; padding: 20px; background: #1a1a1a; color: #fff; }
.container { max-width: 1400px; margin: 0 auto; }
h1 { color: #667eea; }
h2 { color: #764ba2; margin-top: 30px; }
table { width: 100%; border-collapse: collapse; margin: 20px 0; background: rgba(255,255,255,0.05); }
th, td { padding: 12px; text-align: left; border: 1px solid rgba(255,255,255,0.1); }
th { background: rgba(102, 126, 234, 0.3); color: #fff; }
tr:hover { background: rgba(255,255,255,0.05); }
.external { color: #ffa500; font-weight: bold; }
.local { color: #10b981; }
.missing { color: #ef4444; }
.error { color: #ef4444; }
.success { color: #10b981; }
.warning { color: #fbbf24; }
.stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin: 20px 0;
}
.stat-card {
background: rgba(255,255,255,0.05);
padding: 20px;
border-radius: 10px;
border: 1px solid rgba(255,255,255,0.1);
}
.stat-number { font-size: 2rem; font-weight: bold; color: #667eea; }
.stat-label { color: #a0aec0; margin-top: 5px; }
code { background: rgba(0,0,0,0.3); padding: 2px 6px; border-radius: 3px; font-size: 0.9em; }
.bad { background: rgba(239, 68, 68, 0.2); }
.good { background: rgba(16, 185, 129, 0.1); }
</style>
</head>
<body>
<div class="container">
<h1>🔍 Complete Audio URL Audit</h1>
<?php
// Check main tracks
echo "<h2>📊 Main Tracks (music_tracks table)</h2>";
$stmt = $pdo->query("
SELECT
id,
task_id,
title,
audio_url,
status,
created_at,
u.name as artist_name
FROM music_tracks mt
LEFT JOIN users u ON mt.user_id = u.id
WHERE mt.status = 'complete'
AND mt.audio_url IS NOT NULL
AND mt.audio_url != ''
ORDER BY mt.created_at DESC
");
$tracks = $stmt->fetchAll(PDO::FETCH_ASSOC);
$totalTracks = count($tracks);
$externalTracks = [];
$localTracks = [];
$missingFiles = [];
$proxyTracks = [];
foreach ($tracks as $track) {
$url = $track['audio_url'];
// Check if external URL
if (preg_match('/^https?:\/\//', $url) && !preg_match('/^https?:\/\/' . preg_quote($_SERVER['HTTP_HOST'], '/') . '/', $url)) {
$externalTracks[] = $track;
}
// Check if proxy URL (audiofiles.php or audio_proxy)
elseif (strpos($url, 'audiofiles.php') !== false || strpos($url, 'audio_proxy') !== false) {
$proxyTracks[] = $track;
}
// Check if local file path
elseif (preg_match('/^\/audio_files\//', $url)) {
$localPath = ltrim($url, '/');
if (file_exists($localPath)) {
$localTracks[] = $track;
} else {
$missingFiles[] = $track;
}
}
// Other local paths
else {
$localTracks[] = $track;
}
}
// Check audio variations
echo "<h2>🎵 Audio Variations (audio_variations table)</h2>";
$stmt = $pdo->query("
SELECT
av.id,
av.track_id,
av.variation_index,
av.audio_url,
mt.task_id,
mt.title as track_title,
u.name as artist_name
FROM audio_variations av
JOIN music_tracks mt ON av.track_id = mt.id
LEFT JOIN users u ON mt.user_id = u.id
WHERE av.audio_url IS NOT NULL
AND av.audio_url != ''
ORDER BY av.id DESC
");
$variations = $stmt->fetchAll(PDO::FETCH_ASSOC);
$totalVariations = count($variations);
$externalVariations = [];
$localVariations = [];
$missingVariationFiles = [];
$proxyVariations = [];
foreach ($variations as $variation) {
$url = $variation['audio_url'];
// Check if external URL
if (preg_match('/^https?:\/\//', $url) && !preg_match('/^https?:\/\/' . preg_quote($_SERVER['HTTP_HOST'], '/') . '/', $url)) {
$externalVariations[] = $variation;
}
// Check if proxy URL
elseif (strpos($url, 'audiofiles.php') !== false || strpos($url, 'audio_proxy') !== false) {
$proxyVariations[] = $variation;
}
// Check if local file path
elseif (preg_match('/^\/audio_files\//', $url)) {
$localPath = ltrim($url, '/');
if (file_exists($localPath)) {
$localVariations[] = $variation;
} else {
$missingVariationFiles[] = $variation;
}
}
// Other local paths
else {
$localVariations[] = $variation;
}
}
// Display statistics
echo "<div class='stats'>";
echo "<div class='stat-card " . (count($externalTracks) > 0 ? 'bad' : 'good') . "'>";
echo "<div class='stat-number'>" . count($externalTracks) . "</div>";
echo "<div class='stat-label'>External URLs (Tracks)</div>";
echo "</div>";
echo "<div class='stat-card " . (count($externalVariations) > 0 ? 'bad' : 'good') . "'>";
echo "<div class='stat-number'>" . count($externalVariations) . "</div>";
echo "<div class='stat-label'>External URLs (Variations)</div>";
echo "</div>";
echo "<div class='stat-card " . (count($proxyTracks) > 0 || count($proxyVariations) > 0 ? 'warning' : 'good') . "'>";
echo "<div class='stat-number'>" . (count($proxyTracks) + count($proxyVariations)) . "</div>";
echo "<div class='stat-label'>Proxy URLs (Should be /audio_files/)</div>";
echo "</div>";
echo "<div class='stat-card " . (count($missingFiles) > 0 || count($missingVariationFiles) > 0 ? 'bad' : 'good') . "'>";
echo "<div class='stat-number'>" . (count($missingFiles) + count($missingVariationFiles)) . "</div>";
echo "<div class='stat-label'>Missing Files</div>";
echo "</div>";
echo "<div class='stat-card good'>";
echo "<div class='stat-number'>" . (count($localTracks) + count($localVariations)) . "</div>";
echo "<div class='stat-label'>Local Files (OK)</div>";
echo "</div>";
echo "</div>";
// Show external tracks
if (count($externalTracks) > 0) {
echo "<h2>⚠️ Tracks with External URLs</h2>";
echo "<table>";
echo "<tr><th>Title</th><th>Artist</th><th>Task ID</th><th>External URL</th><th>Created</th></tr>";
foreach ($externalTracks as $track) {
echo "<tr class='bad'>";
echo "<td><strong>" . htmlspecialchars($track['title']) . "</strong></td>";
echo "<td>" . htmlspecialchars($track['artist_name'] ?? 'Unknown') . "</td>";
echo "<td><code>" . htmlspecialchars($track['task_id']) . "</code></td>";
echo "<td class='external'>" . htmlspecialchars(substr($track['audio_url'], 0, 80)) . "...</td>";
echo "<td>" . date('M j, Y', strtotime($track['created_at'])) . "</td>";
echo "</tr>";
}
echo "</table>";
}
// Show external variations
if (count($externalVariations) > 0) {
echo "<h2>⚠️ Variations with External URLs</h2>";
echo "<table>";
echo "<tr><th>Track Title</th><th>Artist</th><th>Variation #</th><th>External URL</th></tr>";
foreach ($externalVariations as $variation) {
echo "<tr class='bad'>";
echo "<td><strong>" . htmlspecialchars($variation['track_title']) . "</strong></td>";
echo "<td>" . htmlspecialchars($variation['artist_name'] ?? 'Unknown') . "</td>";
echo "<td>Variation " . htmlspecialchars($variation['variation_index']) . "</td>";
echo "<td class='external'>" . htmlspecialchars(substr($variation['audio_url'], 0, 80)) . "...</td>";
echo "</tr>";
}
echo "</table>";
}
// Show proxy URLs (should be converted to /audio_files/)
if (count($proxyTracks) > 0 || count($proxyVariations) > 0) {
echo "<h2>🔗 Proxy URLs (Should be converted to /audio_files/)</h2>";
if (count($proxyTracks) > 0) {
echo "<h3>Tracks:</h3>";
echo "<table>";
echo "<tr><th>Title</th><th>Task ID</th><th>Proxy URL</th></tr>";
foreach ($proxyTracks as $track) {
echo "<tr class='warning'>";
echo "<td><strong>" . htmlspecialchars($track['title']) . "</strong></td>";
echo "<td><code>" . htmlspecialchars($track['task_id']) . "</code></td>";
echo "<td>" . htmlspecialchars($track['audio_url']) . "</td>";
echo "</tr>";
}
echo "</table>";
}
if (count($proxyVariations) > 0) {
echo "<h3>Variations:</h3>";
echo "<table>";
echo "<tr><th>Track Title</th><th>Variation #</th><th>Proxy URL</th></tr>";
foreach ($proxyVariations as $variation) {
echo "<tr class='warning'>";
echo "<td><strong>" . htmlspecialchars($variation['track_title']) . "</strong></td>";
echo "<td>Variation " . htmlspecialchars($variation['variation_index']) . "</td>";
echo "<td>" . htmlspecialchars($variation['audio_url']) . "</td>";
echo "</tr>";
}
echo "</table>";
}
}
// Show missing files
if (count($missingFiles) > 0 || count($missingVariationFiles) > 0) {
echo "<h2>❌ Missing Files (URLs point to non-existent files)</h2>";
if (count($missingFiles) > 0) {
echo "<h3>Tracks:</h3>";
echo "<table>";
echo "<tr><th>Title</th><th>Task ID</th><th>Missing Path</th></tr>";
foreach ($missingFiles as $track) {
echo "<tr class='bad'>";
echo "<td><strong>" . htmlspecialchars($track['title']) . "</strong></td>";
echo "<td><code>" . htmlspecialchars($track['task_id']) . "</code></td>";
echo "<td class='missing'>" . htmlspecialchars($track['audio_url']) . "</td>";
echo "</tr>";
}
echo "</table>";
}
if (count($missingVariationFiles) > 0) {
echo "<h3>Variations:</h3>";
echo "<table>";
echo "<tr><th>Track Title</th><th>Variation #</th><th>Missing Path</th></tr>";
foreach ($missingVariationFiles as $variation) {
echo "<tr class='bad'>";
echo "<td><strong>" . htmlspecialchars($variation['track_title']) . "</strong></td>";
echo "<td>Variation " . htmlspecialchars($variation['variation_index']) . "</td>";
echo "<td class='missing'>" . htmlspecialchars($variation['audio_url']) . "</td>";
echo "</tr>";
}
echo "</table>";
}
}
// Summary
$totalExternal = count($externalTracks) + count($externalVariations);
$totalIssues = $totalExternal + count($proxyTracks) + count($proxyVariations) + count($missingFiles) + count($missingVariationFiles);
if ($totalIssues === 0) {
echo "<div style='background: rgba(16, 185, 129, 0.2); padding: 30px; border-radius: 10px; margin: 30px 0; border: 2px solid #10b981;'>";
echo "<h2 style='color: #10b981; margin: 0;'>✅ Perfect! All audio files are local!</h2>";
echo "<p style='font-size: 1.2em; margin-top: 10px;'>All " . ($totalTracks + $totalVariations) . " audio URLs are using local files from <code>/audio_files/</code>.</p>";
echo "</div>";
} else {
echo "<div style='background: rgba(239, 68, 68, 0.2); padding: 30px; border-radius: 10px; margin: 30px 0; border: 2px solid #ef4444;'>";
echo "<h2 style='color: #ef4444; margin: 0;'>⚠️ Issues Found</h2>";
echo "<p style='font-size: 1.2em; margin-top: 10px;'>";
echo "Found <strong>$totalIssues</strong> issues: ";
if ($totalExternal > 0) echo "<strong>$totalExternal</strong> external URLs, ";
if (count($proxyTracks) + count($proxyVariations) > 0) echo "<strong>" . (count($proxyTracks) + count($proxyVariations)) . "</strong> proxy URLs, ";
if (count($missingFiles) + count($missingVariationFiles) > 0) echo "<strong>" . (count($missingFiles) + count($missingVariationFiles)) . "</strong> missing files. ";
echo "</p>";
echo "<p><a href='fix_external_audio_urls.php' style='background: linear-gradient(135deg, #667eea, #764ba2); color: white; padding: 15px 30px; border-radius: 5px; text-decoration: none; display: inline-block; margin-top: 15px;'>🔧 Fix External URLs</a></p>";
echo "</div>";
}
// Check callback.php to see if it's downloading
echo "<h2>🔧 System Check</h2>";
echo "<div style='background: rgba(255,255,255,0.05); padding: 20px; border-radius: 10px;'>";
$callbackFile = 'callback.php';
if (file_exists($callbackFile)) {
$callbackContent = file_get_contents($callbackFile);
if (strpos($callbackContent, 'downloadAndStoreAudio') !== false) {
echo "<p class='success'>✅ callback.php has downloadAndStoreAudio() function</p>";
} else {
echo "<p class='error'>❌ callback.php missing downloadAndStoreAudio() function</p>";
}
// Check if it's actually calling the function
if (preg_match('/downloadAndStoreAudio\s*\(/', $callbackContent)) {
echo "<p class='success'>✅ callback.php calls downloadAndStoreAudio()</p>";
} else {
echo "<p class='error'>❌ callback.php does NOT call downloadAndStoreAudio()</p>";
}
} else {
echo "<p class='error'>❌ callback.php not found</p>";
}
// Check audio_files directory
if (is_dir('audio_files')) {
$fileCount = count(glob('audio_files/*.{mp3,wav,m4a,ogg,flac}', GLOB_BRACE));
echo "<p class='success'>✅ audio_files/ directory exists with $fileCount audio files</p>";
} else {
echo "<p class='error'>❌ audio_files/ directory does not exist</p>";
}
echo "</div>";
?>
</div>
</body>
</html>