#!/usr/bin/perl -w
#Developed in 2001 by Philipp Ghring (pg@futureware.at). GPL applies. 

use CGI qw(:standard :cgi-lib);
use XML::Sablotron qw( :all );

print "Content-type: text/html; charset=UTF-8\n\n";


my $res="",$result="";
my %in;
CGI::ReadParse(\%in);

my @parameter;
@parameter=%in;

my $user="1"; $user=$1 if ($in{user} =~ m/(\w+)/);
my $artnr="0"; $artnr=$1 if ($in{artnr} =~ m/(\d+)/);

$content="<root>\n";

foreach my $file (<../../art/$artnr>)
{
    print STDERR "$file\n";
    open IN,"<$file";
    undef $/;
    $content.="<produkt>\n";
    $file =~ m{^db/$user/art/(.*)$};
    $content.="  <ID>$1</ID>\n";
    $content.=<IN>;
    $content.="</produkt>\n";
    close IN;
}
$content.="</root>\n";

$res = Process("file://getdata.xsl", "arg:/data", "arg:/result", \@parameter, [data=>$content],$result);

print "$result\n";

