Mercurial > hgrepos > hgweb.cgi > skipweb
diff coop/entry.rb @ 2168:d29fe5c60dbb
display ENV
author | SUZUKI Takehisa <c110128@e.koeki-u.ac.jp> |
---|---|
date | Wed, 18 Dec 2013 20:14:36 +0900 |
parents | 7611cb9532c1 |
children | c9f82d389325 |
line wrap: on
line diff
--- a/coop/entry.rb Wed Dec 18 20:11:25 2013 +0900 +++ b/coop/entry.rb Wed Dec 18 20:14:36 2013 +0900 @@ -1,28 +1,67 @@ #!/usr/bin/env ruby # coding: euc-jp +require 'pg' require 'cgi' +require 'date' c = CGI.new(:accept_charset => "EUC-JP") +pghost = "localhost" +pgport = 5432 +pgoptions = nil +pgtty = nil +dbname = "coop" +dbuser = "c110128" +passwd = nil + i = 0 ip = ENV['REMOTE_ADDR'] - print "Content-type: text/html; charset=EUC-JP\n\n" print "<html> <head><title>サンプル</title><link rel=\"stylesheet\" type = \"text/css\" href=\"data.css\"></head><body>" +print"<table>" +ENV.each { |k,v| -srand(56384679263254687) -10000.times {rand(1000000)} -idlist = (1..100).collect{rand(10000000)} -if idlist.index(ARGV[0].to_i) - print"<p>おめでとう</p>" - print"<p>#{ip}</p>" -elsif - print"<p>残念</p>" + print "<tr><td>#{k}</td><td>#{v}</td></tr>\n" +} + +print"</table>" + +begin + conn = PGconn.connect(pghost,pgport,pgoptions,pgtty,dbname,dbuser,passwd) + tuple = conn.exec( + "select count(*) from log;" + ) +rescue + print"<p>error</p>" +else + tuple.each{|line| + for comp in line + i = comp[1].to_i + end + } +end + +if i < 100 + i = i + 1 + + srand(56384679263254687) + 10000.times {rand(1000000)} + idlist = (1..100).collect{rand(10000000)} + if idlist.index(ARGV[0].to_i) + print"<p>おめでとう</p>" + print"<p>#{ip}</p>" + end +elsif i >= 100 + print"<p>ごめんなさい</p>" + print"<p>もう品切れです</p>" +else + print"<p>error</p>" + end print"</body></html>\n"