X-Git-Url: https://iankelling.org/git/?p=iankelling.org;a=blobdiff_plain;f=_site%2Fcgi%2Fcomment;fp=_site%2Fcomment.rb;h=b1e8796607706a844cf9a33ecf1a46500acfebec;hp=14f1152cb92ca13970971b4b212a4c21ff71b623;hb=3c09af9cc854c716d9f772d1c8c1e568cacc92b9;hpb=d0a5b73d2a275bfff5957961f2360df8966bee22 diff --git a/_site/comment.rb b/_site/cgi/comment similarity index 92% rename from _site/comment.rb rename to _site/cgi/comment index 14f1152..b1e8796 100755 --- a/_site/comment.rb +++ b/_site/cgi/comment @@ -27,9 +27,12 @@ require 'fileutils' require 'time' require 'sqlite3' -require_relative '../b' +Dir.chdir(File.join(File.dirname(__FILE__), '..')) + +require '../b' include B + # constanty things DEBUG = true CAPTCHA = -> { @@ -77,11 +80,11 @@ EOF def do_captcha captcha_q = CAPTCHA.sample[0] puts "Content-type: text/html\n\n" - puts skel('comment.rb', "#{DN}/captcha", <blog / comment-captcha') + puts skel("#{DN}/captcha", <blog / captcha')

Hello friend. I haven't read a post from #{IP}, and I only remember for a few months, so:

#{captcha_q}

-
+ @@ -106,7 +109,6 @@ def fail(msg) end def redir - File.write('/tmp/x', GOTO) puts 'Status: 302 Found' puts "Location: #{GOTO}#comment-section\n\n" exit(0) @@ -126,18 +128,18 @@ if cgi.has_key?('goto') GOTO = cgi['goto'] else GOTO = '/' - fail['redir to /'] + fail('redir to /') end if (cgi.has_key?('url') && cgi['url'] != "") || ! cgi.has_key?('comment') - fail["comment not in form or url in form. cgi.params: #{cgi.params}"] + fail("comment not in form or url in form. cgi.params: #{cgi.params}") end COMMENT_TXT = cgi["comment"] if COMMENT_TXT.length > 1000 or GOTO.length > 150 - fail['length of comment or goto is too great'] + fail('length of comment or goto is too great') end @@ -154,12 +156,12 @@ end found = false Dir.foreach('blog') do |entry| next if ['.','..'].any? { |f| f == entry } - if GOTO == 'blog/' + entry + if GOTO == '/blog/' + entry found = true break end end - fail['goto entry not found'] unless found + fail('goto entry not found') unless found }[] ######### end error checking & arg parsing ######## @@ -194,18 +196,20 @@ SQL unless state older_date = NOW - DAY*2 - last_moderated = $db.execute(<<-SQL, [older_date])[-1][0] + last_moderated = $db.execute(<<-SQL, [older_date])[-1] select date from c where ip = '#{IP}' and ( state = 'moderated' or (date < ? and (state = 'timed' or state = 'known'))) SQL - last_good = $db.execute(<<-SQL, [older_date])[-1][0] + last_moderated = last_moderated[0] if last_moderated + last_good = $db.execute(<<-SQL, [older_date])[-1] select date from c where ip = '#{IP}' and ( state = 'picked' or (date < ? and (state = 'timed' or state = 'known'))) SQL + last_good = last_good[0] if last_good if last_moderated && last_good if last_good > last_moderated state = 'known'