{"html":"<!DOCTYPE html><html lang=\"en\"><head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Gaming Website - Unified Installation with Python Support</title>\n    <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css\" rel=\"stylesheet\">\n    <link href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css\" rel=\"stylesheet\">\n    <style>\n        body {\n            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n            min-height: 100vh;\n            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n        }\n\n        .install-container {\n            max-width: 700px;\n            margin: 30px auto;\n            padding: 20px;\n        }\n\n        .install-card {\n            background: white;\n            border-radius: 15px;\n            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);\n            overflow: hidden;\n        }\n\n        .install-header {\n            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n            color: white;\n            padding: 30px;\n            text-align: center;\n        }\n\n        .install-body {\n            padding: 30px;\n        }\n\n        .step-indicator {\n            display: flex;\n            justify-content: center;\n            margin-bottom: 30px;\n        }\n\n        .step {\n            width: 40px;\n            height: 40px;\n            border-radius: 50%;\n            background: #e9ecef;\n            display: flex;\n            align-items: center;\n            justify-content: center;\n            margin: 0 8px;\n            font-weight: bold;\n            color: #6c757d;\n            font-size: 14px;\n        }\n\n        .step.active {\n            background: #667eea;\n            color: white;\n        }\n\n        .step.completed {\n            background: #28a745;\n            color: white;\n        }\n\n        .progress {\n            height: 6px;\n            margin-bottom: 20px;\n        }\n\n        .requirement-item {\n            display: flex;\n            align-items: center;\n            padding: 12px;\n            margin: 8px 0;\n            border-radius: 8px;\n            background: #f8f9fa;\n        }\n\n        .requirement-item.passed {\n            background: #d4edda;\n            color: #155724;\n        }\n\n        .requirement-item.failed {\n            background: #f8d7da;\n            color: #721c24;\n        }\n\n        .requirement-item.optional {\n            background: #fff3cd;\n            color: #856404;\n        }\n\n        .btn-primary {\n            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n            border: none;\n        }\n\n        .btn-primary:hover {\n            background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);\n        }\n\n        .python-setup-card {\n            border: 2px solid #ffc107;\n            border-radius: 10px;\n            padding: 20px;\n            margin: 20px 0;\n            background: #fff8e1;\n        }\n\n        .python-option {\n            border: 1px solid #dee2e6;\n            border-radius: 8px;\n            padding: 15px;\n            margin: 10px 0;\n            cursor: pointer;\n            transition: all 0.3s ease;\n        }\n\n        .python-option:hover {\n            border-color: #667eea;\n            background: #f8f9ff;\n        }\n\n        .python-option.selected {\n            border-color: #667eea;\n            background: #e3f2fd;\n        }\n\n        .feature-badge {\n            background: #e3f2fd;\n            color: #1976d2;\n            padding: 4px 8px;\n            border-radius: 12px;\n            font-size: 12px;\n            margin: 2px;\n        }\n\n        .spinner-border-sm {\n            width: 1rem;\n            height: 1rem;\n        }\n\n        .log-output {\n            background: #1e1e1e;\n            color: #00ff00;\n            font-family: 'Courier New', monospace;\n            font-size: 12px;\n            max-height: 300px;\n            overflow-y: auto;\n            padding: 15px;\n            border-radius: 8px;\n        }\n    </style>\n</head>\n\n<body>\n    <div class=\"install-container\">\n        <div class=\"install-card\">\n            <div class=\"install-header\">\n                <div style=\"font-size: 3rem; margin-bottom: 20px;\">🎮</div>\n                <h2>Gaming Website - Unified Installation</h2>\n                <p class=\"mb-0\">Complete setup with Python Image Processor support</p>\n            </div>\n\n            <div class=\"install-body\">\n                <!-- Step Indicator -->\n                <div class=\"step-indicator\">\n                    <div class=\"step active\">1</div>\n                    <div class=\"step \">2</div>\n                    <div class=\"step \">3</div>\n                    <div class=\"step \">4</div>\n                    <div class=\"step \">5</div>\n                    <div class=\"step \">6</div>\n                </div>\n\n                <!-- Progress Bar -->\n                                <div class=\"progress mb-4\">\n                    <div class=\"progress-bar\" style=\"width: 15%\"></div>\n                </div>\n\n                <!-- Messages -->\n                \n                \n                <!-- Installation Steps -->\n                                    <div class=\"text-center\">\n                        <h3>Welcome to Enhanced Gaming Website!</h3>\n                        <p class=\"text-muted\">This unified installer will set up your complete gaming platform with Python image processing support.</p>\n\n                        <div class=\"bg-light rounded p-4 my-4\">\n                            <h5><i class=\"fas fa-star text-warning\"></i> Enhanced Features</h5>\n                            <div class=\"row text-start\">\n                                <div class=\"col-md-6\">\n                                    <ul class=\"list-unstyled\">\n                                        <li><i class=\"fas fa-check text-success\"></i> Advanced SEO helper functions</li>\n                                        <li><i class=\"fas fa-check text-success\"></i> Page helper utilities</li>\n                                        <li><i class=\"fas fa-check text-success\"></i> Enhanced configuration system</li>\n                                        <li><i class=\"fas fa-check text-success\"></i> Performance optimizations</li>\n                                    </ul>\n                                </div>\n                                <div class=\"col-md-6\">\n                                    <ul class=\"list-unstyled\">\n                                        <li><i class=\"fas fa-python text-warning\"></i> Python image processor</li>\n                                        <li><i class=\"fas fa-check text-success\"></i> AVIF &amp; WebP support</li>\n                                        <li><i class=\"fas fa-check text-success\"></i> Automatic fallback to PHP</li>\n                                        <li><i class=\"fas fa-check text-success\"></i> Enhanced compression</li>\n                                    </ul>\n                                </div>\n                            </div>\n\n                            <div class=\"mt-3\">\n                                <span class=\"feature-badge\">Helper Functions</span>\n                                <span class=\"feature-badge\">SEO Optimization</span>\n                                <span class=\"feature-badge\">Python Processing</span>\n                                <span class=\"feature-badge\">AVIF Support</span>\n                                <span class=\"feature-badge\">Performance</span>\n                            </div>\n                        </div>\n\n                        <a href=\"?step=requirements\" class=\"btn btn-primary btn-lg\">\n                            <i class=\"fas fa-arrow-right\"></i> Start Enhanced Setup\n                        </a>\n                    </div>\n\n                            </div>\n        </div>\n    </div>\n\n    <script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js\"></script>\n    <script>\n        // Enhanced installer JavaScript\n        class UnifiedInstaller {\n            constructor() {\n                this.init();\n            }\n\n            init() {\n                this.setupFormValidation();\n\n                // Python setup page specific functionality\n                if (window.location.search.includes('step=python-setup')) {\n                    this.initPythonSetup();\n                }\n            }\n\n            setupFormValidation() {\n                const forms = document.querySelectorAll('.needs-validation');\n                Array.from(forms).forEach(form => {\n                    form.addEventListener('submit', event => {\n                        if (!form.checkValidity()) {\n                            event.preventDefault();\n                            event.stopPropagation();\n                        }\n                        form.classList.add('was-validated');\n                    }, false);\n                });\n\n                // Password confirmation\n                const password = document.getElementById('admin_password');\n                const confirmPassword = document.getElementById('admin_password_confirm');\n\n                if (password && confirmPassword) {\n                    function validatePasswords() {\n                        if (password.value !== confirmPassword.value) {\n                            confirmPassword.setCustomValidity('Passwords do not match');\n                        } else {\n                            confirmPassword.setCustomValidity('');\n                        }\n                    }\n                    password.addEventListener('input', validatePasswords);\n                    confirmPassword.addEventListener('input', validatePasswords);\n                }\n            }\n\n            async initPythonSetup() {\n                // Check Python status first\n                await this.checkPythonStatus();\n\n                // Setup option selection\n                this.setupPythonOptions();\n\n                // Setup form submission\n                this.setupPythonForm();\n            }\n\n            async checkPythonStatus() {\n                try {\n                    const response = await fetch('?action=check_python_status');\n                    const result = await response.json();\n\n                    this.displayPythonStatus(result);\n\n                } catch (error) {\n                    this.displayPythonError('Failed to check Python status: ' + error.message);\n                }\n            }\n\n            displayPythonStatus(result) {\n                const statusDiv = document.getElementById('python-status-check');\n                const optionsDiv = document.getElementById('python-setup-options');\n\n                if (result.success) {\n                    let statusHtml = '';\n\n                    if (result.python_available) {\n                        statusHtml = `\n                            <div class=\"alert alert-success\">\n                                <i class=\"fas fa-python text-warning\"></i>\n                                <strong>Python Ready!</strong> \n                                ${result.status.python.python_version} detected with all dependencies.\n                            </div>\n                        `;\n\n                        // Pre-select auto installation\n                        setTimeout(() => {\n                            const autoOption = document.getElementById('auto-setup');\n                            if (autoOption) {\n                                autoOption.checked = true;\n                                this.selectPythonOption('auto');\n                            }\n                        }, 100);\n\n                    } else {\n                        const errorMsg = result.status.python.error || 'Python not available';\n                        statusHtml = `\n                            <div class=\"alert alert-warning\">\n                                <i class=\"fas fa-exclamation-triangle\"></i>\n                                <strong>Python Issue:</strong> ${errorMsg}\n                            </div>\n                        `;\n\n                        // Pre-select skip if Python not available\n                        setTimeout(() => {\n                            const skipOption = document.getElementById('skip-setup');\n                            if (skipOption) {\n                                skipOption.checked = true;\n                                this.selectPythonOption('skip');\n                            }\n                        }, 100);\n                    }\n\n                    statusDiv.innerHTML = statusHtml;\n                    optionsDiv.style.display = 'block';\n\n                } else {\n                    this.displayPythonError(result.error || 'Unknown error');\n                }\n            }\n\n            displayPythonError(message) {\n                const statusDiv = document.getElementById('python-status-check');\n                statusDiv.innerHTML = `\n                    <div class=\"alert alert-danger\">\n                        <i class=\"fas fa-times-circle\"></i>\n                        <strong>Error:</strong> ${message}\n                    </div>\n                `;\n\n                // Show options anyway but pre-select skip\n                document.getElementById('python-setup-options').style.display = 'block';\n                setTimeout(() => {\n                    const skipOption = document.getElementById('skip-setup');\n                    if (skipOption) {\n                        skipOption.checked = true;\n                        this.selectPythonOption('skip');\n                    }\n                }, 100);\n            }\n\n            setupPythonOptions() {\n                const options = document.querySelectorAll('.python-option');\n                const setupBtn = document.getElementById('python-setup-btn');\n\n                options.forEach(option => {\n                    option.addEventListener('click', () => {\n                        const optionType = option.dataset.option;\n                        const radio = option.querySelector('input[type=\"radio\"]');\n\n                        if (radio) {\n                            radio.checked = true;\n                            this.selectPythonOption(optionType);\n                        }\n                    });\n                });\n\n                // Radio button change events\n                const radioButtons = document.querySelectorAll('input[name=\"python_setup_type\"]');\n                radioButtons.forEach(radio => {\n                    radio.addEventListener('change', () => {\n                        if (radio.checked) {\n                            this.selectPythonOption(radio.value);\n                        }\n                    });\n                });\n            }\n\n            selectPythonOption(optionType) {\n                // Update UI\n                const options = document.querySelectorAll('.python-option');\n                options.forEach(option => {\n                    option.classList.remove('selected');\n                });\n\n                const selectedOption = document.querySelector(`[data-option=\"${optionType}\"]`);\n                if (selectedOption) {\n                    selectedOption.classList.add('selected');\n                }\n\n                // Update button\n                const setupBtn = document.getElementById('python-setup-btn');\n                const buttonTexts = {\n                    'auto': '<i class=\"fas fa-download\"></i> Install Python Dependencies',\n                    'manual': '<i class=\"fas fa-arrow-right\"></i> Continue with Manual Setup',\n                    'skip': '<i class=\"fas fa-arrow-right\"></i> Skip & Use PHP Processing'\n                };\n\n                if (setupBtn) {\n                    setupBtn.disabled = false;\n                    setupBtn.innerHTML = buttonTexts[optionType] || '<i class=\"fas fa-arrow-right\"></i> Continue';\n                }\n            }\n\n            setupPythonForm() {\n                const form = document.getElementById('python-setup-form');\n                if (!form) return;\n\n                form.addEventListener('submit', async (e) => {\n                    const selectedOption = document.querySelector('input[name=\"python_setup_type\"]:checked');\n\n                    if (selectedOption && selectedOption.value === 'auto') {\n                        e.preventDefault();\n                        await this.performAutomaticInstallation();\n                    }\n                    // For manual and skip, let the form submit normally\n                });\n            }\n\n            async performAutomaticInstallation() {\n                this.showInstallationProgress();\n\n                try {\n                    const response = await fetch('?action=install_python_deps', {\n                        method: 'POST'\n                    });\n\n                    const result = await response.json();\n\n                    if (result.success) {\n                        this.updateInstallProgress(100, 'Installation completed successfully!');\n                        this.logOutput('✅ Python dependencies installed successfully!');\n\n                        if (result.output) {\n                            this.logOutput(result.output);\n                        }\n\n                        setTimeout(() => {\n                            window.location.href = '?step=complete';\n                        }, 2000);\n\n                    } else {\n                        this.updateInstallProgress(0, 'Installation failed');\n                        this.logOutput('❌ Installation failed: ' + result.error);\n\n                        if (result.output) {\n                            this.logOutput('\\nDetailed output:\\n' + result.output);\n                        }\n\n                        // Show option to continue anyway\n                        setTimeout(() => {\n                            this.showInstallationFallback();\n                        }, 3000);\n                    }\n\n                } catch (error) {\n                    this.updateInstallProgress(0, 'Network error during installation');\n                    this.logOutput('❌ Network error: ' + error.message);\n\n                    setTimeout(() => {\n                        this.showInstallationFallback();\n                    }, 3000);\n                }\n            }\n\n            showInstallationProgress() {\n                document.getElementById('python-setup-options').style.display = 'none';\n                document.getElementById('python-install-progress').style.display = 'block';\n\n                this.updateInstallProgress(10, 'Starting Python dependency installation...');\n            }\n\n            updateInstallProgress(percentage, status) {\n                const progressBar = document.getElementById('install-progress-bar');\n                const statusElement = document.getElementById('install-status');\n\n                if (progressBar) {\n                    progressBar.style.width = percentage + '%';\n                    progressBar.setAttribute('aria-valuenow', percentage);\n                }\n\n                if (statusElement) {\n                    statusElement.textContent = status;\n                }\n            }\n\n            logOutput(message) {\n                const logElement = document.getElementById('install-log');\n                if (logElement) {\n                    logElement.innerHTML += message + '\\n';\n                    logElement.scrollTop = logElement.scrollHeight;\n                }\n            }\n\n            showInstallationFallback() {\n                const progressDiv = document.getElementById('python-install-progress');\n                progressDiv.innerHTML += `\n                    <div class=\"alert alert-warning mt-3\">\n                        <strong>Installation Failed</strong><br>\n                        You can continue with PHP processing or try manual installation later.\n                        <div class=\"mt-2\">\n                            <a href=\"?step=complete\" class=\"btn btn-primary btn-sm\">\n                                Continue with PHP Processing\n                            </a>\n                            <button class=\"btn btn-outline-secondary btn-sm\" onclick=\"location.reload()\">\n                                Try Again\n                            </button>\n                        </div>\n                    </div>\n                `;\n            }\n        }\n\n        // Initialize when DOM is loaded\n        document.addEventListener('DOMContentLoaded', function() {\n            new UnifiedInstaller();\n        });\n    </script>\n<script defer=\"\" src=\"https://static.cloudflareinsights.com/beacon.min.js/v8c78df7c7c0f484497ecbca7046644da1771523124516\" integrity=\"sha512-8DS7rgIrAmghBFwoOTujcf6D9rXvH8xm8JQ1Ja01h9QX8EzXldiszufYa4IFfKdLUKTTrnSFXLDkUEOTrZQ8Qg==\" data-cf-beacon=\"{&quot;version&quot;:&quot;2024.11.0&quot;,&quot;token&quot;:&quot;9efc2991d6724724a7c8bc6539b48666&quot;,&quot;r&quot;:1,&quot;server_timing&quot;:{&quot;name&quot;:{&quot;cfCacheStatus&quot;:true,&quot;cfEdge&quot;:true,&quot;cfExtPri&quot;:true,&quot;cfL4&quot;:true,&quot;cfOrigin&quot;:true,&quot;cfSpeedBrain&quot;:true},&quot;location_startswith&quot;:null}}\" crossorigin=\"anonymous\"></script>\n\n\n</body></html>"}