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/.cursor-server/data/User/History/-728cc0e6/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/.cursor-server/data/User/History/-728cc0e6/JUFb.php
<?php
session_start();
require_once 'config/database.php';

$pdo = getDBConnection();

// Find Stephane's user ID
$stmt = $pdo->prepare("SELECT id, name, email FROM users WHERE name LIKE '%stephane%' OR name LIKE '%Stephane%' OR email LIKE '%stephane%'");
$stmt->execute();
$stephane = $stmt->fetch();

if (!$stephane) {
    echo "āŒ Stephane not found in database\n";
    exit;
}

echo "āœ… Found Stephane: {$stephane['name']} (ID: {$stephane['id']})\n\n";

// Get Stephane's tracks that are marked as failed but should be complete
$stmt = $pdo->prepare("
    SELECT 
        id,
        task_id,
        title,
        status,
        audio_url,
        duration,
        created_at,
        updated_at
    FROM music_tracks 
    WHERE user_id = ? AND status = 'failed'
    ORDER BY created_at DESC
");
$stmt->execute([$stephane['id']]);
$failedTracks = $stmt->fetchAll();

echo "šŸ” Checking failed tracks that might actually be complete...\n";
echo str_repeat("-", 60) . "\n";

$updatedCount = 0;

foreach ($failedTracks as $track) {
    echo "Track ID: {$track['id']} - {$track['title']}\n";
    echo "Task ID: {$track['task_id']}\n";
    
    // Check if there's a task result file
    $resultFile = "task_results/{$track['task_id']}.json";
    
    if (file_exists($resultFile)) {
        echo "āœ… Found task result file\n";
        
        $resultData = json_decode(file_get_contents($resultFile), true);
        
        if ($resultData && isset($resultData['data']['callbackType']) && $resultData['data']['callbackType'] === 'complete') {
            $audioData = $resultData['data']['data'] ?? [];
            
            if (!empty($audioData)) {
                // Get the first audio file with a valid URL
                $audioUrl = null;
                $duration = null;
                
                foreach ($audioData as $audio) {
                    if (!empty($audio['audio_url'])) {
                        $audioUrl = $audio['audio_url'];
                        $duration = $audio['duration'] ?? null;
                        break;
                    }
                }
                
                if ($audioUrl) {
                    echo "āœ… Found audio URL: $audioUrl\n";
                    echo "āœ… Duration: $duration seconds\n";
                    
                    // Update the track to complete
                    $updateStmt = $pdo->prepare("
                        UPDATE music_tracks 
                        SET status = 'complete', 
                            audio_url = ?, 
                            duration = ?,
                            updated_at = NOW() 
                        WHERE id = ?
                    ");
                    $updateStmt->execute([$audioUrl, $duration, $track['id']]);
                    
                    echo "āœ… Updated track {$track['id']} to complete\n";
                    $updatedCount++;
                    
                    // Also store variations if there are multiple
                    if (count($audioData) > 1) {
                        echo "šŸ“ Storing {$audioData} variations...\n";
                        
                        // Clear existing variations
                        $stmt = $pdo->prepare("DELETE FROM audio_variations WHERE track_id = ?");
                        $stmt->execute([$track['id']]);
                        
                        // Insert each variation
                        foreach ($audioData as $index => $variation) {
                            if (isset($variation['audio_url']) && !empty($variation['audio_url'])) {
                                $stmt = $pdo->prepare("
                                    INSERT INTO audio_variations 
                                    (track_id, variation_index, audio_url, duration, title, tags, image_url, source_audio_url, stream_audio_url) 
                                    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
                                ");
                                
                                $stmt->execute([
                                    $track['id'],
                                    $index,
                                    $variation['audio_url'],
                                    $variation['duration'] ?? null,
                                    $variation['title'] ?? null,
                                    $variation['tags'] ?? null,
                                    $variation['image_url'] ?? null,
                                    $variation['source_audio_url'] ?? null,
                                    $variation['stream_audio_url'] ?? null
                                ]);
                            }
                        }
                        
                        // Update variations count
                        $variations_count = count($audioData);
                        $stmt = $pdo->prepare("UPDATE music_tracks SET variations_count = ?, selected_variation = 0 WHERE id = ?");
                        $stmt->execute([$variations_count, $track['id']]);
                        
                        echo "āœ… Stored $variations_count variations\n";
                    }
                } else {
                    echo "āŒ No valid audio URL found in result data\n";
                }
            } else {
                echo "āŒ No audio data found in result\n";
            }
        } else {
            echo "āŒ Result data doesn't indicate completion\n";
        }
    } else {
        echo "āŒ No task result file found\n";
    }
    
    echo "\n";
}

// Final summary
echo "šŸ“ˆ Fix Summary:\n";
echo str_repeat("-", 40) . "\n";
echo "Tracks updated: $updatedCount\n";

$stmt = $pdo->prepare("
    SELECT 
        COUNT(*) as total,
        COUNT(CASE WHEN status = 'complete' THEN 1 END) as completed,
        COUNT(CASE WHEN status = 'processing' THEN 1 END) as processing,
        COUNT(CASE WHEN status = 'failed' THEN 1 END) as failed
    FROM music_tracks 
    WHERE user_id = ?
");
$stmt->execute([$stephane['id']]);
$finalStats = $stmt->fetch();

echo "\nFinal Stats:\n";
echo "Total tracks: {$finalStats['total']}\n";
echo "Completed: {$finalStats['completed']}\n";
echo "Processing: {$finalStats['processing']}\n";
echo "Failed: {$finalStats['failed']}\n";

if ($updatedCount > 0) {
    echo "\nšŸŽ‰ Successfully fixed $updatedCount tracks!\n";
    echo "Stephane's library should now show the correct completed tracks.\n";
} else {
    echo "\nā„¹ļø  No tracks needed updating.\n";
}
?> 

CasperSecurity Mini