<?php
/**
 * Download Deployment Packages
 */

if ($method === 'GET') {
    if ($id === 'php-package') {
        // Serve PHP/cPanel package
        $file = '/app/cpanel_php/epic-travel-php-cpanel.zip';
        
        if (!file_exists($file)) {
            jsonResponse(['error' => 'PHP package not found'], 404);
        }
        
        header('Content-Type: application/zip');
        header('Content-Disposition: attachment; filename="epic-travel-php-cpanel.zip"');
        header('Content-Length: ' . filesize($file));
        readfile($file);
        exit;
    }
    
    if ($id === 'list') {
        jsonResponse([
            'packages' => [
                [
                    'name' => 'PHP/cPanel Package',
                    'description' => 'Standard cPanel hosting with PHP & MySQL (No SSH/Python required)',
                    'size' => '790 KB',
                    'download_url' => '/api/download/php-package',
                    'requirements' => ['PHP 7.4+', 'MySQL 5.7+', 'cPanel', 'FTP/File Manager access']
                ]
            ]
        ]);
    }
}

jsonResponse(['error' => 'Invalid download endpoint'], 404);
