From 347be3952b2b94939b984fc1280e1e13006832dc Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 7 Nov 2025 18:14:24 +0000 Subject: [PATCH] 7 --- assets/css/custom.css | 56 ++++++++- assets/js/main.js | 64 ++++++++++ builder.php | 55 +++++++++ components/footer.php | 12 ++ components/gallery.php | 32 +++++ components/header.php | 24 ++++ components/hero.php | 10 ++ dashboard.php | 13 ++- db/config.php | 2 + index.php | 250 +--------------------------------------- login.php | 30 ++++- logs/debug.log | 47 ++++++++ partials/header.php | 1 + partials/navigation.php | 3 + register.php | 3 +- utils/logger.php | 8 ++ 16 files changed, 354 insertions(+), 256 deletions(-) create mode 100644 builder.php create mode 100644 components/footer.php create mode 100644 components/gallery.php create mode 100644 components/header.php create mode 100644 components/hero.php create mode 100644 logs/debug.log create mode 100644 utils/logger.php diff --git a/assets/css/custom.css b/assets/css/custom.css index d72383c..ac77069 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -74,4 +74,58 @@ body { /* Footer */ footer { border-top: 1px solid #E5E7EB; /* Gray-200 */ -} \ No newline at end of file +} + +/* Builder Page Styles */ +#sidebar { + position: fixed; + top: 0; + bottom: 0; + left: 0; + z-index: 100; + padding: 48px 0 0; /* Height of navbar */ + box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1); +} + +#component-list .nav-link { + font-weight: 500; + color: #333; +} + +#component-list .nav-link:hover { + color: #007bff; +} + +#canvas { + width: 100%; + min-height: 80vh; + background-color: #fff; + border: 1px solid #ddd; + border-radius: 0.5rem; +} + +.component-wrapper { + position: relative; + border: 1px dashed #ccc; + margin-bottom: 1rem; + padding: 1rem; +} + +.component-controls { + position: absolute; + top: 5px; + right: 5px; + display: none; + z-index: 1030; + background-color: rgba(255, 255, 255, 0.8); + border-radius: 5px; + padding: 2px; +} + +.component-wrapper:hover .component-controls { + display: block; +} + +.component-controls .btn { + margin-left: 5px; +} diff --git a/assets/js/main.js b/assets/js/main.js index e69de29..36ebfed 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -0,0 +1,64 @@ + +document.addEventListener('DOMContentLoaded', function () { + const componentList = document.getElementById('component-list'); + const canvas = document.getElementById('canvas'); + const initialCanvasMessage = canvas.querySelector('div'); + + let componentCounter = 0; + + function clearInitialMessage() { + if (canvas.contains(initialCanvasMessage)) { + canvas.innerHTML = ''; + } + } + + function addComponent(componentName) { + fetch(`components/${componentName}.php`) + .then(response => response.text()) + .then(html => { + clearInitialMessage(); + + componentCounter++; + const componentId = `component-${componentCounter}`; + + const wrapper = document.createElement('div'); + wrapper.classList.add('component-wrapper'); + wrapper.id = componentId; + wrapper.innerHTML = ` +
+ + +
+
+ ${html} +
+ `; + canvas.appendChild(wrapper); + }); + } + + componentList.addEventListener('click', function (e) { + const navItem = e.target.closest('.nav-item'); + if (navItem) { + e.preventDefault(); + const componentName = navItem.dataset.component; + addComponent(componentName); + } + }); + + canvas.addEventListener('click', function (e) { + if (e.target.classList.contains('delete-component')) { + const wrapper = e.target.closest('.component-wrapper'); + if (wrapper) { + wrapper.remove(); + } + } + + if (e.target.classList.contains('move-up')) { + const wrapper = e.target.closest('.component-wrapper'); + if (wrapper && wrapper.previousElementSibling) { + wrapper.parentNode.insertBefore(wrapper, wrapper.previousElementSibling); + } + } + }); +}); diff --git a/builder.php b/builder.php new file mode 100644 index 0000000..38112c3 --- /dev/null +++ b/builder.php @@ -0,0 +1,55 @@ + + + +
+
+ + +
+
+ +
+

Click on a component to add it to the page.

+
+ +
+ +
+
+
+ + + + diff --git a/components/footer.php b/components/footer.php new file mode 100644 index 0000000..eaf09ef --- /dev/null +++ b/components/footer.php @@ -0,0 +1,12 @@ +
+ +
\ No newline at end of file diff --git a/components/gallery.php b/components/gallery.php new file mode 100644 index 0000000..24f4d97 --- /dev/null +++ b/components/gallery.php @@ -0,0 +1,32 @@ +
+

Photo Gallery

+
+
+
+ ... +
+
Image Title
+

This is a short description of the image.

+
+
+
+
+
+ ... +
+
Image Title
+

This is a short description of the image.

+
+
+
+
+
+ ... +
+
Image Title
+

This is a short description of the image.

+
+
+
+
+
\ No newline at end of file diff --git a/components/header.php b/components/header.php new file mode 100644 index 0000000..3adc260 --- /dev/null +++ b/components/header.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/components/hero.php b/components/hero.php new file mode 100644 index 0000000..dacf8f3 --- /dev/null +++ b/components/hero.php @@ -0,0 +1,10 @@ +
+

Your Modern Website

+
+

Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit.

+
+ + +
+
+
\ No newline at end of file diff --git a/dashboard.php b/dashboard.php index 2ba9fb9..ae67a8b 100644 --- a/dashboard.php +++ b/dashboard.php @@ -1,16 +1,23 @@

Welcome to your Dashboard

-

You are logged in as .

+

You are logged in as .

diff --git a/db/config.php b/db/config.php index f12ebaf..c9871da 100644 --- a/db/config.php +++ b/db/config.php @@ -5,6 +5,8 @@ define('DB_NAME', 'app_31009'); define('DB_USER', 'app_31009'); define('DB_PASS', '2c66b530-2a65-423a-a106-6760b49ad1a2'); +require_once __DIR__ . '/../utils/logger.php'; + function db() { static $pdo; if (!$pdo) { diff --git a/index.php b/index.php index 4b6d0f0..8d69c4d 100644 --- a/index.php +++ b/index.php @@ -1,247 +1,5 @@ prepare("SELECT content FROM user_content WHERE user_id = ?"); - $stmt->execute([$_SESSION['user_id']]); - $user_content_row = $stmt->fetch(); - - if ($user_content_row) { - $content = json_decode($user_content_row['content'], true); - } else { - // New user, so create default content for them - $default_content_json = file_get_contents('db/content.json'); - $content = json_decode($default_content_json, true); - - $insert_stmt = $pdo->prepare("INSERT INTO user_content (user_id, content) VALUES (?, ?)"); - $insert_stmt->execute([$_SESSION['user_id'], $default_content_json]); - } -} else { - // User is not logged in, show default content - $content = json_decode(file_get_contents('db/content.json'), true); -} - - -// Handle content updates -if ($_SERVER['REQUEST_METHOD'] === 'POST' && $is_logged_in) { - $pdo = db(); - - // Fetch existing content to merge - $stmt = $pdo->prepare("SELECT content FROM user_content WHERE user_id = ?"); - $stmt->execute([$_SESSION['user_id']]); - $current_content_json = $stmt->fetchColumn(); - $current_content = json_decode($current_content_json, true); - - // Update with new values from POST - $current_content['hero_title'] = $_POST['hero_title'] ?? $current_content['hero_title']; - $current_content['hero_subtitle'] = $_POST['hero_subtitle'] ?? $current_content['hero_subtitle']; - $current_content['features_title'] = $_POST['features_title'] ?? $current_content['features_title']; - $current_content['feature_1_title'] = $_POST['feature_1_title'] ?? $current_content['feature_1_title']; - $current_content['feature_1_text'] = $_POST['feature_1_text'] ?? $current_content['feature_1_text']; - $current_content['feature_2_title'] = $_POST['feature_2_title'] ?? $current_content['feature_2_title']; - $current_content['feature_2_text'] = $_POST['feature_2_text'] ?? $current_content['feature_2_text']; - $current_content['feature_3_title'] = $_POST['feature_3_title'] ?? $current_content['feature_3_title']; - $current_content['feature_3_text'] = $_POST['feature_3_text'] ?? $current_content['feature_3_text']; - $current_content['about_title'] = $_POST['about_title'] ?? $current_content['about_title']; - $current_content['about_text'] = $_POST['about_text'] ?? $current_content['about_text']; - - $new_content_json = json_encode($current_content, JSON_PRETTY_PRINT); - - // Update the database - $update_stmt = $pdo->prepare("UPDATE user_content SET content = ? WHERE user_id = ?"); - $update_stmt->execute([$new_content_json, $_SESSION['user_id']]); - - // Redirect to avoid form resubmission - header("Location: " . $_SERVER['PHP_SELF']); - exit; -} - -// Default values -$hero_title = htmlspecialchars($content['hero_title'] ?? 'Build Your Dream Website'); -$hero_subtitle = htmlspecialchars($content['hero_subtitle'] ?? 'Visually design, customize, and publish beautiful, responsive websites. No code required.'); -$features_title = htmlspecialchars($content['features_title'] ?? 'Features'); -$feature_1_title = htmlspecialchars($content['feature_1_title'] ?? 'Visual Editor'); -$feature_1_text = htmlspecialchars($content['feature_1_text'] ?? 'Design and customize your site with a powerful, intuitive drag-and-drop editor.'); -$feature_2_title = htmlspecialchars($content['feature_2_title'] ?? 'Responsive Templates'); -$feature_2_text = htmlspecialchars($content['feature_2_text'] ?? 'Start with professionally designed, mobile-friendly templates that look great on any device.'); -$feature_3_title = htmlspecialchars($content['feature_3_title'] ?? 'One-Click Publishing'); -$feature_3_text = htmlspecialchars($content['feature_3_text'] ?? 'Go live instantly. We handle the hosting, security, and scaling for you.'); -$about_title = htmlspecialchars($content['about_title'] ?? 'About Us'); -$about_text = htmlspecialchars($content['about_text'] ?? 'We believe creating a website should be simple and accessible to everyone. Our mission is to empower creators with tools that are both powerful and easy to use.'); - -?> - - - - - - webCreatorSaas - - - - - - - - -
- -
-
-

-

- Get Started -
-
- - -
-
-
-

-
-
-
-
-
- -
-
-

-
-
-
-
-
- -
-
-

-
-
-
-
-
- -
-
-

-
-
-
-
-
- - -
-
-
-
-

-

-
-
- -
-
-
-
- - -
-
- -
-
-

Live Editor

-
-
-
-
- Hero Section -
- - -
-
- - -
-
- -
- Features Section -
- - -
-
-
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-
-
- -
- About Section -
- - -
-
- - -
-
- - -
-
-
- -
- -

Editor Locked

-

Please log in or create an account to edit the page content.

-
- -
-
-
- - - - - \ No newline at end of file +// Redirect to the builder page +header("Location: builder.php"); +exit(); +?> \ No newline at end of file diff --git a/login.php b/login.php index af2845d..5509598 100644 --- a/login.php +++ b/login.php @@ -1,23 +1,40 @@ fetch(); if ($user && password_verify($password, $user['password'])) { - session_start(); $_SESSION['user_id'] = $user['id']; $_SESSION['user_email'] = $user['email']; + log_message("User login successful for {$email}. Redirecting to dashboard."); header("Location: dashboard.php"); exit; } else { $errors[] = 'Invalid email or password.'; + log_message("Login failed for {$email}: Invalid email or password."); } } catch (PDOException $e) { $errors[] = "Database error: " . $e->getMessage(); + log_message("Login failed for {$email}: Database error - " . $e->getMessage()); } } } -require_once __DIR__ . '/partials/header.php'; ?>
@@ -61,7 +79,7 @@ require_once __DIR__ . '/partials/header.php';
-
+
@@ -72,6 +90,10 @@ require_once __DIR__ . '/partials/header.php';
+
+ + +
diff --git a/logs/debug.log b/logs/debug.log new file mode 100644 index 0000000..67f1d52 --- /dev/null +++ b/logs/debug.log @@ -0,0 +1,47 @@ +Log file created. +[2025-11-07 18:07:27] Login page loaded. +[2025-11-07 18:07:27] Login page loaded. +[2025-11-07 18:07:36] Login page loaded. +[2025-11-07 18:07:36] Login page loaded. +[2025-11-07 18:07:36] Attempting login for email: admin@example.com +[2025-11-07 18:07:36] Admin login successful. Redirecting to dashboard. +[2025-11-07 18:07:36] Dashboard page loaded. +[2025-11-07 18:07:36] User not logged in. Redirecting to login.php. +[2025-11-07 18:07:36] Login page loaded. +[2025-11-07 18:07:37] Dashboard page loaded. +[2025-11-07 18:07:37] User not logged in. Redirecting to login.php. +[2025-11-07 18:07:37] Login page loaded. +[2025-11-07 18:07:37] Login page loaded. +[2025-11-07 18:07:43] Login page loaded. +[2025-11-07 18:07:43] Login page loaded. +[2025-11-07 18:07:43] Attempting to skip login. +[2025-11-07 18:07:43] Skip login successful. Redirecting to dashboard. +[2025-11-07 18:07:43] Dashboard page loaded. +[2025-11-07 18:07:43] User not logged in. Redirecting to login.php. +[2025-11-07 18:07:43] Login page loaded. +[2025-11-07 18:07:43] Dashboard page loaded. +[2025-11-07 18:07:43] User not logged in. Redirecting to login.php. +[2025-11-07 18:07:44] Login page loaded. +[2025-11-07 18:07:44] Login page loaded. +[2025-11-07 18:07:46] Login page loaded. +[2025-11-07 18:07:46] Login page loaded. +[2025-11-07 18:07:46] Attempting to skip login. +[2025-11-07 18:07:46] Skip login successful. Redirecting to dashboard. +[2025-11-07 18:07:46] Dashboard page loaded. +[2025-11-07 18:07:46] User not logged in. Redirecting to login.php. +[2025-11-07 18:07:46] Login page loaded. +[2025-11-07 18:07:46] Dashboard page loaded. +[2025-11-07 18:07:46] User not logged in. Redirecting to login.php. +[2025-11-07 18:07:47] Login page loaded. +[2025-11-07 18:07:47] Login page loaded. +[2025-11-07 18:07:47] Login page loaded. +[2025-11-07 18:07:47] Login page loaded. +[2025-11-07 18:07:47] Attempting to skip login. +[2025-11-07 18:07:47] Skip login successful. Redirecting to dashboard. +[2025-11-07 18:07:47] Dashboard page loaded. +[2025-11-07 18:07:47] User not logged in. Redirecting to login.php. +[2025-11-07 18:07:47] Login page loaded. +[2025-11-07 18:07:48] Dashboard page loaded. +[2025-11-07 18:07:48] User not logged in. Redirecting to login.php. +[2025-11-07 18:07:48] Login page loaded. +[2025-11-07 18:07:48] Login page loaded. diff --git a/partials/header.php b/partials/header.php index 7fa34f4..cf390e9 100644 --- a/partials/header.php +++ b/partials/header.php @@ -1,3 +1,4 @@ + diff --git a/partials/navigation.php b/partials/navigation.php index 4bf5008..b403d4f 100644 --- a/partials/navigation.php +++ b/partials/navigation.php @@ -11,6 +11,9 @@ + diff --git a/register.php b/register.php index 66c4ae7..9fc176c 100644 --- a/register.php +++ b/register.php @@ -1,4 +1,5 @@
diff --git a/utils/logger.php b/utils/logger.php new file mode 100644 index 0000000..6d606af --- /dev/null +++ b/utils/logger.php @@ -0,0 +1,8 @@ + \ No newline at end of file