diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-09-23 20:58:00 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-09-23 20:58:00 (GMT) |
commit | ea0709ddb5d412be90b423f4fc279b33812b7ebf (patch) | |
tree | e28a19016b1d07469c0290f70d7d4c465b67aa38 /rh-bin/listdropboxes.cgi | |
parent | 69636e8eed5da4393d6c4445835bd811faa246aa (diff) |
switched from fastcgi to mpm-itk and mod-perl
Diffstat (limited to 'rh-bin/listdropboxes.cgi')
-rwxr-xr-x | rh-bin/listdropboxes.cgi | 117 |
1 files changed, 58 insertions, 59 deletions
diff --git a/rh-bin/listdropboxes.cgi b/rh-bin/listdropboxes.cgi index f008c51..a9df374 100755 --- a/rh-bin/listdropboxes.cgi +++ b/rh-bin/listdropboxes.cgi @@ -22,76 +22,75 @@ # use strict; -use CGI::Fast; +use CGI; use POSIX; use XML::Quote; use RHRD::rddb; -while (my $q = CGI::Fast->new) { - my $status = 'ERROR'; - my $errorstring = 'unknown'; - my $responsecode = 500; - my @dropboxes = (); +my $status = 'ERROR'; +my $errorstring = 'unknown'; +my $responsecode = 500; +my @dropboxes = (); - my $username = $q->param('LOGIN_NAME'); - my $token = $q->param('PASSWORD'); +my $q = CGI->new; +my $username = $q->param('LOGIN_NAME'); +my $token = $q->param('PASSWORD'); - my $dbh; - ($dbh, $status, $errorstring) = RHRD::rddb::opendb(); - if(defined $dbh) { - my $result; - ($result, $status, $errorstring) = RHRD::rddb::check_token($dbh, $username, $token); - if($result == 1) { - $responsecode = 200; - @dropboxes = RHRD::rddb::get_dropboxes($dbh, $username); - unless (defined $dropboxes[0]) { - $responsecode = 500; - $status = $dropboxes[1]; - $errorstring = $dropboxes[2]; - } - } elsif($result == 0) { - $responsecode = 401; - } else { +my $dbh; +($dbh, $status, $errorstring) = RHRD::rddb::opendb(); +if(defined $dbh) { + my $result; + ($result, $status, $errorstring) = RHRD::rddb::check_token($dbh, $username, $token); + if($result == 1) { + $responsecode = 200; + @dropboxes = RHRD::rddb::get_dropboxes($dbh, $username); + unless (defined $dropboxes[0]) { $responsecode = 500; + $status = $dropboxes[1]; + $errorstring = $dropboxes[2]; } - RHRD::rddb::closedb($dbh); + } elsif($result == 0) { + $responsecode = 401; + } else { + $responsecode = 500; } + RHRD::rddb::closedb($dbh); +} - print "Content-type: application/xml; charset=UTF-8\n"; - print "Status: $responsecode\n\n"; +print "Content-type: application/xml; charset=UTF-8\n"; +print "Status: $responsecode\n\n"; - if($responsecode != 200) { - print "<RDWebResult>\n"; - print " <ResponseCode>" . xml_quote($responsecode) . "</ResponseCode>\n"; - print " <ErrorString>" . xml_quote($errorstring) . "</ErrorString>\n"; - print "</RDWebResult>\n"; - } else { - print "<dropboxList>\n"; - for my $href (@dropboxes) { - print " <dropbox>\n"; - print " <group>" . xml_quote($href->{'GROUP'}) . "</group>\n"; - print " <group-description>" . xml_quote($href->{'GROUPDESC'}) . "</group-description>\n"; - print " <group-low-cart>" . xml_quote($href->{'GROUPLOWCART'}) . "</group-low-cart>\n"; - print " <group-high-cart>" . xml_quote($href->{'GROUPHIGHCART'}) . "</group-high-cart>\n"; - print " <normalization-level>" . floor($href->{'NORMLEVEL'}/100) . "</normalization-level>\n"; - print " <autotrim-level>" . floor($href->{'TRIMLEVEL'}/100) . "</autotrim-level>\n"; - print " <parameters>" . xml_quote($href->{'PARAM'}) . "</parameters>\n"; - print " <type>" . xml_quote($href->{'TYPE'}) . "</type>\n"; - if($href->{'TYPE'} eq "show") { - print " <show-id>" . xml_quote($href->{'SHOWID'}) . "</show-id>\n"; - print " <show-title>" . xml_quote($href->{'SHOWTITLE'}) . "</show-title>\n"; - print " <show-log>" . xml_quote($href->{'SHOWLOG'}) . "</show-log>\n"; - print " <show-rhythm>" . xml_quote($href->{'SHOWRHYTHM'}) . "</show-rhythm>\n"; - print " <show-dayofweek>" . xml_quote($href->{'SHOWDOW'}) . "</show-dayofweek>\n"; - print " <show-starttime>" . xml_quote($href->{'SHOWSTARTTIME'}) . "</show-starttime>\n"; - print " <show-length>" . xml_quote($href->{'SHOWLEN'}) . "</show-length>\n"; - } elsif($href->{'TYPE'} eq "jingle") { - print " <jingle-title>" . xml_quote($href->{'JINGLETITLE'}) . "</jingle-title>\n"; - } elsif($href->{'TYPE'} eq "musicpool") { - print " <musicpool-title>" . xml_quote($href->{'MUSICPOOLTITLE'}) . "</musicpool-title>\n"; - } - print " </dropbox>\n"; +if($responsecode != 200) { + print "<RDWebResult>\n"; + print " <ResponseCode>" . xml_quote($responsecode) . "</ResponseCode>\n"; + print " <ErrorString>" . xml_quote($errorstring) . "</ErrorString>\n"; + print "</RDWebResult>\n"; +} else { + print "<dropboxList>\n"; + for my $href (@dropboxes) { + print " <dropbox>\n"; + print " <group>" . xml_quote($href->{'GROUP'}) . "</group>\n"; + print " <group-description>" . xml_quote($href->{'GROUPDESC'}) . "</group-description>\n"; + print " <group-low-cart>" . xml_quote($href->{'GROUPLOWCART'}) . "</group-low-cart>\n"; + print " <group-high-cart>" . xml_quote($href->{'GROUPHIGHCART'}) . "</group-high-cart>\n"; + print " <normalization-level>" . floor($href->{'NORMLEVEL'}/100) . "</normalization-level>\n"; + print " <autotrim-level>" . floor($href->{'TRIMLEVEL'}/100) . "</autotrim-level>\n"; + print " <parameters>" . xml_quote($href->{'PARAM'}) . "</parameters>\n"; + print " <type>" . xml_quote($href->{'TYPE'}) . "</type>\n"; + if($href->{'TYPE'} eq "show") { + print " <show-id>" . xml_quote($href->{'SHOWID'}) . "</show-id>\n"; + print " <show-title>" . xml_quote($href->{'SHOWTITLE'}) . "</show-title>\n"; + print " <show-log>" . xml_quote($href->{'SHOWLOG'}) . "</show-log>\n"; + print " <show-rhythm>" . xml_quote($href->{'SHOWRHYTHM'}) . "</show-rhythm>\n"; + print " <show-dayofweek>" . xml_quote($href->{'SHOWDOW'}) . "</show-dayofweek>\n"; + print " <show-starttime>" . xml_quote($href->{'SHOWSTARTTIME'}) . "</show-starttime>\n"; + print " <show-length>" . xml_quote($href->{'SHOWLEN'}) . "</show-length>\n"; + } elsif($href->{'TYPE'} eq "jingle") { + print " <jingle-title>" . xml_quote($href->{'JINGLETITLE'}) . "</jingle-title>\n"; + } elsif($href->{'TYPE'} eq "musicpool") { + print " <musicpool-title>" . xml_quote($href->{'MUSICPOOLTITLE'}) . "</musicpool-title>\n"; } - print "</dropboxList>\n"; + print " </dropbox>\n"; } + print "</dropboxList>\n"; } |