#!/usr/bin/python3 import sqlite3 import os import http.cookies import time print("Content-Type: text/html") print() # Ensure the session_id is properly parsed cookie = http.cookies.SimpleCookie(os.environ.get('HTTP_COOKIE', '')) session_id = cookie.get('session_id') if session_id: session_id = session_id.value # Connect to SQLite and check the session db = sqlite3.connect('/var/lib/monotreme/data/monotreme.db') cursor = db.cursor() # Check if the session exists and is still valid cursor.execute("SELECT username FROM sessions WHERE session_id=? AND expires_at > ?", (session_id, int(time.time()))) result = cursor.fetchone() if result: username = result[0] print(f"
This is your user panel.
") print("This page contains a couple things once I figure out how databases work.
") print("Click here to logout.
") # Fetch and display profile info cursor.execute("SELECT email, date_joined, last_login FROM users WHERE username=?", (username,)) profile_info = cursor.fetchone() if profile_info: email, date_joined, last_login = profile_info print(f"Email: {email}
") print(f"Date Joined: {date_joined}
") print(f"Last Login: {last_login}
") # Fetch and display recent activity cursor.execute("SELECT action, timestamp FROM activity_log WHERE username=? ORDER BY timestamp DESC LIMIT 5", (username,)) recent_activity = cursor.fetchall() print("{action} at {time_str}
") else: print("No recent activity
") # Fetch and display notifications cursor.execute("SELECT message, timestamp FROM notifications WHERE username=? AND read=0 ORDER BY timestamp DESC", (username,)) notifications = cursor.fetchall() print("{message} at {time_str}
") else: print("No new notifications
") else: print("