summaryrefslogtreecommitdiff
path: root/listshows.cgi
blob: 0bc0dbd624bb2ffdb8760cbd60046be10176bd4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl

use strict;
use CGI;
use File::Basename;
use lib dirname( __FILE__ ) . '/lib';
use rddb;

binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");

my $status = 'ERROR';
my $errorstring = 'unknown';
my $responsecode = 500;
my @dropboxes = ();

my $q = CGI->new;
my $username = $q->param('LOGIN_NAME');
my $token = $q->param('PASSWORD');

my $dbh;
($dbh, $status, $errorstring) = rddb::opendb();
if(defined $dbh) {
  my $result;
  ($result, $status, $errorstring) = rddb::check_token($dbh, $username, $token);
  if($result == 1) {
    $responsecode = 200;
    @dropboxes = rddb::get_dropboxes($dbh, $username);
  } elsif($result == 0) {
    $responsecode = 403;
  } else {
    $responsecode = 500;
  }
  rddb::closedb($dbh);
}

print "Content-type: application/xml; charset=UTF-8\n\n";

if($responsecode != 200) {
  print "<RDWebResult>\n";
  print "  <ResponseCode>" . $responsecode . "</ResponseCode>\n";
  print "  <ErrorString>" . $errorstring . "</ErrorString>\n";
  print "</RDWebResult>\n";
} else {
  print "<dropboxList>\n";
  for my $href (@dropboxes) {
    print "  <dropbox>\n";
    print "    <group>" . $href->{'GROUP'} . "</group>\n";
    print "    <group-description>" . $href->{'GROUPDESC'} . "</group-description>\n";
    print "    <type>" . $href->{'TYPE'} . "</type>\n";
    print "    <showid>" . $href->{'SHOWID'} . "</showid>\n";
    print "    <log>" . $href->{'LOG'} . "</log>\n";
    print "    <normalization-level>" . $href->{'NORMLEVEL'} . "</normalization-level>\n";
    print "    <autotrim-level>" . $href->{'TRIMLEVEL'} . "</autotrim-level>\n";
    print "    <parameters>" . $href->{'PARAM'} . "</parameters>\n";
    if($href->{'TYPE'} eq "show") {
      print "    <show-title>" . $href->{'SHOWTITLE'} . "</show-title>\n";
      print "    <show-rhythm>" . $href->{'RHYTHM'} . "</show-rhythm>\n";
      print "    <show-dayofweek>" . $href->{'DOW'} . "</show-dayofweek>\n";
      print "    <show-starttime>" . $href->{'STARTTIME'} . "</show-starttime>\n";
      print "    <show-length>" . $href->{'LENGTH'} . "</show-length>\n";
    }
    print "  </dropbox>\n";
  }
  print "</dropboxList>\n";
}