#! /usr/local/bin/ruby require 'rubygems' require 'cgi' require 'postgres-pr/connection' db=PostgresPR::Connection.new('CONFERENCES', 'ellingson') cgi=CGI.new('html3') cid=cgi.params['cid'][0] uid=cgi.params['uid'][0] action=cgi.params['action'][0] File.open("ast.log", 'w'){|f| f.puts("action=#{action}, cid=#{cid}, uid=#{uid}")} if action == "login" sBack="FAIL" ts=Time.now.strftime("%Y-%m-%d %H:%M") sSQL="Prepare conf_login(int, int, timestamp) AS INSERT INTO inprogress VALUES($1,$2,$3);" db.query(sSQL) sExec="EXECUTE conf_login(#{cid},#{uid},\'#{ts}\')" db.query(sExec) sBack="SUCCESS" else sSQL="Prepare logout(int,int) AS SELECT * FROM inprogress where cid=$1 AND uid=$2 AND entered IS NOT NULL" db.query(sSQL) sExec="EXECUTE logout(#{cid},#{uid});" rs=db.query(sExec) if rs.rows.length==0 sBack="0" else sBack="1" sSQL="PREPARE deletelog(int,int) AS DELETE from inprogress where cid=$1 and uid=$2" db.query(sSQL) sExec="EXECUTE deletelog(#{cid},#{uid});" db.query(sExec) end end cgi.out{sBack}