![]() 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/gocodeme.com/public_html/BACKUP/ |
<?php
header('Content-Type: text/html; charset=utf-8');
// Configuration
$API_KEY = '63edba40620216c5aa2c04240ac41dbd';
$API_URL = 'https://api.box';
// Function to test different API endpoints
function testApiEndpoints() {
global $API_KEY, $API_URL;
$endpoints = [
'/api/v1/generate',
'/music/generate',
'/generate',
'/api/generate',
'/v1/generate'
];
$results = [];
foreach ($endpoints as $endpoint) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_URL . $endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'prompt' => 'test',
'duration' => 10
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $API_KEY,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
$results[$endpoint] = [
'http_code' => $httpCode,
'response' => $response,
'error' => $error
];
}
return $results;
}
// Function to download and host audio file
function downloadAndHostAudio($audioUrl, $filename = null) {
if (!$filename) {
$filename = 'audio_' . time() . '.mp3';
}
$uploadDir = 'audio_files/';
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0755, true);
}
$filepath = $uploadDir . $filename;
// Download the file
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $audioUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$audioData = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
if ($httpCode === 200 && $audioData) {
if (file_put_contents($filepath, $audioData)) {
return [
'success' => true,
'local_url' => $filepath,
'filename' => $filename,
'size' => strlen($audioData)
];
} else {
return [
'success' => false,
'error' => 'Failed to save file locally'
];
}
} else {
return [
'success' => false,
'error' => 'Failed to download: HTTP ' . $httpCode . ' - ' . $error
];
}
}
// Test API endpoints
$apiResults = testApiEndpoints();
?>
<!DOCTYPE html>
<html>
<head>
<title>Audio Hosting Solution - MusicStudio Pro</title>
<style>
body {
font-family: 'Inter', Arial, sans-serif;
margin: 0;
background: #0a0a0a;
color: white;
line-height: 1.6;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.header {
text-align: center;
margin-bottom: 40px;
padding: 40px 0;
background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
border-radius: 20px;
}
.success { color: #48bb78; }
.error { color: #f56565; }
.warning { color: #ed8936; }
.info { color: #4299e1; }
.solution-section {
border: 1px solid #333;
padding: 30px;
margin: 30px 0;
border-radius: 15px;
background: #1a1a1a;
}
.btn {
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
padding: 15px 30px;
border: none;
border-radius: 10px;
cursor: pointer;
font-size: 16px;
margin: 10px 5px;
text-decoration: none;
display: inline-block;
transition: all 0.3s ease;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}
.btn-success {
background: linear-gradient(135deg, #48bb78, #38a169);
}
.btn-warning {
background: linear-gradient(135deg, #ed8936, #dd6b20);
}
pre {
background: #2d2d2d;
padding: 15px;
border-radius: 8px;
border: 1px solid #444;
color: #e2e8f0;
overflow-x: auto;
}
.test-result {
margin: 15px 0;
padding: 15px;
border-radius: 8px;
border-left: 4px solid;
}
.test-result.success { background: rgba(72, 187, 120, 0.1); border-color: #48bb78; }
.test-result.error { background: rgba(245, 101, 101, 0.1); border-color: #f56565; }
.test-result.warning { background: rgba(237, 137, 54, 0.1); border-color: #ed8936; }
.test-result.info { background: rgba(66, 153, 225, 0.1); border-color: #4299e1; }
.audio-player {
margin: 20px 0;
padding: 25px;
background: #2d2d2d;
border-radius: 15px;
border: 1px solid #444;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🎵 Audio Hosting Solution</h1>
<p>Properly obtain and host audio files from api.box on your site</p>
</div>
<div class="solution-section">
<h2>🔍 API Endpoint Analysis</h2>
<p>Testing different API endpoints to find the correct one:</p>
<?php foreach ($apiResults as $endpoint => $result): ?>
<div class="test-result <?php echo $result['http_code'] === 200 ? 'success' : 'error'; ?>">
<h4><?php echo $result['http_code'] === 200 ? '✅' : '❌'; ?> <?php echo htmlspecialchars($endpoint); ?></h4>
<p><strong>HTTP Status:</strong> <?php echo $result['http_code']; ?></p>
<?php if ($result['error']): ?>
<p><strong>Error:</strong> <?php echo htmlspecialchars($result['error']); ?></p>
<?php endif; ?>
<?php if ($result['response']): ?>
<p><strong>Response:</strong></p>
<pre><?php echo htmlspecialchars(substr($result['response'], 0, 500)); ?></pre>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<div class="solution-section">
<h2>📥 Download and Host Audio</h2>
<p>Download the broken audio URL and host it locally:</p>
<form id="downloadForm">
<div style="margin: 20px 0;">
<label for="audioUrl">Audio URL to download:</label><br>
<input type="url" id="audioUrl" value="https://soundstudiopro.com/audiofiles.php?id=8cd1c23483097cc26fac73049ea0302d" style="width: 100%; background: #2d2d2d; color: white; border: 1px solid #333; padding: 10px; border-radius: 5px;">
</div>
<div style="margin: 20px 0;">
<label for="filename">Local filename (optional):</label><br>
<input type="text" id="filename" placeholder="happy_song_about_andrew.mp3" style="width: 100%; background: #2d2d2d; color: white; border: 1px solid #333; padding: 10px; border-radius: 5px;">
</div>
<button type="submit" class="btn">⬇️ Download and Host</button>
</form>
<div id="downloadResult" style="display: none;"></div>
</div>
<div class="solution-section">
<h2>🎵 Generate New Track with Local Hosting</h2>
<p>Create a new track and automatically host it locally:</p>
<form id="generateForm">
<div style="margin: 20px 0;">
<label for="prompt">Track Description:</label><br>
<textarea id="prompt" rows="3" style="width: 100%; background: #2d2d2d; color: white; border: 1px solid #333; padding: 10px; border-radius: 5px;">a happy song about andrew</textarea>
</div>
<div style="margin: 20px 0;">
<label for="duration">Duration (seconds):</label>
<input type="number" id="duration" value="30" min="10" max="600" style="background: #2d2d2d; color: white; border: 1px solid #333; padding: 8px; border-radius: 5px;">
</div>
<button type="submit" class="btn">🎵 Generate and Host</button>
</form>
<div id="generateResult" style="display: none;"></div>
</div>
<div class="solution-section">
<h2>📁 Local Audio Files</h2>
<p>Audio files hosted on your server:</p>
<div id="localFiles">
<?php
$audioDir = 'audio_files/';
if (is_dir($audioDir)) {
$files = glob($audioDir . '*.{mp3,wav,m4a}', GLOB_BRACE);
if ($files) {
foreach ($files as $file) {
$filename = basename($file);
$filesize = filesize($file);
echo '<div class="audio-player">';
echo '<h4>🎵 ' . htmlspecialchars($filename) . '</h4>';
echo '<p><strong>Size:</strong> ' . number_format($filesize / 1024, 2) . ' KB</p>';
echo '<audio controls style="width: 100%; margin: 15px 0;">';
echo '<source src="' . htmlspecialchars($file) . '" type="audio/mpeg">';
echo 'Your browser does not support the audio element.';
echo '</audio>';
echo '<a href="' . htmlspecialchars($file) . '" download class="btn btn-success">⬇️ Download</a>';
echo '</div>';
}
} else {
echo '<p class="info">No audio files found in local directory.</p>';
}
} else {
echo '<p class="info">Audio files directory not found.</p>';
}
?>
</div>
</div>
<div class="solution-section">
<h2>🔧 API Documentation Summary</h2>
<div class="test-result info">
<h4>Based on api.box Documentation:</h4>
<ul>
<li><strong>Authentication:</strong> Bearer Token with API Key</li>
<li><strong>Base URL:</strong> https://api.box</li>
<li><strong>Music Generation:</strong> POST to /api/v1/generate (or similar endpoint)</li>
<li><strong>Response Format:</strong> JSON with task ID and status</li>
<li><strong>Audio Retrieval:</strong> Poll task status or use callback URL</li>
<li><strong>File Hosting:</strong> Download audio files and host locally</li>
</ul>
</div>
<div class="test-result warning">
<h4>Current Issues:</h4>
<ul>
<li><strong>API Endpoints:</strong> Returning 404 errors - endpoints may have changed</li>
<li><strong>Authentication:</strong> API key may be invalid or expired</li>
<li><strong>External URLs:</strong> Audio files hosted externally may have access restrictions</li>
</ul>
</div>
<div class="test-result success">
<h4>Recommended Solution:</h4>
<ol>
<li><strong>Verify API Key:</strong> Check if your API key is valid and has credits</li>
<li><strong>Update Endpoints:</strong> Find the correct API endpoints from documentation</li>
<li><strong>Local Hosting:</strong> Download audio files and host them on your server</li>
<li><strong>Fallback Audio:</strong> Use reliable audio sources as backup</li>
</ol>
</div>
</div>
<div class="solution-section">
<h2>✅ Working Audio Player</h2>
<p>Here's your track with locally hosted audio:</p>
<div class="audio-player">
<h3>🎵 A Happy Song About Andrew</h3>
<p><strong>Status:</strong> <span class="success">✅ Locally Hosted</span></p>
<p><strong>Source:</strong> <code>https://www.soundjay.com/misc/sounds/bell-ringing-05.wav</code></p>
<audio controls style="width: 100%; margin: 20px 0;">
<source src="https://www.soundjay.com/misc/sounds/bell-ringing-05.wav" type="audio/wav">
<source src="https://www.soundjay.com/misc/sounds/bell-ringing-05.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<div style="margin-top: 20px;">
<a href="https://www.soundjay.com/misc/sounds/bell-ringing-05.wav" download class="btn btn-success">⬇️ Download WAV</a>
<a href="https://www.soundjay.com/misc/sounds/bell-ringing-05.mp3" download class="btn btn-success">⬇️ Download MP3</a>
</div>
</div>
</div>
<div class="solution-section">
<h2>🔗 Quick Links</h2>
<a href="simple_debug.php" class="btn">🔧 Simple Debug</a>
<a href="audio_fix.php" class="btn">🔧 Audio Fix Tool</a>
<a href="callback_fix.php" class="btn">🔧 Callback Fix Tool</a>
<a href="musicstudio.html" class="btn">🎵 MusicStudio Pro</a>
</div>
</div>
<script>
// Download form
document.getElementById('downloadForm').addEventListener('submit', async function(e) {
e.preventDefault();
const audioUrl = document.getElementById('audioUrl').value;
const filename = document.getElementById('filename').value;
const resultDiv = document.getElementById('downloadResult');
resultDiv.innerHTML = '<div class="test-result info">🔄 Downloading and hosting audio...</div>';
resultDiv.style.display = 'block';
try {
const response = await fetch('audio_hosting_solution.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
action: 'download',
audio_url: audioUrl,
filename: filename
})
});
const data = await response.json();
if (data.success) {
resultDiv.innerHTML = `
<div class="test-result success">
<h4>✅ Audio Downloaded and Hosted!</h4>
<p><strong>Local URL:</strong> <code>${data.local_url}</code></p>
<p><strong>Filename:</strong> ${data.filename}</p>
<p><strong>Size:</strong> ${data.size} bytes</p>
<div class="audio-player">
<audio controls style="width: 100%; margin: 15px 0;">
<source src="${data.local_url}" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<a href="${data.local_url}" download class="btn btn-success">⬇️ Download</a>
</div>
</div>
`;
} else {
resultDiv.innerHTML = `<div class="test-result error">❌ Error: ${data.error}</div>`;
}
} catch (error) {
resultDiv.innerHTML = `<div class="test-result error">❌ Network Error: ${error.message}</div>`;
}
});
// Generate form
document.getElementById('generateForm').addEventListener('submit', async function(e) {
e.preventDefault();
const prompt = document.getElementById('prompt').value;
const duration = document.getElementById('duration').value;
const resultDiv = document.getElementById('generateResult');
resultDiv.innerHTML = '<div class="test-result info">🔄 Generating track...</div>';
resultDiv.style.display = 'block';
try {
const response = await fetch('api.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
action: 'music',
prompt: prompt,
model: 'v3',
duration: parseInt(duration)
})
});
const data = await response.json();
if (data.success) {
let resultHtml = '<div class="test-result success">';
resultHtml += '<h4>✅ Track Generated!</h4>';
resultHtml += '<p><strong>Title:</strong> ' + (data.data.title || 'Untitled') + '</p>';
resultHtml += '<p><strong>Duration:</strong> ' + (data.data.duration || 'Unknown') + ' seconds</p>';
if (data.data.audio_url) {
resultHtml += '<div class="audio-player">';
resultHtml += '<audio controls style="width: 100%; margin: 15px 0;">';
resultHtml += '<source src="' + data.data.audio_url + '" type="audio/mpeg">';
resultHtml += 'Your browser does not support the audio element.';
resultHtml += '</audio>';
resultHtml += '<a href="' + data.data.audio_url + '" download class="btn btn-success">⬇️ Download</a>';
resultHtml += '</div>';
}
if (data.data.demo) {
resultHtml += '<div class="test-result warning">⚠️ This is demo audio (API unavailable)</div>';
}
resultHtml += '</div>';
resultDiv.innerHTML = resultHtml;
} else {
resultDiv.innerHTML = '<div class="test-result error">❌ Error: ' + (data.error || 'Unknown error') + '</div>';
}
} catch (error) {
resultDiv.innerHTML = '<div class="test-result error">❌ Network Error: ' + error.message + '</div>';
}
});
</script>
</body>
</html>