Fixed send-comment function (now works with apache)

This commit is contained in:
Stefan Ritter 2009-12-07 10:35:36 +01:00
parent ecd758e7f1
commit 6ff2c622be

View File

@ -190,9 +190,9 @@ if cname and ctext and ctitle:
content = open(entries_dir + ctitle + '.comments', "w") content = open(entries_dir + ctitle + '.comments', "w")
content.close() content.close()
except: except:
errorpage(entries_dir, 'isn\'t writable!') errorpage('"' + entries_dir + '" isn\'t writable!')
try: try:
content = open(comments_file[0], "a+") content = open(entries_dir + ctitle + '.comments', "a")
content.write("-." + cname + "\n") content.write("-." + cname + "\n")
content.write("+." + time.asctime() + "\n") content.write("+." + time.asctime() + "\n")
ctext = ctext.split("\n") ctext = ctext.split("\n")
@ -200,13 +200,13 @@ if cname and ctext and ctitle:
content.write("." + line + "\n") content.write("." + line + "\n")
content.close() content.close()
# Send mail? # Send mail?
if new_comment_mail: if not new_comment_mail == 'False':
msg = 'From: Blogthon\nTo: ' + mail_to + '\nSubject: New comment on ' + blog_title + '\n\nSomeone wrote a comment to this entry: ' + blog_url + '?p=' + ctitle.replace(' ', '-') msg = 'From: Blogthon\nTo: ' + mail_to + '\nSubject: New comment on ' + blog_title + '\n\nSomeone wrote a comment to this entry: ' + blog_url + '?p=' + ctitle.replace(' ', '-')
smtp = smtplib.SMTP(smtp_host) smtp = smtplib.SMTP(smtp_host)
smtp.sendmail(blog_title, mail_to, msg) smtp.sendmail(blog_title, mail_to, msg)
smtp.quit() smtp.quit()
except: except:
errorpage(comments_file, 'isn\'t writable!') errorpage('Comment cannot be written!')
# Read entries and store their title and timestamp # Read entries and store their title and timestamp
entries = [] entries = []