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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/soundstudiopro.com/private_html/fix_existing_tracks.php
<?php
// Script to fix all existing tracks stuck in processing status
require_once 'config/database.php';

echo "šŸ”§ Fixing Existing Tracks Stuck in Processing Status\n";
echo "==================================================\n\n";

// Test database connection
echo "1. Testing database connection...\n";
$pdo = getDBConnection();
if ($pdo) {
    echo "āœ… Database connection successful\n\n";
} else {
    echo "āŒ Database connection failed\n";
    exit;
}

// Find all tracks stuck in processing
echo "2. Finding tracks stuck in 'processing' status...\n";
$stmt = $pdo->query("SELECT id, task_id, status, created_at, title FROM music_tracks WHERE status = 'processing' ORDER BY created_at DESC");
$processingTracks = $stmt->fetchAll(PDO::FETCH_ASSOC);

if (empty($processingTracks)) {
    echo "āœ… No tracks stuck in processing status\n";
    exit;
}

echo "āš ļø Found " . count($processingTracks) . " tracks stuck in processing:\n";
foreach ($processingTracks as $track) {
    echo "   - ID: {$track['id']}, Task: {$track['task_id']}, Title: {$track['title']}, Created: {$track['created_at']}\n";
}
echo "\n";

// Check which tracks have audio files
echo "3. Checking which tracks have audio files...\n";
$tracksWithAudio = [];
$tracksWithoutAudio = [];

foreach ($processingTracks as $track) {
    $audioPath = "audio_files/{$track['task_id']}.mp3";
    if (file_exists($audioPath)) {
        $tracksWithAudio[] = $track;
        echo "   āœ… Track {$track['task_id']} has audio file: " . filesize($audioPath) . " bytes\n";
    } else {
        $tracksWithoutAudio[] = $track;
        echo "   āŒ Track {$track['task_id']} missing audio file\n";
    }
}

echo "\nšŸ“Š Summary:\n";
echo "   - Tracks with audio: " . count($tracksWithAudio) . "\n";
echo "   - Tracks without audio: " . count($tracksWithoutAudio) . "\n\n";

// Fix tracks with audio files
if (!empty($tracksWithAudio)) {
    echo "4. Fixing tracks with audio files...\n";
    $fixedCount = 0;
    
    foreach ($tracksWithAudio as $track) {
        $audioPath = "audio_files/{$track['task_id']}.mp3";
        $webPath = "/audio_files/{$track['task_id']}.mp3";
        
        // Get file duration (approximate)
        $duration = null;
        if (function_exists('getID3')) {
            $getID3 = new getID3;
            $fileInfo = $getID3->analyze($audioPath);
            $duration = isset($fileInfo['playtime_seconds']) ? round($fileInfo['playtime_seconds']) : null;
        }
        
        // Update the track status to complete
        $stmt = $pdo->prepare("
            UPDATE music_tracks 
            SET status = 'complete', 
                audio_url = ?, 
                duration = ?, 
                updated_at = NOW() 
            WHERE task_id = ?
        ");
        
        $result = $stmt->execute([$webPath, $duration, $track['task_id']]);
        
        if ($result) {
            echo "   āœ… Fixed track {$track['task_id']} - Status: complete, Audio: {$webPath}, Duration: " . ($duration ?: 'unknown') . "\n";
            $fixedCount++;
        } else {
            echo "   āŒ Failed to fix track {$track['task_id']}\n";
            $errorInfo = $stmt->errorInfo();
            echo "      Error: " . json_encode($errorInfo) . "\n";
        }
    }
    
    echo "\n   šŸŽÆ Successfully fixed $fixedCount tracks with audio files!\n\n";
}

// Handle tracks without audio files
if (!empty($tracksWithoutAudio)) {
    echo "5. Handling tracks without audio files...\n";
    echo "   These tracks may have failed generation or been deleted.\n";
    
    foreach ($tracksWithoutAudio as $track) {
        // Check if this is a very old track (more than 24 hours)
        $createdTime = strtotime($track['created_at']);
        $currentTime = time();
        $hoursOld = ($currentTime - $createdTime) / 3600;
        
        if ($hoursOld > 24) {
            // Mark very old tracks as failed
            $stmt = $pdo->prepare("
                UPDATE music_tracks 
                SET status = 'failed', 
                    metadata = JSON_SET(COALESCE(metadata, '{}'), '$.error_message', 'Track generation failed or timed out'),
                    updated_at = NOW() 
                WHERE task_id = ?
            ");
            
            $result = $stmt->execute([$track['task_id']]);
            
            if ($result) {
                echo "   āš ļø Marked old track {$track['task_id']} as failed (was {$hoursOld} hours old)\n";
            } else {
                echo "   āŒ Failed to mark track {$track['task_id']} as failed\n";
            }
        } else {
            echo "   ā³ Track {$track['task_id']} is recent ({$hoursOld} hours old) - leaving as processing\n";
        }
    }
}

// Final status check
echo "\n6. Final status check...\n";
$stmt = $pdo->query("SELECT status, COUNT(*) as count FROM music_tracks GROUP BY status ORDER BY status");
$statusCounts = $stmt->fetchAll(PDO::FETCH_ASSOC);

foreach ($statusCounts as $status) {
    echo "   - {$status['status']}: {$status['count']} tracks\n";
}

echo "\nšŸŽ‰ Track fixing complete!\n";
echo "šŸ“ Check the database to confirm all tracks are properly updated.\n";
?>

CasperSecurity Mini