(24 * 60 * 60)) { session_destroy(); header('Location: auth.php'); exit; } // Get page ID from URL $page_id = $_GET['id'] ?? null; $format = $_GET['format'] ?? 'view'; $mode = $_GET['mode'] ?? 'preview'; // preview or edit if (!$page_id) { die('Page ID is required.'); } // Handle save request if ($_SERVER['REQUEST_METHOD'] === 'POST' && $format === 'save') { $updated_content = json_decode(file_get_contents('php://input'), true); if ($updated_content) { $_SESSION['generated_pages'][$page_id]['generated_content'] = array_merge( $_SESSION['generated_pages'][$page_id]['generated_content'], $updated_content['content'] ?? [] ); if (isset($updated_content['settings'])) { $_SESSION['generated_pages'][$page_id]['settings'] = $updated_content['settings']; } header('Content-Type: application/json'); echo json_encode(['success' => true]); exit; } } // Get stored content $complete_data = $_SESSION['generated_pages'][$page_id] ?? null; if (!$complete_data) { die('Landing page not found. Please generate a new landing page.'); } $form_data = $complete_data['form_data']; $content = $complete_data['generated_content']; $settings = $complete_data['settings'] ?? []; // Handle different format requests if ($format === 'download') { // Generate standalone HTML file for download $html_content = generatePremiumLandingPage($content, $form_data, $settings, true, false); // Set headers for file download $filename = 'landing-page-' . date('Y-m-d-H-i-s') . '.html'; header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Length: ' . strlen($html_content)); echo $html_content; exit; } if ($format === 'raw') { // Return raw HTML for copying header('Content-Type: text/plain'); echo generatePremiumLandingPage($content, $form_data, $settings, true, false); exit; } // Generate the premium landing page HTML function generatePremiumLandingPage($content, $form_data, $settings, $standalone = false, $editMode = false) { $tracking_code = $form_data['tracking_code'] ?? ''; $affiliate_link = $form_data['affiliate_link'] ?? '#'; // Default settings $primaryColor = $settings['primaryColor'] ?? '#667eea'; $secondaryColor = $settings['secondaryColor'] ?? '#764ba2'; $ctaColor = $settings['ctaColor'] ?? '#4facfe'; $fontFamily = $settings['fontFamily'] ?? 'Inter'; // Ensure content has values with enhanced defaults $headline = $content['headline'] ?? 'Transform Your Digital Presence Today'; $subheadline = $content['subheadline'] ?? 'Join thousands who have revolutionized their success'; $hero_content = $content['hero_content'] ?? 'Discover the game-changing platform that industry leaders use to accelerate their growth and achieve unprecedented results.'; $problem_agitation = $content['problem_agitation'] ?? 'Struggling with outdated methods that drain your time and energy? You\'re not alone in feeling overwhelmed by ineffective solutions.'; $solution_intro = $content['solution_intro'] ?? 'Our revolutionary approach eliminates the guesswork and delivers results that speak for themselves.'; $benefits_list = $content['benefits_list'] ?? "• Accelerate your growth with proven strategies\n• Access exclusive tools and resources\n• Get results in record time\n• Join a community of achievers\n• Risk-free guarantee included"; $social_proof = $content['social_proof'] ?? 'Join over 50,000 successful professionals who have transformed their results.'; $urgency_section = $content['urgency_section'] ?? 'Limited spots available. Secure your access today before this opportunity closes.'; $risk_reversal = $content['risk_reversal'] ?? 'Try risk-free with our 60-day money-back guarantee. Your success is our commitment.'; $final_cta = $content['final_cta'] ?? 'Start Today'; $editClass = $editMode ? 'edit-mode' : ''; $editAttr = $editMode ? 'contenteditable="true"' : ''; $html = '
Get an exclusive 25% discount if you act now!
' . htmlspecialchars($subheadline) . '
' . nl2br(htmlspecialchars($hero_content)) . '
Experience the difference that sets us apart
See immediate improvements from day one with our proven system.
Get unlimited access to all features and future updates forever.
Our expert team is available 24/7 to ensure your success.
You\'re not alone in facing these challenges
' . nl2br(htmlspecialchars($problem_agitation)) . '
Everything changes when you have the right system
' . nl2br(htmlspecialchars($solution_intro)) . '
Transform your results with these powerful benefits
' . $description . '
Join thousands who have transformed their lives
' . nl2br(htmlspecialchars($urgency_section)) . '
' . nl2br(htmlspecialchars($risk_reversal)) . '
Join thousands of people who have already discovered this life-changing opportunity.
' . htmlspecialchars($final_cta) . '🔒 Secure checkout • ✅ Instant access • 💰 Money-back guarantee