It works! draft
authorEric Schmalfuß (prakti) <eric.schmalfuss@schlittermann.de>
Thu, 07 Feb 2013 14:17:09 +0100
changeset 12 4027fd60ba3f
parent 11 bd470c2d0a0a
child 13 2d60fada033e
It works!
htdocs/cgi-bin/receive
htdocs/cgi-bin/scp
htdocs/cgi-bin/status
htdocs/templates/download.html
htdocs/templates/status.html
htdocs/templates/wait.html
--- a/htdocs/cgi-bin/receive	Thu Feb 07 11:45:50 2013 +0100
+++ b/htdocs/cgi-bin/receive	Thu Feb 07 14:17:09 2013 +0100
@@ -30,8 +30,6 @@
     }
 }
 
-
-#$"=" .:. ";
 $uid=$field{id};
 chomp ($uid);
 open (OUT,">/var/www/tmp/$uid") or die "$!\n";
@@ -44,7 +42,7 @@
 close OUT;
 
 my $scp=Net::SCP->new();
-$scp->scp("/var/www/tmp/$uid",'root@192.168.0.138:/var/www/download/');
+$scp->scp("/var/www/tmp/$uid",'root@192.168.0.138:/var/www/tmp/');
 #unlink grep { -M > 3/(24*36) } glob("/var/www/tmp/*");
 __END__
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/cgi-bin/scp	Thu Feb 07 14:17:09 2013 +0100
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use CGI;
+use CGI::Carp qw(fatalsToBrowser);
+use Net::SCP;
+
+my ($id, $name, $value, $uid);
+read (STDIN, $id , $ENV{'CONTENT_LENGTH'} );
+( $name, $uid ) = split( /=/, $id );
+
+chomp($uid);
+my $scp=Net::SCP->new();
+$scp->scp("/var/www/tmp/$uid",'root@192.168.0.138:/var/www/tmp/');
+__END__
--- a/htdocs/cgi-bin/status	Thu Feb 07 11:45:50 2013 +0100
+++ b/htdocs/cgi-bin/status	Thu Feb 07 14:17:09 2013 +0100
@@ -2,6 +2,7 @@
 
 use warnings;
 use strict;
+use LWP::UserAgent;
 use CGI qw(-utf8);
 use CGI::Carp qw(fatalsToBrowser);
 use Net::SCP;
@@ -27,28 +28,33 @@
 close UUID;
 my $uuid = join(" .:;:. ",@uuid);
 my ($error, $farbe, $aerror);
-if ($cgi->param("anummer") eq ''){
+if ($id eq ''){
    $error="missing Key";
    $farbe='rot';
 }
 else{$farbe="black"}
-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}/){
+if($id !~ 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";
 
 }
 
-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}/){
+if ($id =~ 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]) {
+      if ($id eq $uuid[$x]) {
          $farbe="black";
          $error='';
-         if (-e "/var/www/download/$id"){
+         if (-e "/var/www/tmp/$id"){
             last;
          }
          else{$error="Your order will be processed";}
+         my $url='http://192.168.0.144/cgi-bin/scp';
+         my $ua=LWP::UserAgent->new;
+         my $req=HTTP::Request->new("POST",$url);
+         $req->content("id=$id");
+         $ua->request($req);
          last;
       }
       else {$error="No such ID";}
@@ -59,7 +65,7 @@
    print CGI::header(-type => "text/html", -charset => "utf-8");
    $tt->process("status.html", {
          farbe => $farbe,
-         anummer => $cgi->param("anummer"),
+         anummer => $id,
          error => $error,
          aerror => $aerror,
          test => $uuid,
@@ -72,5 +78,3 @@
 })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"));
--- a/htdocs/templates/download.html	Thu Feb 07 11:45:50 2013 +0100
+++ b/htdocs/templates/download.html	Thu Feb 07 14:17:09 2013 +0100
@@ -10,6 +10,6 @@
    Klicken Sie bitte auf den Link um ihre Datei zu Downloaden oder anzuzeigen.<br>Zum Speichern des Inhaltes klicken Sie den Link mit der rechten Maustaste an und w&auml;hlen "Ziel speichern unter..."
    </p>
    <p>
-   <a style="text-decoration: none;"  href="/download/[%uuid%]" type="application/octet-stream">[%uuid%]</a></p >
+   <a style="text-decoration: none;"  href="/tmp/[%uuid%]" type="application/octet-stream">[%uuid%]</a></p >
    </body>
 </html>
--- a/htdocs/templates/status.html	Thu Feb 07 11:45:50 2013 +0100
+++ b/htdocs/templates/status.html	Thu Feb 07 14:17:09 2013 +0100
@@ -35,6 +35,7 @@
                   <td><p><input type="submit" name="_submit" value="Status pr&uuml;fen"></p>
                </tr>
             </table>
+         <p><a href="http://192.168.0.138/cgi-bin/send">zur&uuml;ck zur Startseite</a></p>
       </form>
    </body>
 </html>                                                  
--- a/htdocs/templates/wait.html	Thu Feb 07 11:45:50 2013 +0100
+++ b/htdocs/templates/wait.html	Thu Feb 07 14:17:09 2013 +0100
@@ -11,6 +11,6 @@
          <p>Ihre Anfrage wurde an die zust&auml;ndige CA &uuml;bermittelt.<br />Dieser Vorgang kann einige Zeit in Anspruch nehmen.<br />Bitte notieren Sie sich die folgende Nummer.<br />Mit dieser Nummer k&ouml;nnen Sie sp&auml;ter den Status ihres Auftrages &uuml;berpr&uuml;fen</p>
          <p>[%uid%]</p>
          <p>Danke f&uuml;r ihr entgegengebrachtes Vertrauen.</p>
-         <p><a href="http://192.168.0.138/cgi-bin/send">zur&uuml;ck</a></p>
+         <p><a href="http://192.168.0.138/cgi-bin/send">zur&uuml;ck zur Startseite</a></p>
    </body>
 </html>