#!/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") form=cgi.FieldStorage() aid=form["aid"] 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("