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/admin_sync_kat_zen_track.php
<?php
/**
 * Manual sync script for Kat Zen's stuck track
 * This will check API.Box status and update the track if complete
 */

session_start();
require_once 'config/database.php';

// Check if admin
if (!isset($_SESSION['is_admin']) || !$_SESSION['is_admin']) {
    die("Admin access required");
}

$pdo = getDBConnection();

echo "<h2>Kat Zen Track Sync</h2>";
echo "<style>
    body { font-family: Arial; padding: 20px; background: #1a1a1a; color: white; }
    table { border-collapse: collapse; width: 100%; margin: 20px 0; background: #2a2a2a; }
    th, td { border: 1px solid #444; padding: 10px; text-align: left; }
    th { background: #667eea; color: white; }
    .success { color: #48bb78; }
    .error { color: #e53e3e; }
    .warning { color: #ffc107; }
    .info { color: #667eea; }
    pre { background: #2a2a2a; padding: 10px; border-radius: 5px; overflow-x: auto; }
</style>";

// Find Kat Zen's processing track
$stmt = $pdo->prepare("
    SELECT id, title, task_id, status, audio_url, created_at
    FROM music_tracks 
    WHERE user_id = (SELECT id FROM users WHERE name LIKE '%Kat%Zen%' OR name LIKE '%katzen%' LIMIT 1)
    AND status = 'processing'
    ORDER BY created_at DESC
    LIMIT 5
");
$stmt->execute();
$tracks = $stmt->fetchAll(PDO::FETCH_ASSOC);

if (empty($tracks)) {
    echo "<p class='info'>No processing tracks found for Kat Zen</p>";
    exit;
}

echo "<h3>Found " . count($tracks) . " processing track(s)</h3>";

$api_key = '63edba40620216c5aa2c04240ac41dbd';

foreach ($tracks as $track) {
    echo "<hr>";
    echo "<h3>Track ID: {$track['id']} | Task ID: {$track['task_id']}</h3>";
    echo "<p>Title: " . htmlspecialchars($track['title'] ?: 'N/A') . "</p>";
    echo "<p>Status: <span class='warning'>{$track['status']}</span></p>";
    echo "<p>Created: {$track['created_at']}</p>";
    
    if (empty($track['task_id'])) {
        echo "<p class='error'>✗ No task_id found - cannot sync</p>";
        continue;
    }
    
    // Check API.Box status
    echo "<h4>Checking API.Box Status...</h4>";
    $api_url = "https://api.api.box/api/v1/status/{$track['task_id']}";
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $api_url);
    curl_setopt($ch, CURLOPT_HTTPGET, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Authorization: Bearer ' . $api_key,
        'Content-Type: application/json',
        'User-Agent: SoundStudioPro-Sync/1.0'
    ]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    
    $response = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $curl_error = curl_error($ch);
    curl_close($ch);
    
    if ($curl_error) {
        echo "<p class='error'>✗ cURL Error: $curl_error</p>";
        continue;
    }
    
    if ($http_code !== 200) {
        echo "<p class='error'>✗ API.Box returned HTTP $http_code</p>";
        echo "<pre>" . htmlspecialchars($response) . "</pre>";
        continue;
    }
    
    $api_data = json_decode($response, true);
    
    if (!$api_data) {
        echo "<p class='error'>✗ Invalid JSON response from API.Box</p>";
        echo "<pre>" . htmlspecialchars($response) . "</pre>";
        continue;
    }
    
    echo "<p class='info'>✓ API.Box Response:</p>";
    echo "<pre>" . htmlspecialchars(json_encode($api_data, JSON_PRETTY_PRINT)) . "</pre>";
    
    // Check status
    $api_status = $api_data['data']['status'] ?? null;
    $audio_url = $api_data['data']['audioUrl'] ?? null;
    $video_url = $api_data['data']['videoUrl'] ?? null;
    $title = $api_data['data']['title'] ?? null;
    $duration = $api_data['data']['duration'] ?? null;
    $tags = $api_data['data']['tags'] ?? null;
    $model_name = $api_data['data']['modelName'] ?? null;
    $image_url = $api_data['data']['imageUrl'] ?? null;
    $lyrics = $api_data['data']['lyrics'] ?? null;
    
    echo "<h4>Extracted Data:</h4>";
    echo "<ul>";
    echo "<li>Status: <strong>" . ($api_status ?: 'N/A') . "</strong></li>";
    echo "<li>Audio URL: " . ($audio_url ? 'YES' : 'NO') . "</li>";
    echo "<li>Video URL: " . ($video_url ? 'YES' : 'NO') . "</li>";
    echo "<li>Title: " . ($title ?: 'N/A') . "</li>";
    echo "<li>Duration: " . ($duration ?: 'N/A') . "</li>";
    echo "</ul>";
    
    if ($api_status === 'complete' && $audio_url) {
        echo "<p class='success'>✓ Track is complete in API.Box! Updating database...</p>";
        
        // Update track using the callback logic
        require_once 'callback.php';
        
        // Simulate callback data
        $callback_data = [
            'taskId' => $track['task_id'],
            'status' => 'complete',
            'audioUrl' => $audio_url,
            'videoUrl' => $video_url,
            'title' => $title,
            'duration' => $duration,
            'tags' => $tags,
            'modelName' => $model_name,
            'imageUrl' => $image_url,
            'lyrics' => $lyrics
        ];
        
        // Use updateMusicTrack function
        try {
            $pdo->beginTransaction();
            
            // Download and store audio locally
            $localAudioUrl = null;
            if ($audio_url) {
                $localAudioUrl = downloadAndStoreAudio($audio_url, $track['task_id'], 'main');
                echo "<p>Downloaded audio: " . ($localAudioUrl ?: 'failed') . "</p>";
            }
            
            // Download and store image locally
            $localImageUrl = null;
            if ($image_url) {
                $localImageUrl = downloadAndStoreImage($image_url, $track['task_id']);
                echo "<p>Downloaded image: " . ($localImageUrl ?: 'failed') . "</p>";
            }
            
            // Update track
            $metadata = json_encode([
                'tags' => $tags,
                'modelName' => $model_name,
                'synced_at' => date('Y-m-d H:i:s'),
                'synced_manually' => true
            ]);
            
            $result = updateMusicTrack(
                $track['task_id'],
                'complete',
                $localAudioUrl ?: $audio_url,
                $video_url ? downloadAndStoreAudio($video_url, $track['task_id'], 'video') : null,
                $lyrics,
                $metadata,
                $duration,
                $title,
                $tags,
                $model_name,
                $localImageUrl
            );
            
            if ($result) {
                $pdo->commit();
                echo "<p class='success'>✅ Track updated successfully!</p>";
                echo "<p><a href='/library.php' style='color: #667eea;'>View in Library</a> | ";
                echo "<a href='/track.php?id={$track['id']}' style='color: #667eea;'>View Track</a></p>";
            } else {
                $pdo->rollBack();
                echo "<p class='error'>✗ Failed to update track</p>";
            }
        } catch (Exception $e) {
            $pdo->rollBack();
            echo "<p class='error'>✗ Error: " . htmlspecialchars($e->getMessage()) . "</p>";
            echo "<pre>" . htmlspecialchars($e->getTraceAsString()) . "</pre>";
        }
    } elseif ($api_status === 'processing') {
        echo "<p class='warning'>⚠ Track is still processing in API.Box</p>";
        echo "<p>Please wait for the callback to complete, or check again later.</p>";
    } elseif ($api_status === 'failed') {
        echo "<p class='error'>✗ Track failed in API.Box</p>";
        
        // Update track status to failed
        try {
            $stmt = $pdo->prepare("UPDATE music_tracks SET status = 'failed', updated_at = NOW() WHERE id = ?");
            $stmt->execute([$track['id']]);
            echo "<p class='info'>✓ Updated track status to 'failed'</p>";
        } catch (Exception $e) {
            echo "<p class='error'>✗ Error updating status: " . htmlspecialchars($e->getMessage()) . "</p>";
        }
    } else {
        echo "<p class='warning'>⚠ Unknown status: $api_status</p>";
    }
}

echo "<hr>";
echo "<p><a href='/admin.php?tab=tracks' style='color: #667eea;'>← Back to Admin</a> | ";
echo "<a href='/library.php' style='color: #667eea;'>View Library</a></p>";
?>


CasperSecurity Mini