diff --git a/articles-0.pickle b/articles-0.pickle deleted file mode 100644 index 5a80d20..0000000 Binary files a/articles-0.pickle and /dev/null differ diff --git a/comments.py b/comments.py new file mode 100755 index 0000000..318030b --- /dev/null +++ b/comments.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +from htmlgen import * +import storage +import cgi +import random +import base64 +from io import BytesIO +from captcha.image import ImageCaptcha +import time +print("Content-type: text/html\r\n\r\n") +aid=form["aid"] +form=cgi.FieldStorage() +try: + seed=form["seed"] + random.seed(seed) + checkstr=list("".join(random.choice(string.digits+string.ascii_lowercase) for _ in range(5))) + if not checkstr == form["checkstr"]: + print("Captcha's wrong") + raise Exception() + username=form["username"] + message=form["message"] + timestamp=int(time.time()) + data={"name":"","markdown":message,"author":username,"date":timestamp} + storage.append("comments-%i"%aid,data) +except: + pass + +seed=random.SystemRandom().randint(0,2**24) +random.seed(seed) +checkstr=list("".join(random.choice(string.digits+string.ascii_lowercase) for _ in range(5))) +image = ImageCaptcha() +capt = image.generate(checkstr) +html=htmlgen.HTMLgen(pagelayout.getLayoutXML().decode('utf-8'),"Comments") +html.appendHTML("
"%seed) +html.appendHTML("
") +html.appendHTML("