building out site

This commit is contained in:
Tristan Smith 2024-09-21 21:01:01 -04:00
parent 948b481bca
commit d9db0eafac
9 changed files with 249 additions and 68 deletions

View file

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>monotreme.org</title>
<title>About Us - monotreme.org</title>
<link rel="stylesheet" href="../styles.css">
</head>
<body>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>monotreme.org</title>
<title>blog - monotreme.org</title>
<link rel="stylesheet" href="../styles.css">
</head>
<body>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>monotreme.org</title>
<title>Contact us! - monotreme.org</title>
<link rel="stylesheet" href="../styles.css">
</head>
<body>

56
login/forgot/index.html Normal file
View file

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Forgot Password - monotreme.org</title>
<link rel="stylesheet" href="../../styles.css">
</head>
<body>
<table>
<!-- Header -->
<tr>
<td colspan="2" class="header">
<h1>Forgot Password</h1>
</td>
</tr>
<!-- Main Content and Sidebar -->
<tr>
<!-- Sidebar -->
<td class="sidebar">
<p><strong>Quick Links</strong></p>
<ul>
<li><a href="/platypus/">The Noble Platypus</a></li>
<li><a href="/echidna/">The Royal Echidna</a></li>
<li><a href="/monotremes/">About Monotremes</a></li>
</ul>
</td>
<!-- Main Content Area -->
<td class="content">
<h2>Reset your password</h2>
<!-- Forgot Password Form -->
<div class="forgot-password">
<form action="/cgi-bin/forgot_password.cgi" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<br>
<input type="submit" value="Reset Password">
</form>
</div>
</td>
</tr>
<!-- Footer -->
<tr>
<td colspan="2" class="footer">
<p>&copy; 2024 monotreme.org</p>
</td>
</tr>
</table>
</body>
</html>

View file

@ -51,6 +51,10 @@
<br>
<input type="submit" value="Login">
</form>
<div class="controls">
<a href="/login/register/">Register</a>
<a href="/login/forgot/">Forgot <br />Password</a>
</div>
</div>
<img src="../echidna.png" alt="echidna">

61
login/register/index.html Normal file
View file

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Register - monotreme.org</title>
<link rel="stylesheet" href="../../styles.css">
</head>
<body>
<table>
<!-- Header -->
<tr>
<td colspan="2" class="header">
<h1>Register an account</h1>
</td>
</tr>
<!-- Main Content and Sidebar -->
<tr>
<!-- Sidebar -->
<td class="sidebar">
<p><strong>Quick Links</strong></p>
<ul>
<li><a href="/platypus/">The Noble Platypus</a></li>
<li><a href="/echidna/">The Royal Echidna</a></li>
<li><a href="/monotremes/">About Monotremes</a></li>
</ul>
</td>
<!-- Main Content Area -->
<td class="content">
<h2>Create a new account</h2>
<!-- Register Form -->
<div class="register">
<form action="/cgi-bin/register.cgi" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<br>
<label for="confirm_password">Confirm Password:</label>
<input type="password" id="confirm_password" name="confirm_password" required>
<br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<input type="submit" value="Register">
</form>
</div>
</td>
</tr>
<!-- Footer -->
<tr>
<td colspan="2" class="footer">
<p>&copy; 2024 monotreme.org</p>
</td>
</tr>
</table>
</body>
</html>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>monotreme.org</title>
<title>About the monotremes - monotreme.org</title>
<link rel="stylesheet" href="../styles.css">
</head>
<body>

48
scripts/login.cgi Normal file
View file

@ -0,0 +1,48 @@
#!/usr/bin/python3
import sqlite3
import hashlib
import cgi
import os
import http.cookies
# Get form data
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
# Connect to SQLite and check credentials
db = sqlite3.connect('/var/lib/monotreme/data/monotreme.db')
cursor = db.cursor()
# Fetch the user's stored hashed password
cursor.execute("SELECT password_hash FROM users WHERE username=?", (username,))
result = cursor.fetchone()
if result:
stored_password_hash = result[0]
# Hash the entered password and compare it
entered_password_hash = hashlib.sha256(password.encode()).hexdigest()
if entered_password_hash == stored_password_hash:
# Create a session (a simple token could be enough for now)
session_token = hashlib.sha256(os.urandom(32)).hexdigest()
# Set the session cookie
print("Content-Type: text/html")
print(f"Set-Cookie: session_id={session_token}; Path=/; HttpOnly")
print()
# Show success message or redirect to user panel
print("<h1>Login successful!</h1>")
print("<a href='/user_panel/'>Go to your dashboard</a>")
else:
print("Content-Type: text/html")
print()
print("<h1>Invalid username or password</h1>")
else:
print("Content-Type: text/html")
print()
print("<h1>Invalid username or password</h1>")
# Close the database connection
db.close()

View file

@ -104,6 +104,18 @@ body {
width: 100%;
}
.controls {
display: flex;
justify-content: space-between;
text-align: center;
width: 100%;
}
.controls a {
color: #4682b4; /* Steel blue */
text-decoration: none;
}
input[type="submit"] {
width: auto;
padding: 5px 10px;