#!/usr/bin/env perl

use strict;
use CGI qw(standard);

my $q = new CGI;
my $url = $q->param('url');
if ($url !~ /^http\:\/\/[a-z\.]*[a-z]*\.apache\.org/i) {
    print "Not a valid Apache URL!\n";
    die;
}
my $text;

my $fileName = "/usr/local/websites/asylum/htdocs/htdocs/export/list.xml";

open(IN, $fileName) || die;
while (<IN>) {
    last if $_ =~ /\<\/list\>/;
    $text .= $_;
}
close(IN);
$text .= "  <location>$url</location>\n";
$text .= "</list>\n";

open(OUT, ">$fileName") || die "Unable to write to file!\n";
print OUT $text;
close (OUT);

print "Status: 302 Moved\nLocation: /cgi-bin/genexp.pl\n\n";
