From 8d726945ab95d28d6a214e110bc756272ccf03f8 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 27 Oct 2025 14:04:41 +0000 Subject: [PATCH] v0.1 --- assets/css/custom.css | 41 ++++ assets/js/main.js | 0 db/config.php | 32 +-- db/migrate.php | 29 +++ db/migrations/001_create_users_table.sql | 7 + index.php | 268 +++++++++++------------ login.php | 77 +++++++ logout.php | 7 + 8 files changed, 306 insertions(+), 155 deletions(-) create mode 100644 assets/css/custom.css create mode 100644 assets/js/main.js create mode 100644 db/migrate.php create mode 100644 db/migrations/001_create_users_table.sql create mode 100644 login.php create mode 100644 logout.php diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..e15af5d --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,41 @@ +:root { + --bs-primary: #005A9C; + --bs-secondary: #FDB913; +} + +.btn-primary { + background-image: linear-gradient(to bottom, #006bbd, #005A9C); + border: 1px solid #004c8b; +} + +.sidebar { + position: fixed; + top: 0; + bottom: 0; + left: 0; + z-index: 100; + padding: 48px 0 0; + box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1); +} + +.sidebar-sticky { + position: relative; + top: 0; + height: calc(100vh - 48px); + padding-top: .5rem; + overflow-x: hidden; + overflow-y: auto; +} + +.nav-link { + color: #333; +} + +.nav-link.active { + color: #005A9C; + font-weight: 500; +} + +.nav-link .bi { + margin-right: 8px; +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..e69de29 diff --git a/db/config.php b/db/config.php index cc9229f..ef4bfd1 100644 --- a/db/config.php +++ b/db/config.php @@ -1,17 +1,21 @@ PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - ]); - } - return $pdo; + $dsn = "mysql:host=$host;dbname=$db;charset=$charset"; + $options = [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::ATTR_EMULATE_PREPARES => false, + ]; + try { + return new PDO($dsn, $user, $pass, $options); + } catch (PDOException $e) { + throw new PDOException($e->getMessage(), (int)$e->getCode()); + } } +?> \ No newline at end of file diff --git a/db/migrate.php b/db/migrate.php new file mode 100644 index 0000000..abdb6c8 --- /dev/null +++ b/db/migrate.php @@ -0,0 +1,29 @@ +exec($sql); + echo "Applied migration: " . basename($file) . "\n"; + } +} + +run_migrations(); + +// Add a default admin user +$pdo = db_connect(); +$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?"); +$stmt->execute(['admin@university.com']); +if (!$stmt->fetch()) { + $password = password_hash('password', PASSWORD_DEFAULT); + $stmt = $pdo->prepare("INSERT INTO users (email, password, role) VALUES (?, ?, ?)"); + $stmt->execute(['admin@university.com', $password, 'Super Admin']); + echo "Created default admin user.\n"; +} + +?> \ No newline at end of file diff --git a/db/migrations/001_create_users_table.sql b/db/migrations/001_create_users_table.sql new file mode 100644 index 0000000..42876f0 --- /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, + email VARCHAR(255) NOT NULL UNIQUE, + password VARCHAR(255) NOT NULL, + role VARCHAR(50) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); diff --git a/index.php b/index.php index 7205f3d..670b549 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,136 @@ prepare("SELECT * FROM users WHERE id = ?"); +$stmt->execute([$_SESSION['user_id']]); +$user = $stmt->fetch(); -$phpVersion = PHP_VERSION; -$now = date('Y-m-d H:i:s'); ?> - + - - - New Style - - - - - - - - - - - - - - - - - - - + + + Dashboard - University Class Scheduling + + + -
-
-

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

+ + +
+
+ + +
+
+

Dashboard

+
+ +
+
+
+
+
Welcome, !
+

This is your dashboard. You can manage the university class scheduling from here.

+
+
+
+
+ +
+
-
- + + + - + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..8afbcfa --- /dev/null +++ b/login.php @@ -0,0 +1,77 @@ +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_role'] = $user['role']; + header('Location: index.php'); + exit; + } else { + $error = 'Invalid email or password.'; + } + } +} +?> + + + + + + Login - University Class Scheduling + + + + + +
+
+
+
+
+

Class Scheduling

+

Sign In

+ +
+ +
+
+ + +
+
+ + +
+
+ +
+
+
+
+
+
+
+ + + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..4e97304 --- /dev/null +++ b/logout.php @@ -0,0 +1,7 @@ + \ No newline at end of file