equal
  deleted
  inserted
  replaced
  
    
    
|         |      1 #!/usr/bin/perl | 
|         |      2  | 
|         |      3 use warnings; | 
|         |      4 use strict; | 
|         |      5 use CGI qw(-utf8); | 
|         |      6 use CGI::Carp qw(fatalsToBrowser); | 
|         |      7 use Net::SCP; | 
|         |      8 use Template; | 
|         |      9 use FindBin qw($RealBin); | 
|         |     10  | 
|         |     11 my $cgi = new CGI; | 
|         |     12 my $tt = Template->new({INCLUDE_PATH => "$RealBin/../templates"}) | 
|         |     13    or die "Can't create template object: $Template::ERROR\n"; | 
|         |     14  | 
|         |     15 if (!$cgi->param("_submit")) { | 
|         |     16  | 
|         |     17    print CGI::header(-type => "text/html", -charset => "utf-8"); | 
|         |     18  | 
|         |     19    $tt->process("status.html"); | 
|         |     20    exit 0; | 
|         |     21 } | 
|         |     22  | 
|         |     23 open (UUID, "<UUID"); | 
|         |     24 my @uuid = <UUID>; | 
|         |     25 close UUID; | 
|         |     26  | 
|         |     27 my ($error, $farbe); | 
|         |     28 if ($cgi->param("anummer") eq ''){ | 
|         |     29    $error="missing Key"; | 
|         |     30    $farbe='rot'; | 
|         |     31 } | 
|         |     32 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}/){ | 
|         |     34    $error="invalid Key"; | 
|         |     35    $farbe="red"; | 
|         |     36 } | 
|         |     37 else{ | 
|         |     38    foreach (@uuid){ | 
|         |     39       if ($cgi->param("anummer") eq $_) { | 
|         |     40          $farbe="black"; | 
|         |     41          next; | 
|         |     42       } | 
|         |     43       else{ | 
|         |     44          $error="no such Job-ID"; | 
|         |     45          exit 0; | 
|         |     46       } | 
|         |     47    } | 
|         |     48 } | 
|         |     49 if ($error){ | 
|         |     50    print CGI::header(-type => "text/html", -charset => "utf-8"); | 
|         |     51    $tt->process("status.html", { | 
|         |     52          farbe => $farbe, | 
|         |     53          anummer => $cgi->param("anummer"), | 
|         |     54          error => \$error, | 
|         |     55       }) or die $tt->error(); | 
|         |     56    exit 0; | 
|         |     57 } | 
|         |     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"); | 
|         |     62 $tt->process("download.html",{ | 
|         |     63       uuid => $cgi->param("anummer") | 
|         |     64 }); |