summaryrefslogtreecommitdiff
path: root/rh-bin/musicgrid.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'rh-bin/musicgrid.cgi')
-rwxr-xr-xrh-bin/musicgrid.cgi21
1 files changed, 7 insertions, 14 deletions
diff --git a/rh-bin/musicgrid.cgi b/rh-bin/musicgrid.cgi
index 5e2888d..9cd0837 100755
--- a/rh-bin/musicgrid.cgi
+++ b/rh-bin/musicgrid.cgi
@@ -30,25 +30,12 @@ use RHRD::rddb;
my $status = 'ERROR';
my $errorstring = 'unknown';
my $responsecode = 500;
-my @clocks = ();
my $q = CGI->new;
my $username = $q->param('LOGIN_NAME');
my $token = $q->param('PASSWORD');
my $cmd = $q->request_method();
-sub get_clocks
-{
- my ($ctx) = @_;
-
- @clocks = RHRD::rddb::get_musicpools_clocks($ctx);
- if(!defined $clocks[0] && defined $clocks[1]) {
- return 500, $clocks[1] . ": " . $clocks[2];
- }
-
- return 200, "OK";
-}
-
sub set_clock
{
my ($ctx) = @_;
@@ -77,6 +64,7 @@ sub set_clock
return 200, "OK";
}
+my @clocks = ();
if(!defined $username) {
$responsecode = 400;
$errorstring = "mandatory field LOGIN_NAME is missing";
@@ -90,7 +78,12 @@ if(!defined $username) {
my $authorized = RHRD::rddb::is_musicpools_user($ctx, $username);
if($authenticated == 1 && $authorized == 1) {
if($cmd eq "GET") {
- ($responsecode, $errorstring) = get_clocks($ctx);
+ @clocks = RHRD::rddb::get_musicpools_clocks($ctx);
+ if(!defined $clocks[0] && defined $clocks[1]) {
+ ($responsecode, $errorstring) = (500, $clocks[1] . ": " . $clocks[2]);
+ } else {
+ ($responsecode, $errorstring) = (200, "OK");
+ }
}
elsif($cmd eq "POST") {
($responsecode, $errorstring) = set_clock($ctx);