From 1fddc19e3beab64c84240ec34007cedda2cd7c02 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 1 Dec 2025 04:45:28 +0000 Subject: [PATCH] v1.2 --- admin/cron.php | 32 ++++ assets/images/favicon.svg | 4 + db/setup.php | 20 +++ editor_13d84da0257b8680.php | 302 +++++++++++++++++++++++++++++++++++ index.php | 256 ++++------------------------- login.php | 52 ------ logout.php | 7 - manage.php | 44 +++++ publish.php | 147 +++++++++++++++++ published/692d0999922fe.html | 169 ++++++++++++++++++++ published/692d09f4de19e.html | 169 ++++++++++++++++++++ published/692d1417bdebb.html | 169 ++++++++++++++++++++ published/692d16ba3ef57.html | 169 ++++++++++++++++++++ published/692d17547bd50.html | 169 ++++++++++++++++++++ 14 files changed, 1423 insertions(+), 286 deletions(-) create mode 100644 admin/cron.php create mode 100644 assets/images/favicon.svg create mode 100644 db/setup.php create mode 100644 editor_13d84da0257b8680.php delete mode 100644 login.php delete mode 100644 logout.php create mode 100644 manage.php create mode 100644 publish.php create mode 100644 published/692d0999922fe.html create mode 100644 published/692d09f4de19e.html create mode 100644 published/692d1417bdebb.html create mode 100644 published/692d16ba3ef57.html create mode 100644 published/692d17547bd50.html diff --git a/admin/cron.php b/admin/cron.php new file mode 100644 index 0000000..163a9b0 --- /dev/null +++ b/admin/cron.php @@ -0,0 +1,32 @@ +prepare("SELECT `id`, `filename` FROM `published_pages` WHERE `expires_at` < NOW()"); + $stmt->execute(); + $expired_pages = $stmt->fetchAll(); + + $deleted_count = 0; + foreach ($expired_pages as $page) { + $filepath = __DIR__ . '/../published/' . $page['filename']; + if (file_exists($filepath)) { + unlink($filepath); + } + + $delete_stmt = $pdo->prepare("DELETE FROM `published_pages` WHERE `id` = ?"); + $delete_stmt->execute([$page['id']]); + $deleted_count++; + } + + echo "Expired pages cleanup completed. $deleted_count pages deleted.\n"; + +} catch (PDOException $e) { + error_log("DB Error: " . $e->getMessage()); + die("An error occurred during cleanup.\n"); +} + diff --git a/assets/images/favicon.svg b/assets/images/favicon.svg new file mode 100644 index 0000000..f45158c --- /dev/null +++ b/assets/images/favicon.svg @@ -0,0 +1,4 @@ + + +G + diff --git a/db/setup.php b/db/setup.php new file mode 100644 index 0000000..67942a6 --- /dev/null +++ b/db/setup.php @@ -0,0 +1,20 @@ +exec($sql); + echo "Table `published_pages` created successfully or already exists.\n"; +} catch (PDOException $e) { + die("DB ERROR: " . $e->getMessage()); +} + diff --git a/editor_13d84da0257b8680.php b/editor_13d84da0257b8680.php new file mode 100644 index 0000000..30cdd71 --- /dev/null +++ b/editor_13d84da0257b8680.php @@ -0,0 +1,302 @@ +'; + + // Fetch CSS for inlining + $cssContent = file_get_contents('assets/css/custom.css'); + + // Prepare image for ZIP + $imageContent = @file_get_contents($imageUrl); + $imageFilename = basename(parse_url($imageUrl, PHP_URL_PATH)); + if (empty($imageFilename)) { + $imageFilename = 'featured-image.jpg'; + } + + // Generate the final HTML content from the selected template structure + $templateId = (int)($_POST['template_id'] ?? 1); + $selectedTemplate = null; + foreach ($templates as $t) { + if ($t['id'] === $templateId) { + $selectedTemplate = $t; + break; + } + } + + $templateHtml = $selectedTemplate ? file_get_contents($selectedTemplate['file']) : '
Ebook Cover

' . $title . '

' . $description . '

' . $checkoutHtml . '
'; + $templateDom = new DOMDocument(); + @$templateDom->loadHTML($templateHtml, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); + + $imgTag = $templateDom->getElementById('previewImage'); + if ($imgTag) $imgTag->setAttribute('src', $imageFilename); + + $titleTag = $templateDom->getElementById('previewTitle'); + if ($titleTag) $titleTag->nodeValue = $title; + + $descTag = $templateDom->getElementById('previewDescription'); + if ($descTag) $descTag->nodeValue = $description; + + $ctaContainer = $templateDom->getElementById('previewCtaContainer'); + if ($ctaContainer) { + // Clear existing content + while ($ctaContainer->hasChildNodes()) { + $ctaContainer->removeChild($ctaContainer->firstChild); + } + if (!empty(trim($checkoutHtml))) { + $fragment = $templateDom->createDocumentFragment(); + @$fragment->appendXML($checkoutHtml); + $ctaContainer->appendChild($fragment); + } else { + $ctaContainer->nodeValue = $ctaText; // Fallback to simple text if no HTML + } + } + + $finalPreviewHtml = $templateDom->saveHTML(); + + + $htmlContent = << + + + + + $title + + + + +
+
+
+ $finalPreviewHtml +
+
+
+ + + +HTML; + + // Create a Zip archive + $zip = new ZipArchive(); + $zipFileName = tempnam(sys_get_temp_dir(), 'ebook') . '.zip'; + if ($zip->open($zipFileName, ZipArchive::CREATE) === TRUE) { + $zip->addFromString('index.html', $htmlContent); + if ($imageContent) { + $zip->addFromString($imageFilename, $imageContent); + } + $zip->close(); + + // Force download + header('Content-Type: application/zip'); + header('Content-Disposition: attachment; filename="ebook_page.zip"'); + header('Content-Length: ' . filesize($zipFileName)); + readfile($zipFileName); + unlink($zipFileName); + exit; + } else { + error_log('Failed to create the ZIP file.'); + exit('Could not create ZIP file.'); + } +} + +$template_id = isset($_GET['template_id']) ? (int)$_GET['template_id'] : null; +$selectedTemplate = null; +$templateContent = ''; + +if ($template_id) { + foreach ($templates as $t) { + if ($t['id'] === $template_id) { + $selectedTemplate = $t; + break; + } + } + if ($selectedTemplate && file_exists($selectedTemplate['file'])) { + $templateContent = file_get_contents($selectedTemplate['file']); + } else { + $template_id = null; // Reset if template not found + } +} + +// Read project preview data from environment +$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Create and customize your own ebook landing page.'; +$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; +?> + + + + + + Ebook Lead Magnet Generator + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+

Customize Your Page

+ ← Back to Home +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
This will replace the default button in the preview.
+
+
+ + +
+
+
+
+
+ + + +
+ +
+
+
+

How to Deploy Your Ebook Page

+

A simple guide to get your page online.

+
+
+
+
+
+ 1 +
+
Unzip the File
+

The file you downloaded is a ZIP archive. Unzip it to a folder on your computer. You will find an `index.html` file and an image file inside.

+
+
+
+
+
+ 2 +
+
Upload to Your Hosting
+

Log in to your web hosting control panel (like cPanel, Plesk, or others) or use an FTP client (like FileZilla). Upload the `index.html` file and the image file to the `public_html` or `www` directory of your domain.

+
+
+
+
+
+ 3 +
+
Visit Your Page
+

Once the files are uploaded, you should be able to visit your domain in your browser and see your new ebook landing page live.

+
+
+
+
+
+ + + + + + diff --git a/index.php b/index.php index 815b5a8..fee129e 100644 --- a/index.php +++ b/index.php @@ -4,142 +4,6 @@ declare(strict_types=1); @error_reporting(E_ALL); @date_default_timezone_set('UTC'); -require_once 'templates/data.php'; - -if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'download') { - // (The download logic remains the same) - // Sanitize and retrieve POST data - $title = htmlspecialchars($_POST['title'] ?? 'Your Awesome Ebook Title'); - $description = htmlspecialchars($_POST['description'] ?? 'A compelling description...'); - $imageUrl = filter_var($_POST['imageUrl'] ?? '', FILTER_VALIDATE_URL) ?: 'https://images.pexels.com/photos/1907785/pexels-photo-1907785.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1'; - $ctaText = htmlspecialchars($_POST['ctaText'] ?? 'Download Now'); - $checkoutHtml = $_POST['checkoutHtml'] ?? ''; - - // Fetch CSS for inlining - $cssContent = file_get_contents('assets/css/custom.css'); - - // Prepare image for ZIP - $imageContent = @file_get_contents($imageUrl); - $imageFilename = basename(parse_url($imageUrl, PHP_URL_PATH)); - if (empty($imageFilename)) { - $imageFilename = 'featured-image.jpg'; - } - - // Generate the final HTML content from the selected template structure - $templateId = (int)($_POST['template_id'] ?? 1); - $selectedTemplate = null; - foreach ($templates as $t) { - if ($t['id'] === $templateId) { - $selectedTemplate = $t; - break; - } - } - - $templateHtml = $selectedTemplate ? file_get_contents($selectedTemplate['file']) : '
Ebook Cover

' . $title . '

' . $description . '

' . $checkoutHtml . '
'; - $templateDom = new DOMDocument(); - @$templateDom->loadHTML($templateHtml, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); - - $imgTag = $templateDom->getElementById('previewImage'); - if ($imgTag) $imgTag->setAttribute('src', $imageFilename); - - $titleTag = $templateDom->getElementById('previewTitle'); - if ($titleTag) $titleTag->nodeValue = $title; - - $descTag = $templateDom->getElementById('previewDescription'); - if ($descTag) $descTag->nodeValue = $description; - - $ctaContainer = $templateDom->getElementById('previewCtaContainer'); - if ($ctaContainer) { - // Clear existing content - while ($ctaContainer->hasChildNodes()) { - $ctaContainer->removeChild($ctaContainer->firstChild); - } - if (!empty(trim($checkoutHtml))) { - $fragment = $templateDom->createDocumentFragment(); - @$fragment->appendXML($checkoutHtml); - $ctaContainer->appendChild($fragment); - } else { - $ctaContainer->nodeValue = $ctaText; // Fallback to simple text if no HTML - } - } - - $finalPreviewHtml = $templateDom->saveHTML(); - - - $htmlContent = << - - - - - $title - - - - -
-
-
- $finalPreviewHtml -
-
-
- - - -HTML; - - // Create a Zip archive - $zip = new ZipArchive(); - $zipFileName = tempnam(sys_get_temp_dir(), 'ebook') . '.zip'; - if ($zip->open($zipFileName, ZipArchive::CREATE) === TRUE) { - $zip->addFromString('index.html', $htmlContent); - if ($imageContent) { - $zip->addFromString($imageFilename, $imageContent); - } - $zip->close(); - - // Force download - header('Content-Type: application/zip'); - header('Content-Disposition: attachment; filename="ebook_page.zip"'); - header('Content-Length: ' . filesize($zipFileName)); - readfile($zipFileName); - unlink($zipFileName); - exit; - } else { - error_log('Failed to create the ZIP file.'); - exit('Could not create ZIP file.'); - } -} - -$template_id = isset($_GET['template_id']) ? (int)$_GET['template_id'] : null; -$selectedTemplate = null; -$templateContent = ''; - -if ($template_id) { - foreach ($templates as $t) { - if ($t['id'] === $template_id) { - $selectedTemplate = $t; - break; - } - } - if ($selectedTemplate && file_exists($selectedTemplate['file'])) { - $templateContent = file_get_contents($selectedTemplate['file']); - } else { - $template_id = null; // Reset if template not found - } -} - // Read project preview data from environment $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Create and customize your own ebook landing page.'; $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; @@ -147,25 +11,12 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; - - - Ebook Lead Magnet Generator - - - - - - - - - - - - - - - - + + + Your Landing Page + + + @@ -174,87 +25,38 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; Ebook Page Builder + -
- -
-
- -
-
+
+
+
+

Create Beautiful Ebook Landing Pages in Minutes

+

Our powerful and easy-to-use page builder helps you create stunning landing pages for your ebooks. No coding required. Start building your page today!

+ Purchase Access +
+
-
-
-
-

Customize Your Page

- ← Back to Gallery -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
This will replace the default button in the preview.
-
-
- -
-
-
+
+
+
+

Feature-Rich Editor

+

Choose from a variety of templates, customize your content, and see a live preview of your page as you build it. Our editor is designed to be intuitive and flexible.

-
- - - + +
- + - \ No newline at end of file diff --git a/login.php b/login.php deleted file mode 100644 index 24f6c84..0000000 --- a/login.php +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - Admin Login - - - - -
-
-
- -
-
-
- - \ No newline at end of file diff --git a/logout.php b/logout.php deleted file mode 100644 index 1779b21..0000000 --- a/logout.php +++ /dev/null @@ -1,7 +0,0 @@ - \ No newline at end of file diff --git a/manage.php b/manage.php new file mode 100644 index 0000000..5215fe6 --- /dev/null +++ b/manage.php @@ -0,0 +1,44 @@ +prepare("SELECT `id`, `expires_at` FROM `published_pages` WHERE `management_token` = ?"); + $stmt->execute([$token]); + $page = $stmt->fetch(); + + if ($page) { + $new_expires_at = date('Y-m-d H:i:s', strtotime('+60 days')); + $update_stmt = $pdo->prepare("UPDATE `published_pages` SET `expires_at` = ? WHERE `id` = ?"); + $update_stmt->execute([$new_expires_at, $page['id']]); + + echo "
"; + echo "

Success!

"; + echo "

Your page's lifetime has been extended by 60 days.

"; + echo "

New expiration date: " . $new_expires_at . "

"; + echo "
"; + } else { + echo "
"; + echo "

Error!

"; + echo "

Invalid management token.

"; + echo "
"; + } + } catch (PDOException $e) { + error_log("DB Error: " . $e->getMessage()); + echo "
"; + echo "

Error!

"; + echo "

An error occurred while processing your request.

"; + echo "
"; + } +} else { + header('Location: index.php'); + exit; +} + diff --git a/publish.php b/publish.php new file mode 100644 index 0000000..f86e1f3 --- /dev/null +++ b/publish.php @@ -0,0 +1,147 @@ +'; + + // Fetch CSS for inlining + $cssContent = file_get_contents('assets/css/custom.css'); + + // Prepare image for embedding or linking + $imageFilename = basename(parse_url($imageUrl, PHP_URL_PATH)); + if (empty($imageFilename)) { + $imageFilename = 'featured-image.jpg'; + } + + // Generate the final HTML content from the selected template structure + $templateId = (int)($_POST['template_id'] ?? 1); + $selectedTemplate = null; + foreach ($templates as $t) { + if ($t['id'] === $templateId) { + $selectedTemplate = $t; + break; + } + } + + $templateHtml = $selectedTemplate ? file_get_contents($selectedTemplate['file']) : '
Ebook Cover

' . $title . '

' . $description . '

' . $checkoutHtml . '
'; + $templateDom = new DOMDocument(); + @$templateDom->loadHTML($templateHtml, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); + + $imgTag = $templateDom->getElementById('previewImage'); + if ($imgTag) $imgTag->setAttribute('src', $imageUrl); + + $titleTag = $templateDom->getElementById('previewTitle'); + if ($titleTag) $titleTag->nodeValue = $title; + + $descTag = $templateDom->getElementById('previewDescription'); + if ($descTag) $descTag->nodeValue = $description; + + $ctaContainer = $templateDom->getElementById('previewCtaContainer'); + if ($ctaContainer) { + while ($ctaContainer->hasChildNodes()) { + $ctaContainer->removeChild($ctaContainer->firstChild); + } + if (!empty(trim($checkoutHtml))) { + $fragment = $templateDom->createDocumentFragment(); + @$fragment->appendXML($checkoutHtml); + $ctaContainer->appendChild($fragment); + } else { + $ctaContainer->nodeValue = $ctaText; // Fallback to simple text if no HTML + } + } + + $finalPreviewHtml = $templateDom->saveHTML(); + + $htmlContent = << + + + + + $title + + + + +
+
+
+ $finalPreviewHtml +
+
+
+ + + +HTML; + + // Save the page + $publishedDir = 'published'; + if (!is_dir($publishedDir)) { + mkdir($publishedDir, 0755, true); + } + $pageId = uniqid(); + $filename = $publishedDir . '/' . $pageId . '.html'; + file_put_contents($filename, $htmlContent); + + $pageUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $filename; + + // Database interaction + require_once 'db/config.php'; + $management_token = bin2hex(random_bytes(16)); + $expires_at = date('Y-m-d H:i:s', strtotime('+60 days')); + + try { + $pdo = db(); + $stmt = $pdo->prepare("INSERT INTO published_pages (filename, management_token, expires_at) VALUES (?, ?, ?)"); + $stmt->execute([$pageId . '.html', $management_token, $expires_at]); + } catch (PDOException $e) { + // Log error, but don't show to user + error_log("DB Error: " . $e->getMessage()); + // Fallback to just showing the page URL without management link + echo "
"; + echo "

Your page has been published!

"; + echo "

You can view it here:

"; + echo "{$pageUrl}"; + echo "
"; + exit; + } + + $managementUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/manage.php?token=' . $management_token; + + // Display the success message and URL + echo "
"; + echo "

Your page has been published!

"; + echo "

You can view it here:

"; + echo "

{$pageUrl}

"; + echo "
"; + echo "

Manage your page:

"; + echo "

To prevent your page from being deleted after 60 days, use the following link to extend its lifetime:

"; + echo "

{$managementUrl}

"; + echo "
"; + +} else { + header('Location: index.php'); + exit; +} +?> \ No newline at end of file diff --git a/published/692d0999922fe.html b/published/692d0999922fe.html new file mode 100644 index 0000000..b94e913 --- /dev/null +++ b/published/692d0999922fe.html @@ -0,0 +1,169 @@ + + + + + + Shane's Site + + + + +
+
+
+
+
+ Ebook Cover +
+
+

Shane's Site

+

A vibrant and bold description for the blue-themed template.

+
Get It Now!
+
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/published/692d09f4de19e.html b/published/692d09f4de19e.html new file mode 100644 index 0000000..7f529e0 --- /dev/null +++ b/published/692d09f4de19e.html @@ -0,0 +1,169 @@ + + + + + + Bold & Blue Title + + + + +
+
+
+
+
+ Ebook Cover +
+
+

Bold & Blue Title

+

A vibrant and bold description for the blue-themed template.

+
Get It Now!
+
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/published/692d1417bdebb.html b/published/692d1417bdebb.html new file mode 100644 index 0000000..7f529e0 --- /dev/null +++ b/published/692d1417bdebb.html @@ -0,0 +1,169 @@ + + + + + + Bold & Blue Title + + + + +
+
+
+
+
+ Ebook Cover +
+
+

Bold & Blue Title

+

A vibrant and bold description for the blue-themed template.

+
Get It Now!
+
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/published/692d16ba3ef57.html b/published/692d16ba3ef57.html new file mode 100644 index 0000000..d77e36c --- /dev/null +++ b/published/692d16ba3ef57.html @@ -0,0 +1,169 @@ + + + + + + My Shane Ebook + + + + +
+
+
+
+
+ Ebook Cover +
+
+

My Shane Ebook

+

A compelling description for the minimalist modern template. BLAJ

+
MY PAYMENT FORM
+
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/published/692d17547bd50.html b/published/692d17547bd50.html new file mode 100644 index 0000000..a6f30ce --- /dev/null +++ b/published/692d17547bd50.html @@ -0,0 +1,169 @@ + + + + + + Ava's Ebook + + + + +
+
+
+
+
+ Ebook Cover +
+
+

Ava's Ebook

+

All About AVA

+
MY PAYMENT FORM
+
+
+ +
+
+
+ + + \ No newline at end of file