#!/usr/bin/env python3 from georgedata import george order = list(george.keys()) # dicts guarantee key order as of 3.7 from urllib.parse import urlparse, parse_qs import sys from os import getenv if __name__ == "__main__": colors = { "bg": 'white', "fg": 'black', "george": 'blue', "links": 'blue' } print("Content-Type: text/html") qs = getenv("QUERY_STRING") member,real_qs = (qs.split('&', 1) + [''])[:2] query = parse_qs(real_qs) try: ind = order.index(member) except ValueError: print() print('

no

') else: correct_hn = urlparse(george[member]).hostname rf = getenv("HTTP_REFERER",None) if rf is not None: our_hn = urlparse(rf).hostname if our_hn != correct_hn: print() print('

no

') sys.exit(0) for q in query.keys(): if q.startswith('c_'): color = query[q][0] if color.isalnum() or (color[0] == '#' and color[1:].isalnum()): colors[q[2:]] = color l = len(order) ni = (ind + 1)%l pi = (ind - 1)%l n = george[order[ni]] p = george[order[pi]] ref = getenv("HTTP_REFERER","the") print(f"Content-Security-Policy: frame-ancestors {correct_hn} http://{correct_hn};") print() print( f"""

< PREV

The GEORGE is a noble animal.

NEXT >

""")