- return 1 if $_[0]->{'gruntmaster.reqadmin'} || $r->path eq '/action/passwd' || $r->path =~ m,/pb/$word/submit$,;
- return 1 if $r->path =~ m,^/ct/$word/pb/$word, && time < $db->contest($1)->stop;
+ return 1 if $_[0]->{'gruntmaster.reqadmin'} || $r->path eq '/action/passwd' || $r->path eq '/submit';
+ return 1 if $r->path =~ m,^/pb/$word, && $_[0]->{'gruntmaster.contest'} && time < $db->contest($_[0]->{'gruntmaster.contest'})->stop;
+ ''
+}
+
+sub is_problem_private {
+ my $pb = $_[0];
+ return 1 if $db->problem($pb)->private;
+ my $prv = 0;
+ for my $cp ($db->problem($pb)->contest_problems) {
+ $prv = 1;
+ return '' if $cp->contest->start <= time;
+ }
+
+ $prv
+}
+
+sub is_problem_in_contest {
+ my ($pb, $ct) = @_;
+ return 1 if $db->contest_problems->find($ct, $pb);
+ return '' if defined $ct;
+ for my $cp ($db->problem($pb)->contest_problems) {
+ return 1 if $cp->contest->stop >= time;
+ }