![]() 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
// Debug Audiofiles.php Issue
session_start();
echo "š DEBUGGING AUDIOFILES.PHP ISSUE\n\n";
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
echo "ā User not logged in\n";
echo "Session data: " . print_r($_SESSION, true) . "\n";
exit;
}
echo "ā
User logged in: " . $_SESSION['user_name'] . " (ID: " . $_SESSION['user_id'] . ")\n\n";
// Get the task ID from the URL
$taskId = $_GET['id'] ?? '';
if (empty($taskId)) {
echo "ā Missing id parameter\n";
echo "Available GET parameters: " . print_r($_GET, true) . "\n";
exit;
}
echo "ā
Task ID: " . $taskId . "\n\n";
// Validate task ID format
if (!preg_match('/^[a-zA-Z0-9]+$/', $taskId)) {
echo "ā Invalid id format: " . $taskId . "\n";
exit;
}
echo "ā
Task ID format is valid\n\n";
// Include database configuration
require_once 'config/database.php';
// Get database connection
$pdo = getDBConnection();
if (!$pdo) {
echo "ā Database connection failed\n";
exit;
}
echo "ā
Database connection successful\n\n";
// Check if track exists and user owns it
$stmt = $pdo->prepare("SELECT * FROM music_tracks WHERE task_id = ? AND user_id = ?");
$stmt->execute([$taskId, $_SESSION['user_id']]);
$track = $stmt->fetch();
if (!$track) {
echo "ā Track not found or access denied\n";
echo "Searching for task_id: " . $taskId . " and user_id: " . $_SESSION['user_id'] . "\n";
// Check if track exists at all
$stmt = $pdo->prepare("SELECT * FROM music_tracks WHERE task_id = ?");
$stmt->execute([$taskId]);
$anyTrack = $stmt->fetch();
if ($anyTrack) {
echo "Track exists but belongs to user_id: " . $anyTrack['user_id'] . "\n";
} else {
echo "No track found with task_id: " . $taskId . "\n";
}
// Show user's tracks
$stmt = $pdo->prepare("SELECT task_id, title, status FROM music_tracks WHERE user_id = ? LIMIT 5");
$stmt->execute([$_SESSION['user_id']]);
$userTracks = $stmt->fetchAll();
echo "User's tracks:\n";
foreach ($userTracks as $userTrack) {
echo "- " . $userTrack['task_id'] . " (" . $userTrack['title'] . ") - " . $userTrack['status'] . "\n";
}
exit;
}
echo "ā
Track found and user has access\n";
echo "Track details:\n";
echo "- Title: " . $track['title'] . "\n";
echo "- Status: " . $track['status'] . "\n";
echo "- Audio URL: " . $track['audio_url'] . "\n";
echo "- Music Type: " . $track['music_type'] . "\n";
echo "- Created: " . $track['created_at'] . "\n\n";
if ($track['status'] !== 'complete') {
echo "ā Track status is not 'complete': " . $track['status'] . "\n";
exit;
}
if (empty($track['audio_url'])) {
echo "ā No audio URL found for this track\n";
exit;
}
echo "ā
Track is complete and has audio URL\n\n";
$audioUrl = $track['audio_url'];
// Check if it's a local URL
if (strpos($audioUrl, '/audio_files/') === 0) {
echo "š Local file detected\n";
$localPath = '.' . $audioUrl;
echo "Local path: " . $localPath . "\n";
if (file_exists($localPath)) {
echo "ā
Local file exists\n";
echo "File size: " . filesize($localPath) . " bytes\n";
echo "File permissions: " . substr(sprintf('%o', fileperms($localPath)), -4) . "\n";
} else {
echo "ā Local file does not exist\n";
echo "Directory exists: " . (is_dir(dirname($localPath)) ? 'Yes' : 'No') . "\n";
}
}
// Check if it's an API BOX URL
if (strpos($audioUrl, 'api.box') !== false) {
echo "š API BOX URL detected\n";
echo "URL: " . $audioUrl . "\n";
// Test if URL is accessible
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $audioUrl);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
$contentLength = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
curl_close($ch);
echo "HTTP Code: " . $httpCode . "\n";
echo "Content Type: " . $contentType . "\n";
echo "Content Length: " . $contentLength . "\n";
if ($httpCode === 200) {
echo "ā
API BOX URL is accessible\n";
} else {
echo "ā API BOX URL returned HTTP " . $httpCode . "\n";
}
}
// Check for other URL types
if (strpos($audioUrl, 'http') === 0 && strpos($audioUrl, 'api.box') === false) {
echo "š External URL detected\n";
echo "URL: " . $audioUrl . "\n";
// Test if URL is accessible
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $audioUrl);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);
echo "HTTP Code: " . $httpCode . "\n";
echo "Content Type: " . $contentType . "\n";
if ($httpCode === 200) {
echo "ā
External URL is accessible\n";
} else {
echo "ā External URL returned HTTP " . $httpCode . "\n";
}
}
echo "\nš§ SUGGESTED FIXES:\n";
echo "1. If local file doesn't exist, check if files were downloaded properly\n";
echo "2. If API BOX URL fails, check if the URL is still valid\n";
echo "3. If external URL fails, the file may have been moved or deleted\n";
echo "4. Check server permissions for audio file access\n";
echo "5. Verify CORS settings if accessing external URLs\n";
echo "\nš TESTING STEPS:\n";
echo "1. Try accessing: https://soundstudiopro.com/audiofiles.php?id=" . $taskId . "\n";
echo "2. Check browser developer tools for network errors\n";
echo "3. Check server error logs for PHP errors\n";
echo "4. Verify the audio URL in the database is correct\n";
?>