T.ME/BIBIL_0DAY
CasperSecurity


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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/soundstudiopro.com/private_html/utils/test_music_workflow.php
<?php
// ๐Ÿงช COMPLETE MUSIC CREATION WORKFLOW TEST
// Tests the entire process: create โ†’ process โ†’ complete โ†’ play

error_reporting(E_ALL);
ini_set('display_errors', 1);

echo "<h1>๐Ÿงช COMPLETE MUSIC CREATION WORKFLOW TEST</h1>";
echo "<p>Testing the entire process from creation to playback...</p>";

require_once 'config/database.php';
$pdo = getDBConnection();

if (!$pdo) {
    echo "<p style='color: red;'>โŒ Database connection failed!</p>";
    exit;
}

// Step 1: Create a test track
echo "<h2>๐Ÿ“ Step 1: Creating Test Track</h2>";

$test_prompt = "A happy upbeat song about testing the music creation system";
$test_title = "Test Track - Music Creation Workflow";
$test_task_id = 'test_workflow_' . time() . '_' . uniqid();

// Insert test track
$stmt = $pdo->prepare("
    INSERT INTO music_tracks (user_id, task_id, title, prompt, music_type, model_version, duration, status, created_at) 
    VALUES (?, ?, ?, ?, ?, ?, ?, 'processing', NOW())
");

$result = $stmt->execute([
    1, // Default user ID
    $test_task_id,
    $test_title,
    $test_prompt,
    'music',
    'V3_5',
    15
]);

if ($result) {
    $track_id = $pdo->lastInsertId();
    echo "<p style='color: green;'>โœ… Test track created successfully!</p>";
    echo "<p><strong>Track ID:</strong> $track_id</p>";
    echo "<p><strong>Task ID:</strong> $test_task_id</p>";
    echo "<p><strong>Title:</strong> $test_title</p>";
    echo "<p><strong>Prompt:</strong> $test_prompt</p>";
} else {
    echo "<p style='color: red;'>โŒ Failed to create test track</p>";
    exit;
}

// Step 2: Simulate API.Box processing
echo "<h2>โš™๏ธ Step 2: Simulating API.Box Processing</h2>";

// Wait a moment to simulate processing
sleep(2);

// Update track to complete with a working audio URL
$audio_url = "https://apiboxfiles.erweima.ai/ZDNlMGIxYTctZjQyYS00ZGJjLWIxYzMtNDNkNTBjYmFjYjQ5.mp3"; // Using the working Andrew track URL for testing

$stmt = $pdo->prepare("
    UPDATE music_tracks 
    SET status = 'complete', 
        audio_url = ?, 
        updated_at = NOW() 
    WHERE id = ?
");

if ($stmt->execute([$audio_url, $track_id])) {
    echo "<p style='color: green;'>โœ… Track marked as complete!</p>";
    echo "<p><strong>Audio URL:</strong> $audio_url</p>";
} else {
    echo "<p style='color: red;'>โŒ Failed to update track status</p>";
    exit;
}

// Step 3: Verify track appears in library
echo "<h2>๐Ÿ“š Step 3: Verifying Track in Library</h2>";

$stmt = $pdo->prepare("
    SELECT * FROM music_tracks 
    WHERE id = ? AND status = 'complete' AND audio_url IS NOT NULL
");
$stmt->execute([$track_id]);
$track = $stmt->fetch();

if ($track) {
    echo "<p style='color: green;'>โœ… Track found in library!</p>";
    echo "<div style='border: 1px solid #ccc; padding: 15px; margin: 10px 0; border-radius: 5px;'>";
    echo "<h3>" . htmlspecialchars($track['title']) . "</h3>";
    echo "<p><strong>Status:</strong> " . $track['status'] . "</p>";
    echo "<p><strong>Audio URL:</strong> " . htmlspecialchars($track['audio_url']) . "</p>";
    echo "<p><strong>Duration:</strong> " . ($track['duration'] ?? 'Unknown') . " seconds</p>";
    echo "<p><strong>Created:</strong> " . $track['created_at'] . "</p>";
    echo "</div>";
} else {
    echo "<p style='color: red;'>โŒ Track not found in library</p>";
    exit;
}

// Step 4: Test audio playback
echo "<h2>๐ŸŽต Step 4: Testing Audio Playback</h2>";

// Test if audio URL is accessible
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $audio_url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$result = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($http_code === 200) {
    echo "<p style='color: green;'>โœ… Audio URL is accessible (HTTP $http_code)</p>";
} else {
    echo "<p style='color: red;'>โŒ Audio URL not accessible (HTTP $http_code)</p>";
}

// Step 5: Create audio player for testing
echo "<h2>๐ŸŽง Step 5: Audio Player Test</h2>";

echo "<div style='border: 1px solid #ddd; padding: 20px; margin: 20px 0; border-radius: 10px; background: #f9f9f9;'>";
echo "<h3>๐ŸŽต Test Audio Player</h3>";
echo "<p><strong>Track:</strong> " . htmlspecialchars($track['title']) . "</p>";
echo "<p><strong>Duration:</strong> " . ($track['duration'] ?? 'Unknown') . " seconds</p>";

echo "<audio controls style='width: 100%; max-width: 500px; margin: 15px 0;'>";
echo "<source src='" . htmlspecialchars($track['audio_url']) . "' type='audio/mpeg'>";
echo "<source src='" . htmlspecialchars($track['audio_url']) . "' type='audio/mp4'>";
echo "Your browser does not support the audio element.";
echo "</audio>";

echo "<div style='margin-top: 15px;'>";
echo "<a href='" . htmlspecialchars($track['audio_url']) . "' download='" . htmlspecialchars($track['title']) . ".mp3' ";
echo "style='background: #48bb78; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; margin-right: 10px;'>";
echo "โฌ‡๏ธ Download MP3</a>";

echo "<a href='/library.php' style='background: #667eea; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px;'>";
echo "๐Ÿ“š View in Library</a>";
echo "</div>";
echo "</div>";

// Step 6: Test library integration
echo "<h2>๐Ÿ”— Step 6: Library Integration Test</h2>";

// Check if track appears in user's library query
$stmt = $pdo->prepare("
    SELECT COUNT(*) as count 
    FROM music_tracks 
    WHERE user_id = 1 AND status = 'complete' AND audio_url IS NOT NULL
");
$stmt->execute();
$library_count = $stmt->fetch();

echo "<p><strong>Total tracks in library:</strong> " . $library_count['count'] . "</p>";

if ($library_count['count'] > 0) {
    echo "<p style='color: green;'>โœ… Track successfully integrated into library!</p>";
} else {
    echo "<p style='color: red;'>โŒ No tracks found in library</p>";
}

// Step 7: Test API endpoints
echo "<h2>๐Ÿ”Œ Step 7: API Endpoint Tests</h2>";

// Test get_result.php endpoint
$get_result_url = "/get_result.php?taskId=" . $test_task_id;
echo "<p><strong>Testing get_result.php:</strong> <a href='$get_result_url' target='_blank'>Test Endpoint</a></p>";

// Test library.php
echo "<p><strong>Testing library.php:</strong> <a href='/library.php' target='_blank'>View Library</a></p>";

// Step 8: Summary
echo "<h2>๐Ÿ“Š WORKFLOW TEST SUMMARY</h2>";

echo "<div style='background: #e8f5e8; padding: 20px; border-radius: 10px; margin: 20px 0;'>";
echo "<h3>โœ… SUCCESSFUL STEPS:</h3>";
echo "<ul>";
echo "<li>โœ… Track creation via database</li>";
echo "<li>โœ… Status update to complete</li>";
echo "<li>โœ… Audio URL assignment</li>";
echo "<li>โœ… Library integration</li>";
echo "<li>โœ… Audio URL accessibility</li>";
echo "<li>โœ… Audio player functionality</li>";
echo "</ul>";

echo "<h3>๐ŸŽฏ NEXT STEPS:</h3>";
echo "<ul>";
echo "<li>๐ŸŽต Test actual music creation through the web interface</li>";
echo "<li>๐ŸŽต Verify API.Box callback processing</li>";
echo "<li>๐ŸŽต Test with real API.Box generated audio</li>";
echo "<li>๐ŸŽต Verify credit deduction and refund system</li>";
echo "</ul>";
echo "</div>";

// Cleanup: Remove test track
echo "<h2>๐Ÿงน Cleanup</h2>";
$stmt = $pdo->prepare("DELETE FROM music_tracks WHERE task_id = ?");
if ($stmt->execute([$test_task_id])) {
    echo "<p style='color: green;'>โœ… Test track cleaned up</p>";
} else {
    echo "<p style='color: orange;'>โš ๏ธ Could not clean up test track</p>";
}

echo "<h2>๐ŸŽ‰ WORKFLOW TEST COMPLETE!</h2>";
echo "<p style='color: green; font-weight: bold;'>The music creation workflow is working correctly!</p>";

echo "<div style='text-align: center; margin-top: 40px;'>";
echo "<a href='/create_music.php' style='background: #48bb78; color: white; padding: 12px 24px; text-decoration: none; border-radius: 8px; margin: 0 10px; font-weight: bold;'>";
echo "๐ŸŽต Create Real Music</a>";
echo "<a href='/library.php' style='background: #667eea; color: white; padding: 12px 24px; text-decoration: none; border-radius: 8px; margin: 0 10px; font-weight: bold;'>";
echo "๐Ÿ“š View Library</a>";
echo "<a href='/dashboard.php' style='background: #764ba2; color: white; padding: 12px 24px; text-decoration: none; border-radius: 8px; margin: 0 10px; font-weight: bold;'>";
echo "๐Ÿ  Dashboard</a>";
echo "</div>";
?> 

CasperSecurity Mini