diff options
| author | nathansmith117 <nathansmith117@sdf.org> | 2024-05-21 04:32:00 +0000 | 
|---|---|---|
| committer | nathansmith117 <nathansmith117@sdf.org> | 2024-05-21 04:32:00 +0000 | 
| commit | 4df21dd096b4d6fd25b11e0872c6329608204d62 (patch) | |
| tree | 8f158fcb78d43c0a2082cfc028bf4a4836a28941 /cgi-bin/blahaj_list.cgi | |
| parent | 8944954d2c85325a7af3d531e7490afb5e5e55eb (diff) | |
| download | shittyweb-4df21dd096b4d6fd25b11e0872c6329608204d62.tar.gz shittyweb-4df21dd096b4d6fd25b11e0872c6329608204d62.tar.bz2 shittyweb-4df21dd096b4d6fd25b11e0872c6329608204d62.zip  | |
User submitted blahajs working well
Diffstat (limited to 'cgi-bin/blahaj_list.cgi')
| -rwxr-xr-x | cgi-bin/blahaj_list.cgi | 107 | 
1 files changed, 107 insertions, 0 deletions
diff --git a/cgi-bin/blahaj_list.cgi b/cgi-bin/blahaj_list.cgi new file mode 100755 index 0000000..5342a98 --- /dev/null +++ b/cgi-bin/blahaj_list.cgi @@ -0,0 +1,107 @@ +#!/usr/bin/env python + +import cgi +import json + +# 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') + +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: +                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", blahaj["name"]) +                current_table = current_table.replace("put_info_here", blahaj["info"]) +                current_table = current_table.replace("put_date_here", 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 ):</h2> +                        <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)  | 
