1 package Gruntmaster
::Page
::Submit
;
6 use Gruntmaster
::Page
::Base
;
7 our @ISA = qw
/Gruntmaster::Page::Base/;
8 our $VERSION = '0.001';
10 use Apache2
::Authen
::Passphrase qw
/pwcheck pwset USER_REGEX/;
11 use File
::Slurp qw
/read_file/;
14 use constant FORMAT_EXTENSION
=> {
25 my ($self, $frm, $env) = @_;
26 my $r = Plack
::Request
->new($env);
27 my ($problem, $format, $contest, $private, $prog) = map {scalar $r->param($_)} 'problem', 'prog_format', 'contest', 'private', 'source_code';
28 my $upload = $r->upload('prog');
29 if (defined $upload) {
30 my $temp = read_file
$upload->path;
31 $prog = $temp if $temp
33 die if defined $contest && $contest !~ /^\w+$/ ;
34 die if defined $contest && (time > contest_end
$contest);
35 return reply
'A required parameter was not supplied' if grep { !defined } $problem, $format, $prog;
36 return reply
'You must wait 30 seconds between jobs' unless time > lastjob
($r->user) + 30;
39 local $Gruntmaster::Data
::contest
= $contest if $contest;
45 defined $private ?
(private
=> $private) : (),
46 defined $contest ?
(contest
=> $contest, private
=> 1) : (),
47 filesize
=> length $prog,
48 extension
=> FORMAT_EXTENSION
->{$format},
51 set_job_inmeta
$job, {
55 name
=> 'prog.' . FORMAT_EXTENSION
->{$format},
62 PUBLISH
'jobs', "$contest.$job";
63 [303, [Location
=> $r->path =~ s
,/pb/\w
+/submit$,/log/,r
], ['']]
66 sub variants
{ [[reply
=> 1, undef, undef, undef, undef, undef]] }