garbage commit
This commit is contained in:
parent
63ae0f7b13
commit
a7539187d1
6 changed files with 99 additions and 28 deletions
BIN
images/65b3ae93-cfd3-47a8-ab3d-5db542a3f0e7.webp
Normal file
BIN
images/65b3ae93-cfd3-47a8-ab3d-5db542a3f0e7.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 346 KiB |
|
@ -41,7 +41,7 @@
|
|||
<td class="content">
|
||||
<h2>Login to monotreme.org</h2>
|
||||
<!-- Login Form -->
|
||||
<div class="login">
|
||||
<div class="form-container">
|
||||
<form action="/login/" method="post">
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" id="username" name="username" required>
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
<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>
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
<br>
|
||||
|
@ -45,6 +48,7 @@
|
|||
<input type="submit" value="Register">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
## monotreme.org
|
||||
|
||||
A joke site
|
||||
A joke site that I'm putting entierly too much effort into. Like, seriously, I'm spending way too much time on this. I should be working on [fddl](https://git.fddl.dev/fddl/fddl).
|
92
scripts/register.cgi
Normal file
92
scripts/register.cgi
Normal file
|
@ -0,0 +1,92 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "Content-type: text/html"
|
||||
echo ""
|
||||
|
||||
# Log the raw POST data for debugging
|
||||
read POST_DATA
|
||||
echo "POST Data: $POST_DATA" >> /tmp/register_form.log
|
||||
|
||||
# URL decoding function
|
||||
urldecode() {
|
||||
local url_encoded="${1//+/ }"
|
||||
printf '%b' "${url_encoded//%/\\x}"
|
||||
}
|
||||
|
||||
# Parse the form data using IFS
|
||||
USERNAME=""
|
||||
EMAIL=""
|
||||
PASSWORD=""
|
||||
CONFIRM_PASSWORD=""
|
||||
|
||||
IFS='&' # Split fields by "&"
|
||||
for param in $POST_DATA; do
|
||||
IFS='=' read -r key value <<< "$param"
|
||||
key=$(urldecode "$key")
|
||||
value=$(urldecode "$value")
|
||||
|
||||
case $key in
|
||||
username) USERNAME="$value" ;;
|
||||
email) EMAIL="$value" ;;
|
||||
password) PASSWORD="$value" ;;
|
||||
confirm_password) CONFIRM_PASSWORD="$value" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if passwords match
|
||||
if [ "$PASSWORD" != "$CONFIRM_PASSWORD" ]; then
|
||||
cat <<EOF
|
||||
<html>
|
||||
<head><title>Registration Failed</title></head>
|
||||
<body>
|
||||
<h1>Passwords do not match!</h1>
|
||||
<a href="/login/register/">Go back</a>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Hash the password using SHA-256
|
||||
PASSWORD_HASH=$(echo -n "$PASSWORD" | sha256sum | awk '{print $1}')
|
||||
|
||||
# Insert the user into the SQLite database
|
||||
DB_PATH="/var/lib/monotreme/data/monotreme.db"
|
||||
sqlite3 $DB_PATH "INSERT INTO users (username, email, password_hash) VALUES ('$USERNAME', '$EMAIL', '$PASSWORD_HASH');" 2>> /tmp/register_form.log
|
||||
|
||||
# Log the username and email for debugging
|
||||
echo "Username: $USERNAME, Email: $EMAIL" >> /tmp/register_form.log
|
||||
|
||||
# Create the email with proper headers
|
||||
EMAIL_BODY=$(cat <<EOF
|
||||
From: info@monotreme.org
|
||||
To: $EMAIL
|
||||
Subject: Welcome to monotreme.org
|
||||
|
||||
Hello $USERNAME,
|
||||
|
||||
Thank you for registering at monotreme.org. You can now log in with your credentials. I hope you enjoy the world of the monotreme!
|
||||
|
||||
Best regards,
|
||||
Tristan
|
||||
monotreme.org team
|
||||
EOF
|
||||
)
|
||||
|
||||
# Log the email body for debugging
|
||||
echo "Email Body: $EMAIL_BODY" >> /tmp/register_form.log
|
||||
|
||||
# Send the email using msmtp (or your protonmail-bridge setup)
|
||||
echo "$EMAIL_BODY" | msmtp --from=default "$EMAIL"
|
||||
|
||||
# Response back to the browser
|
||||
cat <<EOF
|
||||
<html>
|
||||
<head><title>Registration Successful</title></head>
|
||||
<body>
|
||||
<h1>Registration successful!</h1>
|
||||
<p>A confirmation email has been sent to $EMAIL.</p>
|
||||
<a href="/login/">Go to login page</a>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
27
styles.css
27
styles.css
|
@ -79,31 +79,6 @@ body {
|
|||
vertical-align: top;
|
||||
}
|
||||
|
||||
.login {
|
||||
width: 200px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 20px;
|
||||
background-color: #eeeeee;
|
||||
/* box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); */
|
||||
}
|
||||
|
||||
.login form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.login label,
|
||||
.login input {
|
||||
margin: 5px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
width: 200px;
|
||||
margin: 0 auto;
|
||||
|
@ -113,7 +88,7 @@ body {
|
|||
align-items: center;
|
||||
padding: 20px;
|
||||
background-color: #eeeeee;
|
||||
/* box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); */
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.form-container form {
|
||||
|
|
Loading…
Reference in a new issue