* Removed blacklist
* Added an addition to solve before adding a comment
This commit is contained in:
Stefan Ritter 2009-04-30 01:25:14 +02:00
parent d82a5f6347
commit d62b62874b
2 changed files with 27 additions and 19 deletions

View File

@ -1,3 +0,0 @@
viagra
sex tape
penis enlargement

View File

@ -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>'