commit 341ff4763550e3f6298624dbbffa7cbd99bd7bc8 Author: bryce Date: Wed Jul 23 17:36:36 2025 +1200 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/admin_settings.php b/admin_settings.php new file mode 100644 index 0000000..e69de29 diff --git a/create_list.php b/create_list.php new file mode 100644 index 0000000..e69de29 diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000..680956e --- /dev/null +++ b/css/style.css @@ -0,0 +1,380 @@ +/* [ LIGHT theme ] */ +:root { + --clr-background: #ffffff; /* white */ + --clr-surface: #f8f9fa; /* Very Light gray */ + --clr-text-primary: #333333; /* dark gray */ + --clr-text-secondary: #555555; /* medium gray */ + --clr-accent-primary: #5a9bd5; /* muted blue */ + --clr-accent-hover: #4784b3; /* slightly darker mute blue */ + --clr-accent-secondary: #6c757d; /* muted gray */ + +} + +body { + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + line-height: 1.6; + background-color: #f0f2f5; /* Light Grey BG */ + color: #333; /* Dark Grey */ + padding: 20px; +} + +.container { + max-width: 960px; + margin: 0 auto; + background-color: #fff; /* white BG */ + padding: 20px 30px; + border-radius: 10px; + box-shaddow: 0 4px 15px rgba(0, 0, 0, 0.1) +} + +h1, h2, h3, h4, h5, h6 { + color: #007bff; /* Primary Blue */ + margin-bottom: 20px; + padding-bottom: 5px; + border-bottom: 1px solid #eee; /* Light Grey */ +} + +h2 { + font-size: 2.2em; +} + +h3 { + font-size: 1.8em; +} + +h4 { + font-size: 1.4em; +} + +p { + margin-bottom: 10px; +} + +ul { + list-style: none; + padding: 0; + margin-bottom: 20px; +} + +li { + background-color: #e9f2ff; /* Very Light Blue */ + margin-bottom: 10px; + padding: 12px 20px; + border-radius: 6px; + display: flex; + justify-content: space-between; + align-itmes: center; + border-left: 5px; solid #007bff; /* Primary Blue */ +} + +li:hover { + background-color: #dae8ff; /* slightly Darker Blue */ +} + +li a { + text-decoration: none; + color: #0056b3; /* Darker Blue */ + font-wieght: bold; + flex-grow: 1; +} + +li a:hover { + text-decoration: underline; +} + +form { + background-color: #fefefe; /* Near White */ + padding: 25px; + border-radius: 8px; + margin-top: 25px; + border: 1px solid #eee; /* Light Grey */ +} + +label { + display: block; + margin-bottom: 8px; + font-weight: bold; + color: #555; /* Medium Grey */ +} + +input[type="text"], +input[type="password"], +textarea, +select { + width: 100%; + padding: 12px; + margin-bottom: 18px; + border: 1px solid #ccc; /* Light Grey */ + border-radius: 5px; + font-size: 1rem; + font-family: inherit; + color: #333; /* Dark Grey */ + background-color: #fff; /* White */ +} + +input[type="submit"], +.button { + background-color: 007bff; /* Primary Blue */ + color: #fff; /* white */ + padding: 12px 25px; + border: none; + border-radius: 5px; + cursor: pointer; + font-size: 1.05rem; + font-weight: bold; + text-decoration: none; + display: inline-block; + transition: background-color 0.2s ease; + margin-right: 10px; +} + +input[type="submit"]:hover, +.button:hover { + background-color: #0056b3; /* Darker Blue */ +} + +.button-secondary { + background-color: #6c757d; /* grey */ +} + +.button-secondary:hover { + background-color: #5a6268; /* Darker Grey */ +} + +.button-danger { + background-color: #dc3545; /* red */ +} + +.button-danger:hover { + background-color: #c82333; /* Darker Red */ +} + + line-height: 1.6; + background-color: #f0f2f5; /* Lt. Blue Grey BG */ + color: #333; + padding: 20px; + .container { + margin: 0 auto; + background-color: #fff; + padding: 20px 30px; + border-radius: 10px; + box-shaddow: 0 4px 15px rgba(0, 0, 0, 0.1max-width: 960px; + + + +h1, h2, h3, h4, h5, h6 { + color: #007bff; /* Primary Blue */ + margin-bottom: 20px; + padding-bottom: 5px; + border-bottom: 1px solid #eee; +} } + +h2 { + font-size: 2.2em; +} + +h3 { + font-size: 1.8em; +} + +h4 { + font-size: 1.4em; +} + +p { + margin-bottom: 10px; +} + +ul { + list-style: none; + padding: 0; + margin-bottom: 20px; +} + +li { + background-color: #e9f2ff; /* Very Light Blue */ + margin-bottom: 10px; + padding: 12px 20px; + border-radius: 6px; + display: flex; + justify-content: space-between; + align-itmes: center; + border-left: 5px; solid #007bff; /* accent border */ +} + +li:hover { + background-color: #dae8ff; /* slightly darker on hover */ +} + +li a { + text-decoration: none; + color: #005ight} /* Dark Grey * /* white BG * /* Light Grey *PrDmary B + /* Darker Blue *font-wieght: bold; + flex-grow: 1;/ + + li a:hover { + text-decoration: underline; +} + +form { + background-color: #fefefe; /* Near White */ + padding: 25px; + border-radius: 8px; + margin-top: 25px; + border: 1px solid #eee; /* Light Grey */ +} + + label { + display: block; + margin-bottom: 8px; + font-weight: bold; + color: #555; /* Medium Grey */ +} + + input[type="text"], + input[type="password"], + textarea, + select { + width: 100%; + padding: 12px; + margin-bottom: 18px; + border: 1px solid #ccc; /* Light Grey */ + +border-radius: 5px; +font-size: 1rem; +font-family: inherit; +color: #333; /* Dark Grey */ +background-color: #fff; /* White */ } + +input[type="submit"], +.button { + background-color: 007bff; /* Primary Blue */ + color: #fff; /* white */ + padding: 12px 25px; + border: none; + border-radius: 5px; + cursor: pointer; + font-size: 1.05rem; + font-weight: bold; + text-decoration: none; + display: inline-block; + transition: background-color 0.2s ease; + margin-right: 10px; +} + +input[type="submit"]:hover, +.button:hover { + background-color: #0056b3; /* Darker Blue */ +} + +.button-secondary { + background-color: #6c757d; /* grey */ +} + +.button-secondary:hover { + background-color: #5a6268; /* Darker Grey */ +} + +.button-danger { + background-color: #dc3545; /* red */ +} + +.button-danger:hover { + background-color: #c82333; /* Darker Red */ +} + +.logout-link { + display: block; + margin-top: 30px; + text-align: right; + color: 007bff; /* Primary Blue */ + text-decoration: none; + font-weight: bold; + font-size: 0.9em; +} + +.logout-link:hover { + text-decoration: underline; +} + +.message { + padding: 12px 20px; + margin-bottom: 20px; + border-radius: 6px; + font-weight: bold; + color: #fff; /* white */ +} + +.message.error { + background-color: dc3545; /* Red - Error */ +} + +.message.success { + background-color: #28a745; /* Green Success */ +} + +.message.info { + background-color: #17a2b8; /* Cyan Info */ +} + +table { + width: 100%; + border-colapse: colapse; + margin-bottom: 20px; + background-color: #fff; /* white */ + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); /* Light Grey */ + border-radius: 8px; + overflow: hidden; +} + +table th, table td { + border: 1px solid #e0e0e0; /* Light Grey */ + padding: 12px 15px; + text-align: left; +} + +table th { + background-color: #f8f9fa; /* Light Grey */ + color: #495057; /* Dark Grey */ + font-weight: bold; + text-transform: uppercase; + font-size: 0.9em; +} + +table tr:nth-child(even) { + background-color: #fdfdfe; /* Very Light Grey */ +} + +table tr:hover { + background-color: #f0f8ff; /* Very Light Blue */ +} + +table td form { + margin: 0; + padding: 0; + border: none; + background: none; +} + +table td input[type="password"] { + width: auto; + max-width: 150px; + margin-bottom: 0; + padding: 8px; + font-size: 0.9em; + display: inline-block; +} + +.list-item-actions .button { + padding: 6px 12px; + font-size: 0.85em; + margin-right: 0; +} + +.list-item-completed { + text-decoration: line-through; + color: #6c757d; /* Grey */ + border-left-color: #6c757d; /* Grey */ + background-color: #e2e6ea; /* Light Grey */ +} + diff --git a/dashboard.php b/dashboard.php new file mode 100644 index 0000000..e69de29 diff --git a/db_setup_rmAfter1Use.php b/db_setup_rmAfter1Use.php new file mode 100644 index 0000000..94a315c --- /dev/null +++ b/db_setup_rmAfter1Use.php @@ -0,0 +1,70 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $sql = " + CREATE TABLE IF NOT EXISTS users ( + id INTERGER PRIMARY KEY AUTOINCREMENT, + usr TEXT UNIQUE NOT NULL, + pass TEXT NOT NULL, + is_admin BOOLEAN + ); + + CREATE TABLE IF NOT EXISTS list_types ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL + ); + + CREATE TABLE IF NOT EXISTS lists ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + usr_id INTEGER NOT NULL, + list_type_id INTEGER NOT NULL, + title TEXT NOT NULL, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (usr_id) REFERENCES users(id) ON DELETE CASCADE, + FOREIGN KEY (list_type_id) REFERENCES list_types(id) ON DELETE CASCADE + ); + + CREATE TABLE IF NOT EXISTS list_items ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + list_id INTEGER NOT NULL, + description TEXT NOT NULL, + is_completed BOOLEAN DEFAULT 0, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + ompleted_at DATETIME, + FOREIGN KEY (list_id) REFERENCES lists(id) ON DELETE CASCADE + ); + "; + + $initDataSql = " + INSERT OR IGNORE INTO list_types (name) VALUES ('Shopping'); + INSERT OR IGNORE INTO list_types (name) VALUES ('To-Do'); + INSERT OR IGNORE INTO list_types (name) VALUES ('Stream Ideas'); + INSERT OR IGNORE INTO list_types (name) VALUES ('Video Ideas'); + INSERT OR IGNORE INTO list_types (name) VALUES ('Work'); + "; + + $pdo->exec($sql); + $pdo->exec($initDataSql); + + echo "Database schema created and initial data inserted successfully at: " . htmlspecialchars(#dbPath); + + $username = 'testuser'; + $password = 'pa$$123'; + $is_admin = 1; + $hashedPassword = password_hash($password, PASSWORD_DEFAULT); + + $stmt = $pdo->prepare("INSERT OR IGNORE INTO users (usr, pass, is_admin) VALUES (?, ?, ?)"); + if ($stmt->execute([$username, $hashedPassword])) { + echo "
Test User '$username' Created (if it doesn't already exist). Password: $password - Is_Admin for Initial Dev Purposes" + } +} catch (PDOException $e) { + die("Database setup failed: " . $e->getMessage()) +} +?> diff --git a/i/auth.php b/i/auth.php new file mode 100644 index 0000000..f3730e8 --- /dev/null +++ b/i/auth.php @@ -0,0 +1,70 @@ +prepare("SELECT id, password, is_admin FROM users WHERE username = ?"); + $stmt->execute([$username]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + session_start(); + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $user['username']; + return true; + } + return false; +} + +function checkAuth() { + session_start(); + if (!isset($_SESSION['user_id'])) { + header('Location: login.php'); + exit(); + } +} + +function checkAdminAuth() { + session_start(); + + if (!isset($_SESSION['user_id'])) { + $_SESSION['message'] = 'You Must be logged in to access this page.'; + header('Location: login.php'); + exit(); + } + + $pdo = getDbConnection(); + $stmt = $pdo->prepare("SELECT is_admin FROM users WHERE id = ?"); + $stmt->execute([$_SESSION['user_id']]); + $user = $stmt->fetch(); + + if (!$user || $user['is_admin'] !=1) { + $_SESSION['message'] = 'You do NOT have the required permission to access that page.'; + header('Location: dashboard.php'); + exit(); + } +} + +function isAdmin() { + session_start(); + + if (!isset($_SESSION['user_id'])) { + return false; + } + + $pdo = getDbConnection(); + $stmt = $pdo->prepare("SELECT is_admin FROM users WHERE id = ?"); + $stmt->execute([$_SESSION['user_id']]); + $user = $stmt->fetch(); + + return ($user && $user['is_admin'] == 1); +} + +function logout() { + session_start(); + session_unset(); + session_destroy(); + header('Location: login.php'); + exit(); +} +?> diff --git a/i/config.php b/i/config.php new file mode 100644 index 0000000..377eb2f --- /dev/null +++ b/i/config.php @@ -0,0 +1,4 @@ + + diff --git a/i/db.php b/i/db.php new file mode 100644 index 0000000..361e3ab --- /dev/null +++ b/i/db.php @@ -0,0 +1,10 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $pdo->setAttribute() + } +} diff --git a/i/footer.php b/i/footer.php new file mode 100644 index 0000000..e69de29 diff --git a/i/header.php b/i/header.php new file mode 100644 index 0000000..6fcfa8b --- /dev/null +++ b/i/header.php @@ -0,0 +1,66 @@ + + + + + + + + Lists - Brycefromnz.live + + + + +
+
+
+
+
+ + +
+
+
+ +
+ + + + + +
+
+
+
diff --git a/index.php b/index.php new file mode 100644 index 0000000..3de7c5f --- /dev/null +++ b/index.php @@ -0,0 +1,24 @@ + + + + +Bryce's Lists + + + +
+

Bryce's Lists

+
+
+

Choose one

+
+
+ +
+
+

+

+
+
diff --git a/list_type_view.php b/list_type_view.php new file mode 100644 index 0000000..e69de29 diff --git a/login.php b/login.php new file mode 100644 index 0000000..e69de29 diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..e69de29 diff --git a/view_list.php b/view_list.php new file mode 100644 index 0000000..e69de29