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/fetch_existing_lyrics.php
<?php
// Fetch Existing Lyrics Script
// Gets lyrics that were already generated but not saved during callback

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

require_once 'config/database.php';

// Logging
$logFile = 'fetch_lyrics_log.txt';
function logMessage($message) {
    global $logFile;
    $timestamp = date('Y-m-d H:i:s');
    $logEntry = "[$timestamp] $message\n";
    file_put_contents($logFile, $logEntry, FILE_APPEND | LOCK_EX);
    echo $logEntry;
}

// Function to fetch lyrics from API using task_id
function fetchLyricsFromAPI($taskId) {
    $apiUrl = "https://api.api.box/api/v1/result/$taskId";
    
    $headers = [
        'Authorization: Bearer 63edba40620216c5aa2c04240ac41dbd',
        'User-Agent: SoundStudioPro/1.0'
    ];
    
    $context = stream_context_create([
        'http' => [
            'method' => 'GET',
            'header' => implode("\r\n", $headers),
            'timeout' => 30
        ]
    ]);
    
    $response = file_get_contents($apiUrl, false, $context);
    
    if ($response === false) {
        return null;
    }
    
    $data = json_decode($response, true);
    
    // Extract lyrics from various possible locations in API.box response
    if (isset($data['data']['lyrics'])) {
        return $data['data']['lyrics'];
    } elseif (isset($data['data']['text'])) {
        return $data['data']['text'];
    } elseif (isset($data['lyrics'])) {
        return $data['lyrics'];
    } elseif (isset($data['text'])) {
        return $data['text'];
    }
    
    return null;
}

// Function to update track with lyrics
function updateTrackLyrics($trackId, $lyrics) {
    $pdo = getDBConnection();
    if (!$pdo) return false;
    
    try {
        $stmt = $pdo->prepare("
            UPDATE music_tracks 
            SET lyrics = ?, updated_at = CURRENT_TIMESTAMP 
            WHERE id = ?
        ");
        
        return $stmt->execute([$lyrics, $trackId]);
        
    } catch (Exception $e) {
        logMessage("Database error: " . $e->getMessage());
        return false;
    }
}

// Main execution
logMessage("=== FETCHING EXISTING LYRICS ===");

$pdo = getDBConnection();
if (!$pdo) {
    logMessage("ERROR: Cannot connect to database");
    exit(1);
}

// Get tracks without lyrics
try {
    $stmt = $pdo->prepare("
        SELECT id, title, task_id, status
        FROM music_tracks 
        WHERE (lyrics IS NULL OR lyrics = '') 
        AND status = 'complete'
        AND task_id IS NOT NULL
        AND task_id != ''
        ORDER BY created_at DESC
    ");
    
    $stmt->execute();
    $tracksWithoutLyrics = $stmt->fetchAll();
    
    $totalTracks = count($tracksWithoutLyrics);
    logMessage("Found $totalTracks tracks without lyrics");
    
    if ($totalTracks === 0) {
        logMessage("No tracks found without lyrics!");
        exit(0);
    }
    
    $successCount = 0;
    $errorCount = 0;
    
    foreach ($tracksWithoutLyrics as $track) {
        logMessage("Processing track {$track['id']}: {$track['title']} (Task: {$track['task_id']})");
        
        // Fetch lyrics from API using task_id
        $lyrics = fetchLyricsFromAPI($track['task_id']);
        
        if ($lyrics) {
            // Clean up lyrics
            $lyrics = str_replace(['[Verse]', '[Chorus]', '[Bridge]', '[Outro]', '[Intro]'], '', $lyrics);
            $lyrics = preg_replace('/\[.*?\]/', '', $lyrics);
            $lyrics = trim($lyrics);
            
            // Update track
            if (updateTrackLyrics($track['id'], $lyrics)) {
                $successCount++;
                logMessage("✅ Added lyrics to track {$track['id']}");
            } else {
                $errorCount++;
                logMessage("❌ Failed to update track {$track['id']}");
            }
        } else {
            $errorCount++;
            logMessage("❌ No lyrics found for track {$track['id']}");
        }
        
        // Small delay to avoid overwhelming the API
        sleep(1);
    }
    
    // Summary
    logMessage("=== COMPLETE ===");
    logMessage("Total: $totalTracks, Success: $successCount, Errors: $errorCount");
    
} catch (Exception $e) {
    logMessage("ERROR: " . $e->getMessage());
    exit(1);
}

logMessage("=== SCRIPT COMPLETED ===");
?> 

CasperSecurity Mini