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> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <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"> <link rel="stylesheet" href="../styles.css">
</head> </head>
<body> <body>

View file

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

View file

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

@ -1,69 +1,73 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>monotreme.org</title> <title>monotreme.org</title>
<link rel="stylesheet" href="../styles.css"> <link rel="stylesheet" href="../styles.css">
</head> </head>
<body> <body>
<table> <table>
<!-- Header --> <!-- Header -->
<tr> <tr>
<td colspan="2" class="header"> <td colspan="2" class="header">
<h1>Save the monotremes</h1> <h1>Save the monotremes</h1>
</td> </td>
</tr> </tr>
<!-- Navigation --> <!-- Navigation -->
<tr> <tr>
<td colspan="2" class="nav"> <td colspan="2" class="nav">
<a href="/">Home</a> <a href="/">Home</a>
<a href="/about/">About</a> <a href="/about/">About</a>
<a href="/blog/">Blog</a> <a href="/blog/">Blog</a>
<a href="/contact/">Contact</a> <a href="/contact/">Contact</a>
</td> </td>
</tr> </tr>
<!-- Main Content and Sidebar --> <!-- Main Content and Sidebar -->
<tr> <tr>
<!-- Sidebar --> <!-- Sidebar -->
<td class="sidebar"> <td class="sidebar">
<p><strong>Quick Links</strong></p> <p><strong>Quick Links</strong></p>
<ul> <ul>
<li><a href="/platypus/">The Noble Platypus</a></li> <li><a href="/platypus/">The Noble Platypus</a></li>
<li><a href="/echidna/">The Royal Echidna</a></li> <li><a href="/echidna/">The Royal Echidna</a></li>
<li><a href="/monotremes/">About Monotremes</a></li> <li><a href="/monotremes/">About Monotremes</a></li>
</ul> </ul>
</td> </td>
<!-- Main Content Area --> <!-- Main Content Area -->
<td class="content"> <td class="content">
<h2>Login to monotreme.org</h2> <h2>Login to monotreme.org</h2>
<!-- Login Form --> <!-- Login Form -->
<div class="login"> <div class="login">
<form action="/login/" method="post"> <form action="/login/" method="post">
<label for="username">Username:</label> <label for="username">Username:</label>
<input type="text" id="username" name="username" required> <input type="text" id="username" name="username" required>
<br> <br>
<label for="password">Password:</label> <label for="password">Password:</label>
<input type="password" id="password" name="password" required> <input type="password" id="password" name="password" required>
<br> <br>
<input type="submit" value="Login"> <input type="submit" value="Login">
</form> </form>
</div> <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"> <img src="../echidna.png" alt="echidna">
<img src="../platypus.png" alt="platypus"> <img src="../platypus.png" alt="platypus">
</td> </td>
</tr> </tr>
<!-- Footer --> <!-- Footer -->
<tr> <tr>
<td colspan="2" class="footer"> <td colspan="2" class="footer">
<p>&copy; 2024 monotreme.org</p> <p>&copy; 2024 monotreme.org</p>
</td> </td>
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>

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> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <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"> <link rel="stylesheet" href="../styles.css">
</head> </head>
<body> <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%; 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"] { input[type="submit"] {
width: auto; width: auto;
padding: 5px 10px; padding: 5px 10px;