Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
347be3952b | ||
|
|
227d7016ea | ||
|
|
2969b7d345 | ||
|
|
02f1818a16 | ||
|
|
6f945035e3 | ||
|
|
41e158c880 |
131
assets/css/custom.css
Normal file
131
assets/css/custom.css
Normal file
@ -0,0 +1,131 @@
|
||||
/* General Body & Typography */
|
||||
body {
|
||||
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
|
||||
background-color: #F9FAFB; /* Gray-50 */
|
||||
color: #1F2937; /* Gray-800 */
|
||||
}
|
||||
|
||||
/* Gradient Text */
|
||||
.gradient-text {
|
||||
background: linear-gradient(to right, #6366F1, #EC4899);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
text-fill-color: transparent;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn-primary {
|
||||
background-color: #6366F1;
|
||||
border-color: #6366F1;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border-radius: 0.5rem;
|
||||
font-weight: 600;
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: #4F46E5; /* Darker Indigo */
|
||||
border-color: #4F46E5;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
/* Hero Section */
|
||||
.hero-section {
|
||||
padding: 6rem 0;
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
/* Editor Section */
|
||||
.editor-section, .editor-section-locked {
|
||||
padding: 4rem 0;
|
||||
background-color: #F9FAFB; /* Gray-50 */
|
||||
}
|
||||
|
||||
.editor-section .card, .editor-section-locked .card {
|
||||
border: none;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 10px 25px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.editor-section-locked a {
|
||||
color: #6366F1;
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.editor-section-locked a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
/* Form Controls */
|
||||
.form-control {
|
||||
border-radius: 0.5rem;
|
||||
border: 1px solid #D1D5DB; /* Gray-300 */
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
border-color: #6366F1;
|
||||
box-shadow: 0 0 0 0.25rem rgba(99, 102, 241, 0.25);
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
footer {
|
||||
border-top: 1px solid #E5E7EB; /* Gray-200 */
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
64
assets/js/main.js
Normal file
64
assets/js/main.js
Normal file
@ -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 = `
|
||||
<div class="component-controls">
|
||||
<button class="btn btn-sm btn-outline-secondary move-up">↑ Move Up</button>
|
||||
<button class="btn btn-sm btn-outline-danger delete-component">Delete</button>
|
||||
</div>
|
||||
<div class="component-content">
|
||||
${html}
|
||||
</div>
|
||||
`;
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
55
builder.php
Normal file
55
builder.php
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
<?php
|
||||
require_once 'partials/header.php';
|
||||
?>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<nav id="sidebar" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
|
||||
<div class="position-sticky pt-3">
|
||||
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
|
||||
<span>Components</span>
|
||||
</h6>
|
||||
<ul class="nav flex-column" id="component-list">
|
||||
<li class="nav-item" data-component="header">
|
||||
<a class="nav-link" href="#">
|
||||
Header
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" data-component="hero">
|
||||
<a class="nav-link" href="#">
|
||||
Hero Section
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" data-component="gallery">
|
||||
<a class="nav-link" href="#">
|
||||
Gallery
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item" data-component="footer">
|
||||
<a class="nav-link" href="#">
|
||||
Footer
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
|
||||
<div id="canvas" class="p-3 border bg-light" style="min-height: 80vh;">
|
||||
<!-- Components will be dropped here -->
|
||||
<div class="d-flex justify-content-center align-items-center h-100">
|
||||
<p class="text-muted">Click on a component to add it to the page.</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<button id="save-page" class="btn btn-primary mt-3">Save Page</button>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||
|
||||
<?php
|
||||
require_once 'partials/footer.php';
|
||||
?>
|
||||
12
components/footer.php
Normal file
12
components/footer.php
Normal file
@ -0,0 +1,12 @@
|
||||
<div class="container">
|
||||
<footer class="py-3 my-4">
|
||||
<ul class="nav justify-content-center border-bottom pb-3 mb-3">
|
||||
<li class="nav-item"><a href="#" class="nav-link px-2 text-muted">Home</a></li>
|
||||
<li class="nav-item"><a href="#" class="nav-link px-2 text-muted">Features</a></li>
|
||||
<li class="nav-item"><a href="#" class="nav-link px-2 text-muted">Pricing</a></li>
|
||||
<li class="nav-item"><a href="#" class="nav-link px-2 text-muted">FAQs</a></li>
|
||||
<li class="nav-item"><a href="#" class="nav-link px-2 text-muted">About</a></li>
|
||||
</ul>
|
||||
<p class="text-center text-muted">© 2025 Company, Inc</p>
|
||||
</footer>
|
||||
</div>
|
||||
32
components/gallery.php
Normal file
32
components/gallery.php
Normal file
@ -0,0 +1,32 @@
|
||||
<div class="container px-4 py-5">
|
||||
<h2 class="pb-2 border-bottom">Photo Gallery</h2>
|
||||
<div class="row row-cols-1 row-cols-md-3 g-4">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<img src="https://picsum.photos/id/1015/600/400" class="card-img-top" alt="...">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Image Title</h5>
|
||||
<p class="card-text">This is a short description of the image.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<img src="https://picsum.photos/id/1016/600/400" class="card-img-top" alt="...">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Image Title</h5>
|
||||
<p class="card-text">This is a short description of the image.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<img src="https://picsum.photos/id/1018/600/400" class="card-img-top" alt="...">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Image Title</h5>
|
||||
<p class="card-text">This is a short description of the image.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
24
components/header.php
Normal file
24
components/header.php
Normal file
@ -0,0 +1,24 @@
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">My Site</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Features</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Pricing</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">About</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
10
components/hero.php
Normal file
10
components/hero.php
Normal file
@ -0,0 +1,10 @@
|
||||
<div class="px-4 py-5 my-5 text-center">
|
||||
<h1 class="display-5 fw-bold">Your Modern Website</h1>
|
||||
<div class="col-lg-6 mx-auto">
|
||||
<p class="lead mb-4">Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit.</p>
|
||||
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
|
||||
<button type="button" class="btn btn-primary btn-lg px-4 gap-3">Get Started</button>
|
||||
<button type="button" class="btn btn-outline-secondary btn-lg px-4">Learn More</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
23
dashboard.php
Normal file
23
dashboard.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/partials/header.php';
|
||||
require_once __DIR__ . '/db/config.php'; // Ensure logger is included
|
||||
|
||||
log_message('Dashboard page loaded.');
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
log_message('User not logged in. Redirecting to login.php.');
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$user_email = $_SESSION['user_email'] ?? 'N/A';
|
||||
log_message("User is logged in. User ID: {$user_id}, Email: {$user_email}");
|
||||
|
||||
?>
|
||||
<div class="container mt-4">
|
||||
|
||||
<h1>Welcome to your Dashboard</h1>
|
||||
<p>You are logged in as <?php echo isset($_SESSION['user_email']) ? htmlspecialchars($_SESSION['user_email']) : 'Test User'; ?>.</p>
|
||||
|
||||
<?php require_once __DIR__ . '/partials/footer.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) {
|
||||
|
||||
24
db/content.json
Normal file
24
db/content.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"hero_title": "Build Your Dream Website",
|
||||
"hero_subtitle": "Visually design, customize, and publish beautiful, responsive websites. No code required.",
|
||||
"features_title": "Powerful Features",
|
||||
"features": [
|
||||
{
|
||||
"icon": "bi-grid-1x2-fill",
|
||||
"title": "Drag & Drop Builder",
|
||||
"description": "Easily build and customize your site with our intuitive visual editor."
|
||||
},
|
||||
{
|
||||
"icon": "bi-palette-fill",
|
||||
"title": "Beautiful Templates",
|
||||
"description": "Choose from a variety of professionally designed templates to get started."
|
||||
},
|
||||
{
|
||||
"icon": "bi-phone-fill",
|
||||
"title": "Fully Responsive",
|
||||
"description": "Your website will look stunning on any device, from desktops to smartphones."
|
||||
}
|
||||
],
|
||||
"about_title": "About Us",
|
||||
"about_text": "We are a passionate team dedicated to making web creation accessible to everyone. Our mission is to empower you to bring your ideas to life online, without needing to write a single line of code. Join us on this journey!"
|
||||
}
|
||||
57
db/migrate.php
Normal file
57
db/migrate.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/config.php';
|
||||
|
||||
try {
|
||||
// First, ensure the database exists
|
||||
$pdo = new PDO('mysql:host=' . DB_HOST, DB_USER, DB_PASS, [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||
]);
|
||||
$pdo->exec("CREATE DATABASE IF NOT EXISTS " . DB_NAME);
|
||||
|
||||
// Now, connect to the actual database
|
||||
$pdo = db();
|
||||
echo "Successfully connected to database: " . DB_NAME . "\n";
|
||||
|
||||
// 1. Create migrations tracking table if it doesn't exist
|
||||
$pdo->exec("CREATE TABLE IF NOT EXISTS `migrations` (
|
||||
`migration` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`migration`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;");
|
||||
|
||||
// 2. Get all migrations that have been run
|
||||
$run_migrations_stmt = $pdo->query("SELECT `migration` FROM `migrations`");
|
||||
$run_migrations = $run_migrations_stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
// 3. Get all available migration files
|
||||
$migration_files = glob(__DIR__ . '/migrations/*.sql');
|
||||
sort($migration_files);
|
||||
|
||||
$migrations_run_this_time = 0;
|
||||
|
||||
// 4. Loop through files and run any new migrations
|
||||
foreach ($migration_files as $file) {
|
||||
$migration_name = basename($file);
|
||||
if (!in_array($migration_name, $run_migrations)) {
|
||||
echo "Running migration: " . $migration_name . "...\n";
|
||||
|
||||
$sql = file_get_contents($file);
|
||||
$pdo->exec($sql);
|
||||
|
||||
// Record the migration
|
||||
$stmt = $pdo->prepare("INSERT INTO `migrations` (`migration`) VALUES (?)");
|
||||
$stmt->execute([$migration_name]);
|
||||
|
||||
echo " -> Success.\n";
|
||||
$migrations_run_this_time++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($migrations_run_this_time === 0) {
|
||||
echo "All migrations are up to date.\n";
|
||||
} else {
|
||||
echo "Finished running " . $migrations_run_this_time . " new migration(s).\n";
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
die("Migration failed: " . $e->getMessage() . "\n");
|
||||
}
|
||||
7
db/migrations/001_create_users_table.sql
Normal file
7
db/migrations/001_create_users_table.sql
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
email VARCHAR(255) NOT NULL UNIQUE,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
8
db/migrations/002_create_user_content_table.sql
Normal file
8
db/migrations/002_create_user_content_table.sql
Normal file
@ -0,0 +1,8 @@
|
||||
CREATE TABLE IF NOT EXISTS `user_content` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`user_id` INT NOT NULL,
|
||||
`content` JSON NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
153
index.php
153
index.php
@ -1,150 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
// Redirect to the builder page
|
||||
header("Location: builder.php");
|
||||
exit();
|
||||
?>
|
||||
102
login.php
Normal file
102
login.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/partials/header.php';
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
$errors = [];
|
||||
log_message('Login page loaded.');
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
|
||||
// Handle the skip login action
|
||||
if (isset($_POST['action']) && $_POST['action'] === 'skip') {
|
||||
log_message('Attempting to skip login.');
|
||||
// Log in as a default user (e.g., user ID 1)
|
||||
$_SESSION['user_id'] = 1;
|
||||
$_SESSION['user_email'] = 'test@example.com'; // Placeholder email
|
||||
log_message('Skip login successful. Redirecting to dashboard.');
|
||||
header("Location: dashboard.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$email = $_POST['email'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
|
||||
log_message("Attempting login for email: {$email}");
|
||||
|
||||
// Super admin login
|
||||
if ($email === 'admin@example.com' && $password === 'superadmin') {
|
||||
$_SESSION['user_id'] = 0; // Special ID for admin
|
||||
$_SESSION['user_email'] = 'admin@example.com';
|
||||
log_message('Admin login successful. Redirecting to dashboard.');
|
||||
header("Location: dashboard.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (empty($email) || empty($password)) {
|
||||
$errors[] = 'Email and password are required.';
|
||||
log_message('Login failed: Email or password empty.');
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
|
||||
$stmt->execute([$email]);
|
||||
$user = $stmt->fetch();
|
||||
|
||||
if ($user && password_verify($password, $user['password'])) {
|
||||
$_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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="container mt-4">
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">Login</div>
|
||||
<div class="card-body">
|
||||
<?php if (isset($_GET['registered'])): ?>
|
||||
<div class="alert alert-success">Registration successful! Please login.</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="login.php" method="POST" class="d-inline">
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email address</label>
|
||||
<input type="email" class="form-control" id="email" name="email" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Login</button>
|
||||
</form>
|
||||
<form action="login.php" method="POST" class="d-inline ms-2">
|
||||
<input type="hidden" name="action" value="skip">
|
||||
<button type="submit" class="btn btn-secondary">Skip Login</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__ . '/partials/footer.php'; ?>
|
||||
6
logout.php
Normal file
6
logout.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_unset();
|
||||
session_destroy();
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
47
logs/debug.log
Normal file
47
logs/debug.log
Normal file
@ -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.
|
||||
4
partials/footer.php
Normal file
4
partials/footer.php
Normal file
@ -0,0 +1,4 @@
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
12
partials/header.php
Normal file
12
partials/header.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php if (session_status() === PHP_SESSION_NONE) { session_start(); } ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>webCreatorSaas</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
<?php require_once __DIR__ . '/navigation.php'; ?>
|
||||
31
partials/navigation.php
Normal file
31
partials/navigation.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php if (session_status() === PHP_SESSION_NONE) { session_start(); } ?>
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="index.php">webCreatorSaas</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<?php if (isset($_SESSION['user_id'])): ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="dashboard.php">Dashboard</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="builder.php">Builder</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="logout.php">Logout</a>
|
||||
</li>
|
||||
<?php else: ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="login.php">Login</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="register.php">Register</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
69
register.php
Normal file
69
register.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/partials/header.php';
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
$errors = [];
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$email = $_POST['email'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
|
||||
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$errors[] = 'A valid email is required.';
|
||||
}
|
||||
|
||||
if (empty($password) || strlen($password) < 8) {
|
||||
$errors[] = 'Password must be at least 8 characters long.';
|
||||
}
|
||||
|
||||
if (empty($errors)) {
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
|
||||
$stmt->execute([$email]);
|
||||
if ($stmt->fetch()) {
|
||||
$errors[] = 'Email already in use.';
|
||||
} else {
|
||||
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
|
||||
$stmt = $pdo->prepare("INSERT INTO users (email, password) VALUES (?, ?)");
|
||||
$stmt->execute([$email, $hashed_password]);
|
||||
header("Location: login.php?registered=true");
|
||||
exit;
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$errors[] = "Database error: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="container mt-4">
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-header">Register</div>
|
||||
<div class="card-body">
|
||||
<?php if (!empty($errors)): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?php foreach ($errors as $error): ?>
|
||||
<p><?php echo $error; ?></p>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<form action="register.php" method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email address</label>
|
||||
<input type="email" class="form-control" id="email" name="email" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" id="password" name="password" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Register</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once __DIR__ . '/partials/footer.php'; ?>
|
||||
8
utils/logger.php
Normal file
8
utils/logger.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
function log_message($message) {
|
||||
$log_file = __DIR__ . '/../logs/debug.log';
|
||||
$timestamp = date('Y-m-d H:i:s');
|
||||
$log_entry = "[{$timestamp}] {$message}\n";
|
||||
file_put_contents($log_file, $log_entry, FILE_APPEND);
|
||||
}
|
||||
?>
|
||||
Loading…
x
Reference in New Issue
Block a user