diff options
Diffstat (limited to 'rh-bin/musicgrid.cgi')
-rwxr-xr-x | rh-bin/musicgrid.cgi | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/rh-bin/musicgrid.cgi b/rh-bin/musicgrid.cgi index b1bfa1f..f2bf9db 100755 --- a/rh-bin/musicgrid.cgi +++ b/rh-bin/musicgrid.cgi @@ -25,7 +25,6 @@ use strict; use CGI; use POSIX; use XML::Quote; -use lib "../../rhrdlibs/lib/"; use RHRD::rddb; my $status = 'ERROR'; @@ -34,9 +33,9 @@ my $responsecode = 500; my @clocks = (); my $q = CGI->new; -my $username = "equinox"; #$q->param('LOGIN_NAME'); -my $token = ""; #$q->param('PASSWORD'); -my $cmd = "get"; #$q->param('COMMAND'); +my $username = $q->param('LOGIN_NAME'); +my $token = $q->param('PASSWORD'); +my $cmd = $q->param('COMMAND'); sub get_clocks { @@ -60,13 +59,22 @@ sub set_clock if(!defined $dow) { return 400 ,"mandatory field DOW is missing"; + } elsif($dow < 0 || $dow > 6) { + return 400 ,"DOW is out of range"; } elsif(!defined $hour) { return 400, "mandatory field HOUR is missing"; + } elsif($hour < 0 || $hour > 23) { + return 400 ,"HOUR is out of range"; } elsif(!defined $shortname) { return 400, "mandatory field NAME is missing"; } - return 500, "not yet implemented"; + my ($result, $status, $error) = RHRD::rddb::set_musicpools_clock($ctx, $dow, $hour, $shortname); + if(!defined $result) { + return 500, $status . ": " . $error; + } + + return 200, "OK"; } if(!defined $username) { @@ -81,7 +89,7 @@ if(!defined $username) { } else { (my $ctx, $status, $errorstring) = RHRD::rddb::init(); if(defined $ctx) { - my $authenticated = 1; # (my $authenticated, $status, $errorstring) = RHRD::rddb::check_token($ctx, $username, $token); + (my $authenticated, $status, $errorstring) = RHRD::rddb::check_token($ctx, $username, $token); my $authorized = RHRD::rddb::is_musicpools_user($ctx, $username); if($authenticated == 1 && $authorized == 1) { if($cmd eq "get") { |