aboutsummaryrefslogtreecommitdiffstats
path: root/blogthon.cgi
diff options
context:
space:
mode:
authorStefan Ritter <xeno@thehappy.de>2009-04-30 01:25:14 +0200
committerStefan Ritter <xeno@thehappy.de>2009-04-30 01:25:14 +0200
commitd62b62874b6735cc5aa93b5e057c489e468610b6 (patch)
tree3647144e8db3abbc3b2b51c7206ae9ba9cad0fff /blogthon.cgi
parentd82a5f63470f9b46acd1779d824affe4e41b7d7c (diff)
Spam:
* Removed blacklist * Added an addition to solve before adding a comment
Diffstat (limited to 'blogthon.cgi')
-rwxr-xr-xblogthon.cgi43
1 files changed, 27 insertions, 16 deletions
diff --git a/blogthon.cgi b/blogthon.cgi
index 14dafdb..f5d68d1 100755
--- a/blogthon.cgi
+++ b/blogthon.cgi
@@ -9,7 +9,7 @@
# Author: Stefan Ritter <xeno@thehappy.de>
# Description: A simple blogging software
-import cgi, os, time, glob, re, md5, sys
+import cgi, os, time, glob, re, md5, sys, random
import ConfigParser
def generate_uuid(string):
@@ -85,9 +85,13 @@ if not feed_display: feed_display = ""
ctitle = action.getvalue('ctitle')
cname = action.getvalue('cname')
ctext = action.getvalue('ctext')
+cquiz = action.getvalue('cquiz')
+cquizv = action.getvalue('cquizv')
if not ctitle: ctitle = ""
if not cname: cname = ""
if not ctext: ctext = ""
+if not cquiz: cquiz = ""
+if not cquizv: cquizv = ""
# Comment to commit?
if cname and ctext and ctitle:
@@ -99,21 +103,22 @@ if cname and ctext and ctitle:
.replace(">", "&gt;") \
.replace("\"", "&quot;")
- # TODO: Read file with spam words
-
# Add comment
- comments_file = glob.glob(entries_dir + ctitle + '.comments')
- if not comments_file:
- content = open(entries_dir + ctitle + '.comments', "w")
- content.close()
+ if not cquiz == cquizv:
+ errorpage("Brainmode")
+ else:
comments_file = glob.glob(entries_dir + ctitle + '.comments')
- content = open(comments_file[0], "a+")
- content.write("-." + cname + "\n")
- content.write("+." + time.asctime() + "\n")
- ctext = ctext.split("\n")
- for line in ctext:
- content.write("." + line + "\n")
- content.close()
+ if not comments_file:
+ content = open(entries_dir + ctitle + '.comments', "w")
+ content.close()
+ comments_file = glob.glob(entries_dir + ctitle + '.comments')
+ content = open(comments_file[0], "a+")
+ content.write("-." + cname + "\n")
+ content.write("+." + time.asctime() + "\n")
+ ctext = ctext.split("\n")
+ for line in ctext:
+ content.write("." + line + "\n")
+ content.close()
# Read entries and store their title and timestamp
entries = []
@@ -249,9 +254,9 @@ else:
if post_display == title or not post_display:
if allentries_display == "1" or entry_counter < entries_per_page:
content = open(entry, "r")
- if permalinks: # Title as permalink...
+ if permalinks:
print ' <div class="entrytitle"><a href="?p=' + title + '" class="entrytitle">' + title + ' <small>(' + date + ')</small></a></div>'
- else: # ... or not
+ else:
print ' <div class="entrytitle">' + title + ' <small>(' + date + ')</small></div>'
print ' <div class="entry">'
for line in content:
@@ -276,11 +281,17 @@ else:
comments_content.close()
# Form for adding comments
+ random_int_a = random.randint(1,9)
+ random_int_b = random.randint(1,9)
+ cquizv = random_int_a + random_int_b
+
print ' <br /><br /><br />'
print ' <form action="" method="post">'
print ' <input type="hidden" name="ctitle" value="' + title + '" />'
+ print ' <input type="hidden" name="cquizv" value="' + str(cquizv) + '" />'
print ' <label for="cname">name:</label><input type="text" id="cname" name="cname" />'
print ' <br /><label for="ctext">text:</label><textarea rows="5" cols="80" id="ctext" name="ctext"></textarea>'
+ print ' <br /><label for="cquiz">' + str(random_int_a) + '+' + str(random_int_b) + '=</label><input type="text" id="cquiz" name="cquiz" />'
print ' <br /><input type="submit" id="submit" value="post comment" />'
print ' </form>'