X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=_site%2Fcgi%2Fcomment;h=b84c45ebe6076132bf81a39b0cb1da5d3820eb00;hb=17dba3676e34470b962616e310f8f4585a697fa3;hp=b1e8796607706a844cf9a33ecf1a46500acfebec;hpb=3c09af9cc854c716d9f772d1c8c1e568cacc92b9;p=iankelling.org diff --git a/_site/cgi/comment b/_site/cgi/comment index b1e8796..b84c45e 100755 --- a/_site/cgi/comment +++ b/_site/cgi/comment @@ -142,6 +142,10 @@ if COMMENT_TXT.length > 1000 or GOTO.length > 150 fail('length of comment or goto is too great') end +if COMMENT_TXT.length <= 2 or COMMENT_TXT =~ /\A\s*\Z/ + fail('not enough content in comment') +end + captchad = false if cgi.has_key?('answer') && cgi.has_key?('question') @@ -292,20 +296,27 @@ state != 'rate_limited' and state != 'suspect' SQL +$db.execute('insert into c values (NULL, ?, ?, ?, ?, ?)', + [state, + IP, + NOW, + GOTO, + COMMENT_TXT]) if date - new_count = $db.execute(query + 'and date > ?',date) + new_count = $db.execute(query + 'and date > ?', date) else new_count = $db.execute(query) end +new_count = new_count[0][0] if new_count == 1 require 'net/smtp' def send_email(opts={}) - opts[:to] ||= ENV['USER'] + opts[:to] ||= 'root' opts[:server] ||= 'localhost' - opts[:from] ||= ENV['USER'] - opts[:from_alias] ||= ENV['USER'] + opts[:from] ||= 'root' + opts[:from_alias] ||= 'root' opts[:subject] ||= "test subject" opts[:body] ||= "" @@ -321,16 +332,9 @@ END_OF_MESSAGE smtp.send_message msg, opts[:from], opts[:to] end end - send_email :subject => 'new comments on iankelling.org' + send_email :subject => "new comment on #{DN}" end -$db.execute('insert into c values (NULL, ?, ?, ?, ?, ?)', - [state, - IP, - NOW, - GOTO, - COMMENT_TXT]) - post(md_file) redir