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/extract_all_existing_lyrics.php
<?php
require_once 'config/database.php';

echo "<h1>đŸŽĩ Extracting Lyrics for All Existing Tracks</h1>";

try {
    $pdo = getDBConnection();
    
    // Get all task result files
    $task_results_dir = 'task_results/';
    $json_files = glob($task_results_dir . '*.json');
    
    if (empty($json_files)) {
        echo "<p>❌ No task result files found</p>";
        exit;
    }
    
    echo "<p><strong>Found " . count($json_files) . " task result files</strong></p>";
    
    $tracks_updated = 0;
    $tracks_with_lyrics = 0;
    $tracks_no_lyrics = 0;
    $errors = [];
    
    echo "<h2>🔄 Processing Tracks...</h2>";
    
    foreach ($json_files as $json_file) {
        $task_id = basename($json_file, '.json');
        
        // Skip test files
        if (strpos($task_id, 'test') !== false || strpos($task_id, 'soundstudiopro') !== false) {
            continue;
        }
        
        echo "<div style='border: 1px solid #ccc; border-radius: 8px; padding: 15px; margin: 10px 0; background: #f9f9f9;'>";
        echo "<h3>đŸŽĩ Processing: $task_id</h3>";
        
        // Read the JSON file
        $json_content = file_get_contents($json_file);
        if (!$json_content) {
            echo "<p style='color: red;'>❌ Could not read file</p>";
            $errors[] = "Could not read $json_file";
            continue;
        }
        
        $data = json_decode($json_content, true);
        if (!$data) {
            echo "<p style='color: red;'>❌ Invalid JSON</p>";
            $errors[] = "Invalid JSON in $json_file";
            continue;
        }
        
        // Extract lyrics from the prompt field
        $lyrics = null;
        if (isset($data['data']['data']) && is_array($data['data']['data'])) {
            foreach ($data['data']['data'] as $item) {
                if (isset($item['prompt']) && !empty($item['prompt'])) {
                    $lyrics = $item['prompt'];
                    break;
                }
            }
        }
        
        if ($lyrics) {
            echo "<p style='color: green;'>✅ <strong>Found lyrics:</strong> " . strlen($lyrics) . " characters</p>";
            echo "<div style='background: #e8f5e8; padding: 10px; border-radius: 5px; margin: 5px 0; max-height: 200px; overflow-y: auto;'>";
            echo "<strong>Preview:</strong> " . htmlspecialchars(substr($lyrics, 0, 300)) . "...";
            echo "</div>";
            
            // Clean up lyrics (remove [Verse], [Chorus], etc.)
            $lyrics = str_replace(['[Verse]', '[Chorus]', '[Bridge]', '[Outro]', '[Intro]', '[Verse 1]', '[Verse 2]', '[Prechorus]'], '', $lyrics);
            $lyrics = preg_replace('/\[.*?\]/', '', $lyrics); // Remove any remaining [bracketed] content
            $lyrics = trim($lyrics);
            
            // Find the track in database by task_id
            $stmt = $pdo->prepare("SELECT id, title, lyrics FROM music_tracks WHERE task_id = ?");
            $stmt->execute([$task_id]);
            $track = $stmt->fetch();
            
            if ($track) {
                if (empty($track['lyrics'])) {
                    // Update the track with lyrics
                    $update_stmt = $pdo->prepare("UPDATE music_tracks SET lyrics = ? WHERE task_id = ?");
                    $result = $update_stmt->execute([$lyrics, $task_id]);
                    
                    if ($result) {
                        echo "<p style='color: green;'>✅ <strong>Updated track:</strong> {$track['title']} (ID: {$track['id']})</p>";
                        $tracks_updated++;
                        $tracks_with_lyrics++;
                    } else {
                        echo "<p style='color: red;'>❌ <strong>Failed to update:</strong> {$track['title']}</p>";
                        $errors[] = "Failed to update track {$track['id']}";
                    }
                } else {
                    echo "<p style='color: blue;'>â„šī¸ <strong>Already has lyrics:</strong> {$track['title']}</p>";
                    $tracks_with_lyrics++;
                }
            } else {
                echo "<p style='color: orange;'>âš ī¸ <strong>Track not found in database:</strong> $task_id</p>";
            }
        } else {
            echo "<p style='color: red;'>❌ <strong>No lyrics found</strong> in callback data</p>";
            $tracks_no_lyrics++;
        }
        
        echo "</div>";
    }
    
    echo "<h2>📊 Results Summary</h2>";
    echo "<div style='background: #f0f0f0; padding: 20px; border-radius: 8px; margin: 20px 0;'>";
    echo "<p><strong>Total files processed:</strong> " . count($json_files) . "</p>";
    echo "<p><strong>Tracks updated with lyrics:</strong> <span style='color: green;'>$tracks_updated</span></p>";
    echo "<p><strong>Tracks with lyrics (total):</strong> <span style='color: green;'>$tracks_with_lyrics</span></p>";
    echo "<p><strong>Tracks without lyrics:</strong> <span style='color: red;'>$tracks_no_lyrics</span></p>";
    
    if (!empty($errors)) {
        echo "<p><strong>Errors:</strong> <span style='color: red;'>" . count($errors) . "</span></p>";
        echo "<ul>";
        foreach ($errors as $error) {
            echo "<li style='color: red;'>$error</li>";
        }
        echo "</ul>";
    }
    echo "</div>";
    
    if ($tracks_updated > 0) {
        echo "<div style='background: #d4edda; border: 1px solid #c3e6cb; color: #155724; padding: 15px; border-radius: 8px; margin: 20px 0;'>";
        echo "<h3>🎉 Success!</h3>";
        echo "<p><strong>$tracks_updated tracks have been updated with lyrics!</strong></p>";
        echo "<p>You can now visit any track page to see the lyrics.</p>";
        echo "<p><a href='track.php?id=63' style='color: #155724; text-decoration: underline;'>← Test Track 63 (The Rest Is Ours)</a></p>";
        echo "</div>";
    }
    
} catch (Exception $e) {
    echo "<p style='color: red;'>❌ Error: " . htmlspecialchars($e->getMessage()) . "</p>";
}

echo "<hr>";
echo "<h2>đŸŽ¯ What This Script Did:</h2>";
echo "<p>1. <strong>Read all stored callback files</strong> from task_results/ directory</p>";
echo "<p>2. <strong>Extracted lyrics</strong> from the 'prompt' field in each file</p>";
echo "<p>3. <strong>Updated your database</strong> with the extracted lyrics</p>";
echo "<p>4. <strong>Cleaned up formatting</strong> (removed [Verse], [Chorus], etc.)</p>";
echo "<p>5. <strong>Provided results summary</strong> of what was updated</p>";
?>

CasperSecurity Mini