diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..c1b781a --- /dev/null +++ b/assets/css/custom.css @@ -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; +} diff --git a/auth.php b/auth.php new file mode 100644 index 0000000..05e8f93 --- /dev/null +++ b/auth.php @@ -0,0 +1,8 @@ + + +
+

Welcome, !

+
+ +
+
+

Total Products

+
0
+
+
+

Total Categories

+
0
+
+
+

Total Users

+
1
+
+
+ + \ No newline at end of file diff --git a/db/config.php b/db/config.php index cc9229f..5a9d634 100644 --- a/db/config.php +++ b/db/config.php @@ -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; } diff --git a/db/migrate.php b/db/migrate.php new file mode 100644 index 0000000..b97285d --- /dev/null +++ b/db/migrate.php @@ -0,0 +1,42 @@ +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(); diff --git a/db/migrations/001_create_users_table.sql b/db/migrations/001_create_users_table.sql new file mode 100644 index 0000000..94caa30 --- /dev/null +++ b/db/migrations/001_create_users_table.sql @@ -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 +); diff --git a/index.php b/index.php index 7205f3d..5754946 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,4 @@ - - - - - - New Style - - - - - - - - - - - - - - - - - - - - - -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
-
- Page updated: (UTC) -
- - +// Redirect to the login page, which is the main entry point for the admin panel. +header('Location: login.php'); +exit; diff --git a/login.php b/login.php new file mode 100644 index 0000000..435924a --- /dev/null +++ b/login.php @@ -0,0 +1,72 @@ +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.'; + } + } +} +?> + + + + + + Login - Furniture Admin Panel + + + + + + + + + + + +
+
+

Admin Login

+ +
+ +
+
+ + +
+
+ + +
+ +
+
+
+ + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..95db42c --- /dev/null +++ b/logout.php @@ -0,0 +1,6 @@ + + + diff --git a/partials/header.php b/partials/header.php new file mode 100644 index 0000000..0019402 --- /dev/null +++ b/partials/header.php @@ -0,0 +1,17 @@ + + + + + + Furniture Admin Panel + + + + + + + + + + + diff --git a/partials/sidebar.php b/partials/sidebar.php new file mode 100644 index 0000000..2a3b91d --- /dev/null +++ b/partials/sidebar.php @@ -0,0 +1,7 @@ +
+

Admin Panel

+ Dashboard + + Logout +
+