first commit

This commit is contained in:
bryce
2025-07-23 17:36:36 +12:00
commit 341ff47635
16 changed files with 624 additions and 0 deletions

0
README.md Normal file
View File

0
admin_settings.php Normal file
View File

0
create_list.php Normal file
View File

380
css/style.css Normal file
View File

@@ -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 */
}

0
dashboard.php Normal file
View File

70
db_setup_rmAfter1Use.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
require_once '../i/config.php';
$db_path = DB_PATH;
try {
$pdo = new PDO('sqlite:' . $dbPath);
$pdo->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 "<br>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())
}
?>

70
i/auth.php Normal file
View File

@@ -0,0 +1,70 @@
<?php
require_once 'db.php';
function authenticateUser ($username, $password) {
$pdo = getDbConnection();
$stmt = $pdo->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();
}
?>

4
i/config.php Normal file
View File

@@ -0,0 +1,4 @@
<?php
define('DB_PATH', __DIR__ . '../../../dbs/lists/lists.sqlite');
?>

10
i/db.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
require_once 'config.php';
function getDbConnection() {
try {
$pdo = new PDO('sqlite: ' . DB_PATH);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute()
}
}

0
i/footer.php Normal file
View File

66
i/header.php Normal file
View File

@@ -0,0 +1,66 @@
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
require_once __DIR__ . '/auth.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="wdth=device-width, initial-scale=1.0">
<title>Lists - Brycefromnz.live</title>
<link rel="stylesheet" href="../css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body>
<header class="main-header">
<div class="container header-container">
<div class="header-left">
<div class="search-section">
<form action="/search_results.php" method="get" class="search_form">
<input type="search" name="query" placeholder="Search lists & terms. . ." class="search-input">
<button type="submit" class="search-button">Go</button>
</form>
</div>
</div>
<div class="header-right">
<button class="menu-toggle" aria-label="Toggle navigation">
<i class="fas fa-bars"></i>
</button>
<nav class="main-nav">
<ul>
<?php if (isset($_SESSION['user_id'])): ?>
<li><a href="../dashboard.php" class="button button-nav">Dashboard</a></li>
<li><a href="../create_list.php" class="button button-nav">Create New List</a></li>
<?php if (is_admin()): ?>
<li><a href="../admin_settings.php" class="btutton button-nav">Settings</a></li>
<?php endif; ?>
<li><a href="../logout.php" class="button button-nav button-logout">Logout</a></li>
<?php else: ?>
<li><a href="../login.php" class="button button-nav">Login</a></li>
<?php endif; ?>
</ul>
</nav>
<div class="login-status">
<?php if (isset($_SESSION['user_id'])): ?>
<span class="status-icon logged-in" title="Logged In">
<i class="fas fa-check-circle"></i>
</span>
<?php else: ?>
<span class="status-icon logged-out" title="Logged Out">
<i class="fas fa-times-circle"></i>
</span>
<?php endif; ?>
</div>
</div>
</div>
</header>
<main>

24
index.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
?>
<!doctype html>
<html lang=eng>
<head>
<title>Bryce's Lists</title>
<link rel='stylesheet' href='style.css'>
</head>
<body>
<div class='section'>
<h1>Bryce's Lists</h1>
</div>
<div class='section'>
<h4>Choose one</h4>
<div class='card'>
<div class='img'>
<img src='.jpg'>
</div>
<div class='name'>
<p class='line1'>
</div>
</div>
</div>

0
list_type_view.php Normal file
View File

0
login.php Normal file
View File

0
logout.php Normal file
View File

0
view_list.php Normal file
View File