]> git.sesse.net Git - ccbs/blobdiff - html/do-edit-scores.pl
Check for scores out of range, instead of giving SQL errors.
[ccbs] / html / do-edit-scores.pl
index 8b28303e6162fff4238da4898075f399d6f38ea1..be93df0536c9ef0871822406f37b1dd92bb1195a 100755 (executable)
@@ -24,8 +24,21 @@ for my $p ($cgi->param()) {
        undef $val if ($val =~ /^\s*$/);
 
        if ($p =~ /^score(\d+)-(\d+)/) {
+               if (defined($val) && ($val < 0 || $val > 10000)) {
+                       ccbs::user_error("Alle poengsummer må være mellom 0 og 10000 (inklusive).");
+               }
+       
                $dbh->do('UPDATE scores SET score=? WHERE tournament=? AND round=? AND parallel=? AND player=? AND songnumber=?', undef,
                        $val, $tournament, $round, $group, $1, $2);
+       } elsif ($p =~ /^playmode(\d+)-(\d+)/) {
+               $dbh->do('UPDATE scores SET playmode=? WHERE tournament=? AND round=? AND parallel=? AND player=? AND songnumber=?', undef,
+                       $val, $tournament, $round, $group, $1, $2);
+       } elsif ($p =~ /^difficulty(\d+)-(\d+)/) {
+               $dbh->do('UPDATE scores SET difficulty=? WHERE tournament=? AND round=? AND parallel=? AND player=? AND songnumber=?', undef,
+                       $val, $tournament, $round, $group, $1, $2);
+       } elsif ($p =~ /^song(\d+)-(\d+)/) {
+               $dbh->do('UPDATE scores SET song=? WHERE tournament=? AND round=? AND parallel=? AND player=? AND songnumber=? AND chosen=\'t\'', undef,
+                       $val, $tournament, $round, $group, $1, $2);
        }
 }