![]() 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 Audio URLs - Remove circular references
require_once 'config/database.php';
echo "š§ FIXING AUDIO URL CIRCULAR REFERENCES\n\n";
// Get database connection
$pdo = getDBConnection();
if (!$pdo) {
echo "ā Database connection failed\n";
exit;
}
echo "ā
Database connection successful\n\n";
// Find tracks with circular references
$stmt = $pdo->prepare("SELECT * FROM music_tracks WHERE audio_url LIKE '/audiofiles.php?id=%'");
$stmt->execute();
$circularTracks = $stmt->fetchAll();
echo "Found " . count($circularTracks) . " tracks with circular references:\n\n";
foreach ($circularTracks as $track) {
echo "Track ID: " . $track['id'] . "\n";
echo "Task ID: " . $track['task_id'] . "\n";
echo "Title: " . $track['title'] . "\n";
echo "Status: " . $track['status'] . "\n";
echo "Current Audio URL: " . $track['audio_url'] . "\n";
echo "User ID: " . $track['user_id'] . "\n";
echo "Created: " . $track['created_at'] . "\n";
echo "---\n";
}
echo "\nš§ FIXING OPTIONS:\n";
echo "1. Set audio_url to NULL for tracks with circular references\n";
echo "2. Update status to 'failed' for these tracks\n";
echo "3. Add a note in the metadata about the issue\n\n";
// Fix the circular references
$fixedCount = 0;
foreach ($circularTracks as $track) {
// Extract the task_id from the circular URL
$taskId = $track['task_id'];
// Check if there's an actual audio file for this task
$possiblePaths = [
'./audio_files/' . $taskId . '.mp3',
'./audio_files/' . $taskId . '.wav',
'./audio_files/' . $taskId . '.m4a',
'./task_results/' . $taskId . '.mp3',
'./task_results/' . $taskId . '.wav',
'./task_results/' . $taskId . '.m4a'
];
$foundFile = null;
foreach ($possiblePaths as $path) {
if (file_exists($path)) {
$foundFile = $path;
break;
}
}
if ($foundFile) {
// Found the actual audio file
$audioUrl = str_replace('./', '/', $foundFile);
echo "ā
Found audio file for " . $taskId . ": " . $audioUrl . "\n";
} else {
// No audio file found, set to NULL and mark as failed
$audioUrl = null;
echo "ā No audio file found for " . $taskId . " - marking as failed\n";
}
// Update the track
$updateStmt = $pdo->prepare("UPDATE music_tracks SET audio_url = ?, status = ? WHERE id = ?");
$newStatus = $foundFile ? 'complete' : 'failed';
$updateStmt->execute([$audioUrl, $newStatus, $track['id']]);
$fixedCount++;
}
echo "\nā
Fixed " . $fixedCount . " tracks\n\n";
// Show the specific track that was causing the 404
$stmt = $pdo->prepare("SELECT * FROM music_tracks WHERE task_id = ?");
$stmt->execute(['8cd1c23483097cc26fac73049ea0302d']);
$track = $stmt->fetch();
if ($track) {
echo "š SPECIFIC TRACK STATUS:\n";
echo "Task ID: " . $track['task_id'] . "\n";
echo "Title: " . $track['title'] . "\n";
echo "Status: " . $track['status'] . "\n";
echo "Audio URL: " . ($track['audio_url'] ?: 'NULL') . "\n";
echo "User ID: " . $track['user_id'] . "\n";
if ($track['status'] === 'failed') {
echo "\nā This track failed because no audio file was found\n";
echo "The original audio file may have been lost or never properly saved\n";
} else if ($track['audio_url']) {
echo "\nā
This track should now work properly\n";
echo "Try accessing: https://soundstudiopro.com/audiofiles.php?id=" . $track['task_id'] . "\n";
}
}
echo "\nš SUMMARY:\n";
echo "The circular reference issue has been fixed\n";
echo "Tracks with missing audio files have been marked as 'failed'\n";
echo "Tracks with found audio files have been updated with correct URLs\n";
echo "The audiofiles.php should now work properly for valid tracks\n";
?>