summaryrefslogtreecommitdiff
path: root/rh-bin/musicgrid.cgi
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-17 16:07:05 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-17 16:07:05 (GMT)
commit9e447636429a231eb7aeda22049422f2dc692936 (patch)
tree923377f8f318a786638850e376624c6123e80163 /rh-bin/musicgrid.cgi
parent40947fb5575fa3a6053302263a52bbaa54ecff97 (diff)
also implemented setting of clock
Diffstat (limited to 'rh-bin/musicgrid.cgi')
-rwxr-xr-xrh-bin/musicgrid.cgi20
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") {