Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

judge cgi modified

  • Loading branch information...
commit d9a5f5f19ac6d62724eac53da0e05b75eb7b3381 1 parent 6ba9cec
muranushi@gmail.com authored
Showing with 79 additions and 21 deletions.
  1. +79 −21 league/judge.cgi
View
100 league/judge.cgi
@@ -23,9 +23,11 @@ def digest(str)
end
$ais = []
+$poketime = 123
open('register.txt', 'r') {|fp|
+ $poketime = fp.gets
while line = fp.gets
words = line.split(/\s+/)
next if words.length < 4
@@ -35,20 +37,34 @@ open('register.txt', 'r') {|fp|
$fail = false
$errmsg = ''
+$update = false
+
+if $cgi.has_key?('poke')
+ t = Time.now
+ pt = t.to_i
+ if pt <= $poketime.to_i + 3
+ $errmsg += "Do not poke me so much! <br/><br/>"
+ else
+ $poketime = pt
+ $errmsg = "poked! at #{t}<br/><br/>"
+ $update = true
+ end
+end
if $cgi.has_key?('add')
if $cgi['url'] =~ /\s+/ || $cgi['package'] =~ /\s+/
$fail = true
$errmsg += <<MSG
-URL must not contain spaces<br><br>
+URL must not contain spaces<br/><br/>
MSG
elsif ($cgi['team'].strip.length > 0) && ($cgi['url'].strip.length > 0) && ($cgi['package'].strip.length > 0)
$ais << AI::new($cgi['team'].strip, digest($cgi['password'].strip),
$cgi['url'].strip, $cgi['package'].strip)
+ $update = true
else
$fail = true
$errmsg += <<MSG
-some fields are missing<br><br>
+some fields are missing<br/><br/>
MSG
end
@@ -66,21 +82,30 @@ $cgi.params.each{|k,v|
else
$fail = true
$errmsg += <<MSG
-Remove requested, but Password Mismatch.<br><br>
+Remove requested, but Password Mismatch.<br/><br/>
MSG
end
end
+ $update = true if flag
flag
}
end
}
-open('register.txt', 'w') {|fp|
- $ais.each{|ai|
- fp.puts "#{ai.team} #{ai.passh} #{ai.url} #{ai.package}"
+if $update
+ open('register.txt', 'w') {|fp|
+ begin
+ fp.flock(File::LOCK_EX)
+ fp.puts $poketime
+ $ais.each{|ai|
+ fp.puts "#{ai.team} #{ai.passh} #{ai.url} #{ai.package}"
+ }
+ fp.flock(File::LOCK_UN)
+ rescue e
+ $errmsg += "#{e.inspect}<br/><br/>"
+ end
}
-}
-
+end
officialUrl = $cgi.a({:href => 'http://www.icfpcontest.org/' }) {
'ICFP programming contest 2011'
}
@@ -131,14 +156,23 @@ $cgi.out() do
} + $cgi.p({:align => 'left'}) {
greetings
} + $cgi.p({:align => 'right'}) {
- 'Takayuki Muranushi (@nushio) from team' +
+ 'Takayuki Muranushi (@nushio) from team ' +
$cgi.a({:href => 'https://github.com/tanakh/ICFP2011'}) {
'atomically $ save Madoka'
}
} + $cgi.p {
$cgi.a({:href => 'http://www.paraiso-lang.org/Walpurgisnacht/store/scoreboard.html'}) {
- 'league result'
+ 'league result (current)'
+ }+'&nbsp;'*4+
+ $cgi.a({:href => 'http://www.paraiso-lang.org/Walpurgisnacht/store/polling_log_current.txt'}) {
+ 'polling log (current)'
}+'<br/>'+
+ $cgi.a({:href => 'http://www.paraiso-lang.org/Walpurgisnacht/store/2/scoreboard.html'}) {
+ 'league result (last finished)'
+ }+'&nbsp;'*4+
+ $cgi.a({:href => 'http://www.paraiso-lang.org/Walpurgisnacht/store/polling_log.txt'}) {
+ 'polling log (last)'
+ }+'<br/>'+'<br/>'+
$cgi.a({:href =>'https://github.com/tanakh/ICFP2011/wiki/League'}) {
'judge specification (ja)'
}+'<br/>'+
@@ -146,7 +180,7 @@ $cgi.out() do
'judge specification (en)'
}+'<br/>'+
$cgi.a({:href =>'http://nushisblogger.blogspot.com/'}) {
- 'blog about this'
+ 'YAUJ blog'
}
} +
$cgi.table({:border => '1'}) {
@@ -172,22 +206,46 @@ $cgi.out() do
$cgi.table {
$cgi.tr{
$cgi.td({:align=>'right'}){ 'team name' } +
- $cgi.td({:align=>'right'}){ $cgi.input({:type => 'text', :name => 'team'}) }
+ $cgi.td({:align=>'right'}){ $cgi.input({:type => 'text', :name => 'team', :size=>32}) }
} + $cgi.tr{
$cgi.td({:align=>'right'}){ 'password' }+
- $cgi.td({:align=>'right'}){ $cgi.input({:type => 'password', :name => 'password'}) }
+ $cgi.td({:align=>'right'}){ $cgi.input({:type => 'password', :name => 'password', :size=>32}) }
} + $cgi.tr{
$cgi.td({:align=>'right'}){ 'team website url' }+
- $cgi.td({:align=>'right'}){ $cgi.input({:type => 'text', :name => 'url'}) }
+ $cgi.td({:align=>'right'}){ $cgi.input({:type => 'text', :name => 'url', :size=>32}) }
} + $cgi.tr{
$cgi.td({:align=>'right'}){ 'submit.tar.gz url' } +
- $cgi.td({:align=>'right'}){ $cgi.input({:type => 'text', :name => 'package'}) }
- } +
- $cgi.td{} +
- $cgi.td({:align=>'right'}){ $cgi.input({:type => 'submit', :name => 'add', :value => 'submit'}) }
- }
- } + $cgi.p {
- 'remember your password for removal!'
+ $cgi.td({:align=>'right'}){ $cgi.input({:type => 'text', :name => 'package', :size=>32}) }
+ } + $cgi.tr{
+ $cgi.td{} +
+ $cgi.td({:align=>'right'}){ $cgi.input({:type => 'submit', :name => 'add', :value => 'submit'}) }
+ } + $cgi.tr{
+ $cgi.td{'<br/>'}
+ } + $cgi.tr{
+ $cgi.td({:colspan=>2}){
+ 'remember your password for removal!'
+ }
+ } + $cgi.tr{
+ $cgi.td{'<br/>'}
+ } + $cgi.tr{
+ $cgi.td({:colspan=>2}){
+ 'The judge looks at the team list every minute<br/>and starts the match, when' +
+ $cgi.ul {
+ $cgi.li {
+ 'the team list is updated,'
+ } + $cgi.li {
+ 'previous match is finished,'
+ } + $cgi.li {
+ 'and nothing is broken :)'
+ }
+ }
+ }
+ } + $cgi.tr{
+ $cgi.td({:colspan=>2, :align=>'right'}){
+ 'also generate update by pressing:' +$cgi.input({:type => 'submit', :name => 'poke', :value => 'poke!'})
+ }
+ }
+ }
}
end
} # end of CGI
Please sign in to comment.
Something went wrong with that request. Please try again.