diff options
author | ubq323 <ubq323@ubq323.website> | 2021-12-11 20:28:36 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2021-12-11 20:28:36 +0000 |
commit | e79fe819f672d3454532181182732080e056592a (patch) | |
tree | d242d5e454026e40ebeeaa0c655e7764075ebd8e /embed_old.cgi |
add existing content
Diffstat (limited to 'embed_old.cgi')
-rwxr-xr-x | embed_old.cgi | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/embed_old.cgi b/embed_old.cgi new file mode 100755 index 0000000..f574036 --- /dev/null +++ b/embed_old.cgi @@ -0,0 +1,104 @@ +#!/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 +import sys + +from os import getenv +if __name__ == "__main__": + print("Content-Type: text/html") + qs = getenv("QUERY_STRING") + qs = qs.replace("%20"," ") + try: + ind = order.index(qs) + except ValueError: + print() + print('<h1 style="color: red">no</h1>') + else: + correct_hn = urlparse(george[qs]).hostname + + rf = getenv("HTTP_REFERER",None) + if rf is not None: + our_hn = urlparse(rf).hostname + if our_hn != correct_hn: + print() + print('<h1 style="color: red">no</h1>') + sys.exit(0) + + 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"""<!DOCTYPE html> +<html> + <head> + <base target="_parent"> + </head> + <body> + <style> + body,html {{ + overflow: hidden; + font-family: sans-serif; + padding:0; + margin:0; + }} + main {{ + margin:0; + padding-left: 5px; + padding-right: 5px; + height: 45px; + border: 1px solid black; + box-shadow: 5px 5px black; + /*background-color: pink;*/ + display: flex; + flex-wrap: nowrap; + justify-content: space-between; + }} + #george {{ + color: cyan; + text-decoration: underline; + text-decoration-color: blue; + text-decoration-thickness: 2px; + font-style: oblique; + animation: 2s infinite alternate george; + }} + @media (prefers-reduced-motion) {{ + #george {{ animation: none; }} + }} + #noble {{ + font-size: min(3vw, 12pt); + }} + p {{ + white-space: nowrap; + align-self: center; + }} + @keyframes george {{ + from {{ + letter-spacing: 1px; + }} + to {{ + letter-spacing: 6px; + }} + }} + a {{ + color: blue; + }} + </style> + <main> + <p><a href="{p}">< PREV</a></p> + <p id="noble"> + The <a href="https://george.gh0.pw" id="george">GEORGE</a> is a noble animal. + </p> + <p><a href="{n}">NEXT ></a></p> + </main> + </body> +</html>""") + |