#!/usr/bin/perl # # rhwebimport # # Copyright (C) 2014-2015 Christian Pointner # # This file is part of rhwebimport. # # rhwebimport is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # any later version. # # rhwebimport is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with rhwebimport. If not, see . # use strict; use CGI; use File::Basename; use lib dirname( __FILE__ ) . '/../lib'; use rddb; 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); unless (defined $dropboxes[0]) { $responsecode = 500; $status = $dropboxes[1]; $errorstring = $dropboxes[2]; } } 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 "\n"; print " " . $responsecode . "\n"; print " " . $errorstring . "\n"; print "\n"; } else { print "\n"; for my $href (@dropboxes) { print " \n"; print " " . $href->{'GROUP'} . "\n"; print " " . $href->{'GROUPDESC'} . "\n"; print " " . $href->{'GROUPLOWCART'} . "\n"; print " " . $href->{'GROUPHIGHCART'} . "\n"; print " " . $href->{'NORMLEVEL'} . "\n"; print " " . $href->{'TRIMLEVEL'} . "\n"; print " " . $href->{'PARAM'} . "\n"; print " " . $href->{'TYPE'} . "\n"; if($href->{'TYPE'} eq "show") { print " " . $href->{'SHOWID'} . "\n"; print " " . $href->{'SHOWTITLE'} . "\n"; print " " . $href->{'SHOWLOG'} . "\n"; print " " . $href->{'SHOWRHYTHM'} . "\n"; print " " . $href->{'SHOWDOW'} . "\n"; print " " . $href->{'SHOWSTARTTIME'} . "\n"; print " " . $href->{'SHOWLEN'} . "\n"; } print " \n"; } print "\n"; }