--- a/htdocs/cgi-bin/status Wed Feb 06 13:22:28 2013 +0100
+++ b/htdocs/cgi-bin/status Thu Feb 07 11:45:50 2013 +0100
@@ -9,7 +9,7 @@
use FindBin qw($RealBin);
my $cgi = new CGI;
-my $tt = Template->new({INCLUDE_PATH => "$RealBin/../templates"})
+my $tt = Template->new({INCLUDE_PATH => "$RealBin/../templates/"})
or die "Can't create template object: $Template::ERROR\n";
if (!$cgi->param("_submit")) {
@@ -19,12 +19,14 @@
$tt->process("status.html");
exit 0;
}
-
+my $id=$cgi->param("anummer");
+chomp $id;
+my @uuid;
open (UUID, "<UUID");
-my @uuid = <UUID>;
+ @uuid = <UUID>;
close UUID;
-
-my ($error, $farbe);
+my $uuid = join(" .:;:. ",@uuid);
+my ($error, $farbe, $aerror);
if ($cgi->param("anummer") eq ''){
$error="missing Key";
$farbe='rot';
@@ -33,32 +35,42 @@
if($cgi->param("anummer") !~ m/^[A-F0-9]{8}\-[A-F0-9]{4}\-[A-F0-9]{4}\-[A-F0-9]{4}\-[A-F0-9]{12}/){
$error="invalid Key";
$farbe="red";
+ $aerror="Format: 1A2B3C4B-5E6F-7G8H-9I0J-1K2L3M4N5O6P";
+
}
-else{
- foreach (@uuid){
- if ($cgi->param("anummer") eq $_) {
+
+if ($cgi->param("anummer") =~ m/^[A-F0-9]{8}\-[A-F0-9]{4}\-[A-F0-9]{4}\-[A-F0-9]{4}\-[A-F0-9]{12}/){
+ for(my $x=0;$x<=$#uuid;$x++){
+ chomp($uuid[$x]);
+ if ($cgi->param("anummer") eq $uuid[$x]) {
$farbe="black";
- next;
+ $error='';
+ if (-e "/var/www/download/$id"){
+ last;
+ }
+ else{$error="Your order will be processed";}
+ last;
}
- else{
- $error="no such Job-ID";
- exit 0;
- }
+ else {$error="No such ID";}
}
}
+
if ($error){
print CGI::header(-type => "text/html", -charset => "utf-8");
$tt->process("status.html", {
farbe => $farbe,
anummer => $cgi->param("anummer"),
- error => \$error,
+ error => $error,
+ aerror => $aerror,
+ test => $uuid,
}) or die $tt->error();
exit 0;
}
-my $scp=Net::SCP->new();
-$scp->scp("root@192.168.0.144:/usr/lib/cgi-bin/".$cgi->param("anummer"), "/var/www/download/".$cgi->param("anummer"));
-
print CGI::header(-type => "text/html", -charset => "utf-8");
$tt->process("download.html",{
- uuid => $cgi->param("anummer")
-});
+ uuid => $id,
+})or die $tt->error;
+exit 0;
+__END__
+my $scp=Net::SCP->new();
+$scp->scp("root\@192.168.0.144:/var/www/tmp/.$cgi->param('anummer')","/var/www/download/".$cgi->param("anummer"));