aboutsummaryrefslogtreecommitdiff
path: root/cgi-bin
diff options
context:
space:
mode:
authornathansmith117 <nathansmith@posteo.com>2025-03-12 08:07:18 -0600
committernathansmith117 <nathansmith@posteo.com>2025-03-12 08:07:18 -0600
commitc2d46da747c4901c7fd7821c0fde715dd6bbf3a1 (patch)
treeb22f0f20a0878211eea54a06878090c5643d97a4 /cgi-bin
parent04fdc9e72bf0ca77def196a1a2d4cd3514fbaeaf (diff)
Working on tv corner
Diffstat (limited to 'cgi-bin')
-rwxr-xr-xcgi-bin/blahaj_list.cgi123
-rwxr-xr-xcgi-bin/submit_blahaj_info.cgi114
2 files changed, 0 insertions, 237 deletions
diff --git a/cgi-bin/blahaj_list.cgi b/cgi-bin/blahaj_list.cgi
deleted file mode 100755
index e6bbc85..0000000
--- a/cgi-bin/blahaj_list.cgi
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/usr/bin/env python
-
-import cgi
-import json
-
-from bs4 import BeautifulSoup
-
-# Worse code here. Prepare your eyes for this monster.
-# Its almost as bad as programming anything in php or even worse javascript.
-
-print('Content-Type: text/html')
-
-# Mode for letting peope inject stuff.
-form = cgi.FieldStorage()
-unsafe_mode = form.getvalue("unsafe_mode") == "on"
-
-# Hehehe
-def check_for_injection(value):
- if bool(BeautifulSoup(value, "html.parser").find()) and not unsafe_mode:
- return """
- This silly silly tried to hack this website lmao.
- <a href=\"?unsafe_mode=on\">Click to see the website with the hack</a>
- """
-
- return value
-
-def create_blahaj_tables():
- try:
- tables_html = """
- <h1>Blahaj list!!!!!</h1>
- <table border="1" width="50%">
- <tr>
- <td>
- <h3><a href=\"../submit_blahaj_info.html\">Submit yours here if you haven't already!</a></h3>
- <h3><a href=\"../blahajRoom.html\">Back to blahaj room</a></h3>
- </td>
- </tr>
- </table>
- <br/>
- """
-
- with open("blahaj_info.json", "r") as fp:
- blahaj_list = json.load(fp)
-
- for blahaj in blahaj_list[::-1]:
- current_table = """
- <table border="1" width="50%">
- <tr>
- <td>
- <!-- Great place for an injection hint hint -->
- <h2>put_name_here</h2>
- <p>Date submitted: put_date_here</p>
- </td>
- </tr>
-
- <tr>
- <td>
- <p>put_info_here</p>
- </td>
- </tr>
- </table>
- """
-
- current_table = current_table.replace("put_name_here", check_for_injection(blahaj["name"]))
- current_table = current_table.replace("put_info_here", check_for_injection(blahaj["info"]))
- current_table = current_table.replace("put_date_here", check_for_injection(blahaj["date"]))
-
- tables_html += current_table
-
- return tables_html
-
- except FileNotFoundError: # No blahaj's yet
- return """
- <table border="1">
- <tr>
- <td>
- <h1>No blahaj's found ):</h1>
- <h2>Yours could be first tho :3</h2>
- <h3><a href=\"../submit_blahaj_info.html\">Submit yours here</a></h3>
- </td>
- </tr>
- </table>
- """
-
-html_text = """
-<!DOCTYPE html>
-<html>
-
-<head>
- <title>hehehe</title>
-
-<style>
-
-body {
- color: black;
- background-image: url('../images/blahaj_background.jpg');
-}
-
-table {
- color: black;
- background-color: #bebebe;
- margin-top: 10px;
- margin-bottom: 10px;
- margin-left: 10px;
- margin-right: 10px;
-}
-
-</style>
-</head>
-
-<body>
- <center>
- thing_to_replace
- </center>
-</body>
-
-</html>
-"""
-
-tables = create_blahaj_tables()
-html_text = html_text.replace("thing_to_replace", tables)
-
-print(html_text)
diff --git a/cgi-bin/submit_blahaj_info.cgi b/cgi-bin/submit_blahaj_info.cgi
deleted file mode 100755
index 4c2e1b6..0000000
--- a/cgi-bin/submit_blahaj_info.cgi
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/env python
-
-import cgi
-import json
-import datetime
-
-# Get the information given and dump it into a file.
-def handle_fields():
- form = cgi.FieldStorage()
-
- blahaj_name = form.getvalue("blahaj_name")
- blahaj_info = form.getvalue("blahaj_info")
-
- if blahaj_name == None:
- return "Blahaj name is required"
-
- if blahaj_info == None:
- blahaj_info = ""
-
- blahaj_list = []
-
- # Get existing data.
- try:
- with open("blahaj_info.json", "r") as fp:
- blahaj_list = json.load(fp)
- except FileNotFoundError:
- pass
-
- date = datetime.datetime.now()
- blahaj_entry = {"name": blahaj_name, "info": blahaj_info, "date": date.strftime("%B, %d %Y")}
-
- # Already been added.
- for blahaj in blahaj_list:
- if blahaj["name"] == blahaj_entry["name"] and blahaj["info"] == blahaj_entry["info"]:
- return "Already exists"
-
- # Dump new data.
- with open("blahaj_info.json", "w") as fp:
- blahaj_list.append(blahaj_entry)
- json.dump(blahaj_list, fp)
-
- return "submitted"
-
-def display_context(fields_reponse):
- print('Content-Type: text/html')
-
- html_text = """
- <!DOCTYPE html>
- <html>
-
- <head>
- <title>hehehe</title>
-
- <style>
-
- body {
- color: black;
- background-image: url('../images/blahaj_background.jpg');
- }
-
- table {
- color: black;
- background-color: #bebebe;
- margin-top: 10px;
- margin-bottom: 10px;
- margin-left: 10px;
- margin-right: 10px;
- }
-
- </style>
- </head>
-
- <body>
- <center>
- <table border="1" width="40%">
- <tr>
- <td>
- thing_to_replace
- </td>
- </tr>
- </table>
- </center>
- </body>
-
- </html>
- """
-
- # Place html tags in the "thing_to_replace" spot
- replace_text = ""
-
- if fields_reponse == "Blahaj name is required":
- replace_text = """
- <h1>Blahaj name required</h1>
- <h2><a href=\"../submit_blahaj_info.html\">Go back</a></h2>
- """
- elif fields_reponse == "Already exists":
- replace_text = """
- <h1>Blahaj already added</h1>
- <h2><a href=\"../submit_blahaj_info.html\">Go back</a></h2>
- """
- elif fields_reponse == "submitted":
- replace_text = """
- <h1>Blahaj submitted!</h1>
- <img src="https://media1.tenor.com/m/FKtdcMXKBhsAAAAC/yippee-happy.gif" alt="yippee!" width="90%">
- <h2><a href=\"blahaj_list.cgi\">See it in the list!</a></h2>
- """
-
- html_text = html_text.replace("thing_to_replace", replace_text)
-
- print(html_text)
-
-
-fields_reponse = handle_fields()
-display_context(fields_reponse)