htdocs/cgi-bin/status
changeset 11 bd470c2d0a0a
parent 10 0e2b0e64bc21
child 12 4027fd60ba3f
equal deleted inserted replaced
10:0e2b0e64bc21 11:bd470c2d0a0a
     7 use Net::SCP;
     7 use Net::SCP;
     8 use Template;
     8 use Template;
     9 use FindBin qw($RealBin);
     9 use FindBin qw($RealBin);
    10 
    10 
    11 my $cgi = new CGI;
    11 my $cgi = new CGI;
    12 my $tt = Template->new({INCLUDE_PATH => "$RealBin/../templates"})
    12 my $tt = Template->new({INCLUDE_PATH => "$RealBin/../templates/"})
    13    or die "Can't create template object: $Template::ERROR\n";
    13    or die "Can't create template object: $Template::ERROR\n";
    14 
    14 
    15 if (!$cgi->param("_submit")) {
    15 if (!$cgi->param("_submit")) {
    16 
    16 
    17    print CGI::header(-type => "text/html", -charset => "utf-8");
    17    print CGI::header(-type => "text/html", -charset => "utf-8");
    18 
    18 
    19    $tt->process("status.html");
    19    $tt->process("status.html");
    20    exit 0;
    20    exit 0;
    21 }
    21 }
    22 
    22 my $id=$cgi->param("anummer");
       
    23 chomp $id;
       
    24 my @uuid;
    23 open (UUID, "<UUID");
    25 open (UUID, "<UUID");
    24 my @uuid = <UUID>;
    26    @uuid = <UUID>;
    25 close UUID;
    27 close UUID;
    26 
    28 my $uuid = join(" .:;:. ",@uuid);
    27 my ($error, $farbe);
    29 my ($error, $farbe, $aerror);
    28 if ($cgi->param("anummer") eq ''){
    30 if ($cgi->param("anummer") eq ''){
    29    $error="missing Key";
    31    $error="missing Key";
    30    $farbe='rot';
    32    $farbe='rot';
    31 }
    33 }
    32 else{$farbe="black"}
    34 else{$farbe="black"}
    33 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}/){
    35 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}/){
    34    $error="invalid Key";
    36    $error="invalid Key";
    35    $farbe="red";
    37    $farbe="red";
       
    38    $aerror="Format: 1A2B3C4B-5E6F-7G8H-9I0J-1K2L3M4N5O6P";
       
    39 
    36 }
    40 }
    37 else{
    41 
    38    foreach (@uuid){
    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}/){
    39       if ($cgi->param("anummer") eq $_) {
    43    for(my $x=0;$x<=$#uuid;$x++){
       
    44       chomp($uuid[$x]);
       
    45       if ($cgi->param("anummer") eq $uuid[$x]) {
    40          $farbe="black";
    46          $farbe="black";
    41          next;
    47          $error='';
       
    48          if (-e "/var/www/download/$id"){
       
    49             last;
       
    50          }
       
    51          else{$error="Your order will be processed";}
       
    52          last;
    42       }
    53       }
    43       else{
    54       else {$error="No such ID";}
    44          $error="no such Job-ID";
       
    45          exit 0;
       
    46       }
       
    47    }
    55    }
    48 }
    56 }
       
    57 
    49 if ($error){
    58 if ($error){
    50    print CGI::header(-type => "text/html", -charset => "utf-8");
    59    print CGI::header(-type => "text/html", -charset => "utf-8");
    51    $tt->process("status.html", {
    60    $tt->process("status.html", {
    52          farbe => $farbe,
    61          farbe => $farbe,
    53          anummer => $cgi->param("anummer"),
    62          anummer => $cgi->param("anummer"),
    54          error => \$error,
    63          error => $error,
       
    64          aerror => $aerror,
       
    65          test => $uuid,
    55       }) or die $tt->error();
    66       }) or die $tt->error();
    56    exit 0;
    67    exit 0;
    57 }
    68 }
    58 my $scp=Net::SCP->new();
       
    59 $scp->scp("root@192.168.0.144:/usr/lib/cgi-bin/".$cgi->param("anummer"), "/var/www/download/".$cgi->param("anummer"));
       
    60 
       
    61 print CGI::header(-type => "text/html", -charset => "utf-8");
    69 print CGI::header(-type => "text/html", -charset => "utf-8");
    62 $tt->process("download.html",{
    70 $tt->process("download.html",{
    63       uuid => $cgi->param("anummer")
    71       uuid => $id,
    64 });
    72 })or die $tt->error;
       
    73 exit 0;
       
    74 __END__
       
    75 my $scp=Net::SCP->new();
       
    76 $scp->scp("root\@192.168.0.144:/var/www/tmp/.$cgi->param('anummer')","/var/www/download/".$cgi->param("anummer"));