]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Submit.pm
Restrict submit size to 25KB
[gruntmaster-page.git] / lib / Gruntmaster / Page / Submit.pm
index b08399e005d4f74e0b666aceafcee0e0decb39d1..ea67c2b609b3b6c575c86f92e2a7f1014bec367c 100644 (file)
@@ -1,15 +1,6 @@
 package Gruntmaster::Page::Submit;
 
-use 5.014000;
-use strict;
-use warnings;
 use Gruntmaster::Page::Base;
-our @ISA = qw/Gruntmaster::Page::Base/;
-our $VERSION = '0.001';
-
-use Apache2::Authen::Passphrase qw/pwcheck pwset USER_REGEX/;
-use File::Slurp qw/read_file/;
-use Plack::Request;
 
 use constant FORMAT_EXTENSION => {
        C => 'c',
@@ -27,12 +18,15 @@ sub generate{
        my ($problem, $format, $contest, $private, $prog) = map {scalar $r->param($_)} 'problem', 'prog_format', 'contest', 'private', 'source_code';
        my $upload = $r->upload('prog');
        if (defined $upload) {
-               my $temp = read_file $upload->filename;
+               my $temp = read_file $upload->path;
                $prog = $temp if $temp
        }
        die if defined $contest && $contest !~ /^\w+$/ ;
        die if defined $contest && (time > contest_end $contest);
        return reply 'A required parameter was not supplied' if grep { !defined } $problem, $format, $prog;
+       return reply 'Maximum source size is 10KB' if length $prog > 25 * 1024;
+       return reply 'You must wait 30 seconds between jobs' unless time > lastjob ($r->user) + 30;
+       set_lastjob $r->user;
 
        local $Gruntmaster::Data::contest = $contest if $contest;
 
@@ -61,6 +55,4 @@ sub generate{
        [303, [Location => $r->path =~ s,/pb/\w+/submit$,/log/,r], ['']]
 }
 
-sub variants{ [[reply => 1, undef, undef, undef, undef, undef]] }
-
 1
This page took 0.019899 seconds and 4 git commands to generate.