From 4ed2abbf3150b69568d31b29e20a85ac16756104 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Thu, 2 Oct 2025 02:55:03 +0000 Subject: [PATCH] 1.0 --- assets/css/custom.css | 50 ++++++++++++ assets/js/main.js | 20 +++++ includes/common.php | 35 +++++++++ includes/footer.php | 12 +++ includes/header.php | 41 ++++++++++ index.php | 172 +++++++----------------------------------- login.php | 76 +++++++++++++++++++ logout.php | 18 +++++ register.php | 102 +++++++++++++++++++++++++ setup.php | 33 ++++++++ 10 files changed, 413 insertions(+), 146 deletions(-) create mode 100644 assets/css/custom.css create mode 100644 assets/js/main.js create mode 100644 includes/common.php create mode 100644 includes/footer.php create mode 100644 includes/header.php create mode 100644 login.php create mode 100644 logout.php create mode 100644 register.php create mode 100644 setup.php diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..668a5c9 --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,50 @@ +:root { + --primary-color: #4F46E5; + --secondary-color: #10B981; + --bg-color: #F3F4F6; + --surface-color: #FFFFFF; + --text-color: #111827; + --gradient: linear-gradient(to right, var(--primary-color), var(--secondary-color)); +} + +body { + font-family: 'Inter', sans-serif; + background-color: var(--bg-color); + color: var(--text-color); +} + +h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { + font-family: 'Georgia', serif; +} + +.navbar { + background: var(--gradient); +} + +.card { + border-radius: 0.5rem; + border: 1px solid #e5e7eb; + box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); +} + +.btn-primary { + background-color: var(--primary-color); + border-color: var(--primary-color); + padding: 0.75rem 1.5rem; + border-radius: 0.5rem; + font-weight: bold; +} + +.btn-primary:hover { + background-color: #4338ca; + border-color: #4338ca; +} + +.form-control:focus { + border-color: var(--primary-color); + box-shadow: 0 0 0 0.25rem rgba(79, 70, 229, 0.25); +} + +.form-floating > .form-control:focus ~ label { + color: var(--primary-color); +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..fc1e58a --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,20 @@ +// assets/js/main.js +(function () { + 'use strict' + + // Fetch all the forms we want to apply custom Bootstrap validation styles to + var forms = document.querySelectorAll('.needs-validation') + + // Loop over them and prevent submission + Array.prototype.slice.call(forms) + .forEach(function (form) { + form.addEventListener('submit', function (event) { + if (!form.checkValidity()) { + event.preventDefault() + event.stopPropagation() + } + + form.classList.add('was-validated') + }, false) + }) + })() diff --git a/includes/common.php b/includes/common.php new file mode 100644 index 0000000..3a419f1 --- /dev/null +++ b/includes/common.php @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000..c212f9f --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000..fc865b7 --- /dev/null +++ b/includes/header.php @@ -0,0 +1,41 @@ + + + + + + <?= htmlspecialchars($title ?? 'TimeSheet') ?> + + + + + + + + +
diff --git a/index.php b/index.php index 7205f3d..2374bd0 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,30 @@ - - - - - - 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

+ +
+

Welcome to Your TimeSheet

+
+

This is your dashboard. The timesheet entry table will be displayed here soon.

+

You are logged in as .

+
-
-
- Page updated: (UTC) -
- - + + +
+

Under Construction!

+

The main functionality for logging hours and viewing reports is currently being built. Check back soon!

+
+ + + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..9dc206c --- /dev/null +++ b/login.php @@ -0,0 +1,76 @@ +prepare("SELECT id, username, password_hash FROM users WHERE username = ?"); + $stmt->execute([$username]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password_hash'])) { + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $user['username']; + header('Location: index.php'); + exit; + } else { + $errors[] = 'Invalid username or password.'; + } + } catch (PDOException $e) { + $errors[] = 'Database error. Please try again later.'; + } + } +} + +require_once __DIR__ . '/includes/header.php'; +?> + +
+
+
+
+

Login

+ + +
+

+
+ + +
+
+ + +
Please enter your username.
+
+
+ + +
Please enter your password.
+
+
+ +
+
+

+ Don't have an account? Register here. +

+
+
+
+
+ + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..80a0565 --- /dev/null +++ b/logout.php @@ -0,0 +1,18 @@ + diff --git a/register.php b/register.php new file mode 100644 index 0000000..0d9727a --- /dev/null +++ b/register.php @@ -0,0 +1,102 @@ +prepare("SELECT id FROM users WHERE username = ?"); + $stmt->execute([$username]); + if ($stmt->fetch()) { + $errors[] = 'Username is already taken.'; + } else { + $password_hash = password_hash($password, PASSWORD_DEFAULT); + $stmt = $pdo->prepare("INSERT INTO users (username, password_hash) VALUES (?, ?)"); + $stmt->execute([$username, $password_hash]); + + // Log the user in + $_SESSION['user_id'] = $pdo->lastInsertId(); + $_SESSION['username'] = $username; + + header('Location: index.php'); + exit; + } + } catch (PDOException $e) { + $errors[] = 'Database error. Please try again later.'; + } + } +} + +require_once __DIR__ . '/includes/header.php'; +?> + +
+
+
+
+

Create an Account

+ + +
+ +

+ +
+ + +
+
+ + +
Please enter a username.
+
+
+ + +
Please enter a password.
+
+
+ + +
Please confirm your password.
+
+
+ +
+
+

+ Already have an account? Login here. +

+
+
+
+
+ + diff --git a/setup.php b/setup.php new file mode 100644 index 0000000..487c529 --- /dev/null +++ b/setup.php @@ -0,0 +1,33 @@ +exec(" + CREATE TABLE IF NOT EXISTS users ( + id INT AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(50) NOT NULL UNIQUE, + password_hash VARCHAR(255) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ); + "); + + $pdo->exec(" + CREATE TABLE IF NOT EXISTS timesheets ( + id INT AUTO_INCREMENT PRIMARY KEY, + user_id INT NOT NULL, + work_date DATE NOT NULL, + hours DECIMAL(4, 2) 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, + UNIQUE KEY user_date (user_id, work_date) + ); + "); + + echo "Database setup completed successfully."; + +} catch (PDOException $e) { + die("Database setup failed: " . $e->getMessage()); +} +?> \ No newline at end of file