From 6b30c4447eb0b90c4bc656b317cec262b549ccfc Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Sun, 8 Mar 2009 19:17:59 +0100 Subject: Comments: * You can now add comments --- blogthon.cgi | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/blogthon.cgi b/blogthon.cgi index 5dd7d11..15e1fe5 100755 --- a/blogthon.cgi +++ b/blogthon.cgi @@ -43,6 +43,32 @@ if not post_display: post_display = "" if not static_display: static_display = "" if not allentries_display: allentries_display = "" +# Commentstuff +ctitle = action.getvalue('ctitle') +cname = action.getvalue('cname') +ctext = action.getvalue('ctext') +if not ctitle: ctitle = "" +if not cname: cname = "" +if not ctext: ctext = "" + +# Comment to commit? +if cname and ctext and ctitle: + # Prevent XSS hacks + cname = cname.replace("<", "<") + cname = cname.replace(">", ">") + cname = cname.replace("\"", """) + ctext = ctext.replace("<", "<") + ctext = ctext.replace(">", ">") + ctext = ctext.replace("\"", """) + + # Add comment + comments_file = glob.glob(entries_dir + ctitle + '.comments') + content = open(comments_file[0], "a+") + content.write("-." + cname + "\n") + content.write("+." + time.asctime() + "\n") + content.write("." + ctext + "\n") + content.close() + print 'Content-type: text/html\n' print '' @@ -159,9 +185,10 @@ else: # Show regular entry # Form for adding comments print '


' - print '
' - print ' ' - print '
' + print ' ' + print ' ' + print ' ' + print '
' print '
' print '
' -- cgit v1.2.3