This commit is contained in:
Flatlogic Bot 2025-10-23 08:54:07 +00:00
parent bab1701497
commit 3d1ae14d5d
12 changed files with 351 additions and 157 deletions

135
assets/css/custom.css Normal file
View File

@ -0,0 +1,135 @@
:root {
--primary-color: #2c3e50;
--secondary-color: #3498db;
--background-color: #ecf0f1;
--surface-color: #ffffff;
--font-family: 'Poppins', sans-serif;
}
body {
background-color: var(--background-color);
font-family: var(--font-family);
margin: 0;
display: flex;
min-height: 100vh;
}
.sidebar {
width: 250px;
background-color: var(--primary-color);
color: white;
padding: 1rem;
display: flex;
flex-direction: column;
}
.sidebar h3 {
margin-top: 0;
text-align: center;
}
.sidebar a {
color: white;
text-decoration: none;
padding: 0.75rem 1rem;
border-radius: 0.25rem;
margin-bottom: 0.5rem;
transition: background-color 0.2s ease-in-out;
}
.sidebar a:hover, .sidebar a.active {
background-color: var(--secondary-color);
}
.sidebar .logout {
margin-top: auto;
}
.main-content {
flex-grow: 1;
padding: 2rem;
}
.dashboard-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2rem;
}
.stat-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
}
.card {
background-color: var(--surface-color);
border-radius: 0.5rem;
padding: 1.5rem;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.card h4 {
margin-top: 0;
color: #7f8c8d;
}
.card .stat {
font-size: 2rem;
font-weight: 600;
color: var(--primary-color);
}
/* Login Page */
.login-container {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.login-box {
width: 100%;
max-width: 400px;
padding: 2rem;
background-color: var(--surface-color);
border-radius: 0.5rem;
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.login-box h1 {
text-align: center;
color: var(--primary-color);
margin-bottom: 1.5rem;
}
.form-group {
margin-bottom: 1rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
color: #7f8c8d;
}
.form-control {
width: 100%;
padding: 0.75rem;
border: 1px solid #bdc3c7;
border-radius: 0.25rem;
box-sizing: border-box;
}
.btn {
width: 100%;
padding: 0.85rem;
border: none;
border-radius: 0.25rem;
cursor: pointer;
font-size: 1rem;
font-weight: 600;
}
.btn-primary {
background-color: var(--secondary-color);
color: white;
}
.alert {
padding: 1rem;
margin-bottom: 1rem;
border-radius: 0.25rem;
}
.alert-danger {
background-color: #f2dede;
color: #a94442;
border: 1px solid #ebccd1;
}

8
auth.php Normal file
View File

@ -0,0 +1,8 @@
<?php
session_start();
// If the user is not logged in, redirect to the login page.
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}

26
dashboard.php Normal file
View File

@ -0,0 +1,26 @@
<?php
require_once 'auth.php';
require_once 'partials/header.php';
require_once 'partials/sidebar.php';
?>
<div class="dashboard-header">
<h2>Welcome, <?php echo htmlspecialchars($_SESSION['user_name']); ?>!</h2>
</div>
<div class="stat-cards">
<div class="card">
<h4>Total Products</h4>
<div class="stat">0</div>
</div>
<div class="card">
<h4>Total Categories</h4>
<div class="stat">0</div>
</div>
<div class="card">
<h4>Total Users</h4>
<div class="stat">1</div>
</div>
</div>
<?php require_once 'partials/footer.php'; ?>

View File

@ -6,12 +6,29 @@ define('DB_USER', 'app_30972');
define('DB_PASS', '9eb17a13-4a89-4e11-8517-0c201096e935');
function db() {
static $pdo;
if (!$pdo) {
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
}
return $pdo;
static $pdo;
if ($pdo) {
return $pdo;
}
try {
// Connect without specifying a database
$pdo_temp = new PDO('mysql:host='.DB_HOST.';charset=utf8mb4', DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
// Create the database if it doesn't exist
$pdo_temp->exec('CREATE DATABASE IF NOT EXISTS `'.DB_NAME.'`');
// Now connect to the newly created/existing database
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
} catch (PDOException $e) {
die('Database connection failed: ' . $e->getMessage());
}
return $pdo;
}

42
db/migrate.php Normal file
View File

@ -0,0 +1,42 @@
<?php
require_once __DIR__ . '/config.php';
function run_migrations() {
$pdo = db();
$migrations_dir = __DIR__ . '/migrations';
$files = glob($migrations_dir . '/*.sql');
sort($files);
foreach ($files as $file) {
$sql = file_get_contents($file);
try {
$pdo->exec($sql);
echo 'Migrated: ' . basename($file) . PHP_EOL;
} catch (PDOException $e) {
die('Migration failed: ' . $e->getMessage());
}
}
// Check if default user exists
$stmt = $pdo->prepare('SELECT id FROM users WHERE email = ?');
$stmt->execute(['admin@example.com']);
if ($stmt->fetch()) {
echo 'Default admin user already exists.' . PHP_EOL;
return;
}
// Insert a default admin user
$name = 'Super Admin';
$email = 'admin@example.com';
$password = password_hash('password', PASSWORD_DEFAULT);
try {
$stmt = $pdo->prepare('INSERT INTO users (name, email, password) VALUES (?, ?, ?)');
$stmt->execute([$name, $email, $password]);
echo 'Default admin user created (admin@example.com / password).' . PHP_EOL;
} catch (PDOException $e) {
die('Failed to create default user: ' . $e->getMessage());
}
}
run_migrations();

View File

@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS `users` (
`id` INT AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(100) NOT NULL,
`email` VARCHAR(100) NOT NULL UNIQUE,
`password` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

152
index.php
View File

@ -1,150 +1,4 @@
<?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 login page, which is the main entry point for the admin panel.
header('Location: login.php');
exit;

72
login.php Normal file
View File

@ -0,0 +1,72 @@
<?php
session_start();
require_once 'db/config.php';
// If the user is already logged in, redirect to the dashboard.
if (isset($_SESSION['user_id'])) {
header('Location: dashboard.php');
exit;
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = $_POST['email'] ?? '';
$password = $_POST['password'] ?? '';
if (empty($email) || empty($password)) {
$error = 'Email and password are required.';
} else {
$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_name'] = $user['name'];
header('Location: dashboard.php');
exit;
} else {
$error = 'Invalid email or password.';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Furniture Admin Panel</title>
<meta name="description" content="Admin panel for a furniture e-commerce store, built with Flatlogic Generator.">
<meta name="keywords" content="admin panel, furniture store, e-commerce, dashboard, product management, category management, user authentication, Flatlogic Generator">
<meta property="og:title" content="Furniture Admin Panel">
<meta property="og:description" content="Admin panel for a furniture e-commerce store, built with Flatlogic Generator.">
<meta property="og:image" content="">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>
<div class="login-container">
<div class="login-box">
<h1>Admin Login</h1>
<?php if ($error): ?>
<div class="alert alert-danger"><?php echo htmlspecialchars($error); ?></div>
<?php endif; ?>
<form action="login.php" method="POST">
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" name="email" class="form-control" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" class="form-control" required>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
</div>
</div>
</body>
</html>

6
logout.php Normal file
View File

@ -0,0 +1,6 @@
<?php
session_start();
session_unset();
session_destroy();
header('Location: login.php');
exit;

3
partials/footer.php Normal file
View File

@ -0,0 +1,3 @@
</div>
</body>
</html>

17
partials/header.php Normal file
View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Furniture Admin Panel</title>
<meta name="description" content="Admin panel for a furniture e-commerce store, built with Flatlogic Generator.">
<meta name="keywords" content="admin panel, furniture store, e-commerce, dashboard, product management, category management, user authentication, Flatlogic Generator">
<meta property="og:title" content="Furniture Admin Panel">
<meta property="og:description" content="Admin panel for a furniture e-commerce store, built with Flatlogic Generator.">
<meta property="og:image" content="">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body>

7
partials/sidebar.php Normal file
View File

@ -0,0 +1,7 @@
<div class="sidebar">
<h3>Admin Panel</h3>
<a href="dashboard.php" class="active">Dashboard</a>
<!-- More links will be added here -->
<a href="logout.php" class="logout">Logout</a>
</div>
<div class="main-content">