From: Drew Fisher Date: Fri, 28 Jan 2011 20:23:09 +0000 (-0600) Subject: Implement antispam tactics. X-Git-Url: https://git.zarvox.org/shortlog/month?a=commitdiff_plain;h=4ee8790bce7d74dc2dcc5e4e99c5ed92d6b9f646;p=shortlog.git Implement antispam tactics. I've been getting a bunch of spam comments lately (I knew this day would come). This adds a field to the comment-submission page, and verifies that the field contains a four-digit number. Hopefully this will stop most automated bots. --- diff --git a/shortlog.py b/shortlog.py index a341b66..a2606d3 100644 --- a/shortlog.py +++ b/shortlog.py @@ -147,9 +147,21 @@ class day: web.template.Template.globals['len'] = len print render.noentry("%s-%s-%s" % (year, month, day)) + def verify(self, test): + if len(test) != 4: + return False + try: + x = int(test,10) + except ValueError: + return False + return True def POST(self, year, month, day): i = web.input() + bottest = i.bottest.strip() + if not self.verify(bottest): + web.redirect("http://127.0.0.1/go_away_bot.html") + return name = i.name.strip() email = i.email.strip() website = i.website.strip() diff --git a/templates/day.html b/templates/day.html index df4b4fe..b2a5eac 100644 --- a/templates/day.html +++ b/templates/day.html @@ -34,6 +34,7 @@ $for c in comments:

Name

Email (required, but won't be posted)

Website (optional)

+

Antispam: enter a four digit number