Changes draft
authorEric Schmalfuß (prakti) <eric.schmalfuss@schlittermann.de>
Tue, 05 Feb 2013 14:01:36 +0100
changeset 8 73d827714711
parent 7 2f11b54a69fe
child 9 a915e7231d63
Changes
htdocs/cgi-bin/receive
htdocs/cgi-bin/send_n
htdocs/index.html
--- a/htdocs/cgi-bin/receive	Tue Feb 05 08:05:54 2013 +0100
+++ b/htdocs/cgi-bin/receive	Tue Feb 05 14:01:36 2013 +0100
@@ -4,6 +4,7 @@
 use warnings;
 use CGI;
 use CGI::Carp qw(fatalsToBrowser);
+use Net::SCP;
 
 my (
     $Daten, $value, $name, $text,  $anhang, $input,
@@ -12,7 +13,6 @@
 my %Formular;
 my @Formularfelder;
 
-#$anhang = $ENV{'QUERY_STRING'};
 read( STDIN, $Daten, $ENV{'CONTENT_LENGTH'} );
 print $Daten;
 &verarbeiten;
@@ -21,9 +21,12 @@
     @Formularfelder = split( /&/, $Daten );
     foreach my $Feld (@Formularfelder) {
         ( $name, $value ) = split( /=/, $Feld );
-		$value=~ s/\<26\>/&/;
         	$value =~ tr/+/ /;
         	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
+		$value =~ s/\<3D\>/\=/g;
+		$value =~ s/\<25\>/\%/g;
+		$value =~ s/\<2B\>/\+/g;
+		$value =~ s/\<26\>/\&/g;
         $Formular{$name} = $value;
     }
 }
@@ -37,15 +40,29 @@
 
 # Folgend Test-Script
 
-open OUT,">test";
-print OUT "\@schluessel: @schluessel\n\@werte: @values\n\n";
-print OUT $Daten;
+if ($Formular{req} ne ''){
+	open (OUT, ">$uid.pem");
+	print OUT "$Formular{req}";
+	close OUT;
+}
+
+open OUT,">$uid";
+print OUT "\@schluessel:\t=\t\@werte:\n";
+print OUT "------------\t\t-------\n\n";
+for(my $x=0;$x<=$#schluessel;$x++){
+print OUT "$schluessel[$x]\t\t=\t$values[$x]\n";
+}
 close OUT;
 
+my $scp=Net::SCP->new();
+$scp->scp($uid,'root@192.168.0.138:/var/www/download/');
+system ("rm $uid");
+system ("rm $uid.pem");
+__END__
+
 # Test
-$uid=$uid.'.html';
 my $x=0;
-open( OUT, ">/var/www/$uid" );
+open( OUT, ">/var/www/$uid.html" );
 print OUT (
 '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"><head>
 <title>CGI-Feedback</title><body><h1>CGI-Feedback vom Programm  <i>recieve</i></h1>'
@@ -60,6 +77,3 @@
 }
 print OUT ('</body></html>');
 close OUT;
-sleep(180);
-system "rm /var/www/$uid";
-__END__
--- a/htdocs/cgi-bin/send_n	Tue Feb 05 08:05:54 2013 +0100
+++ b/htdocs/cgi-bin/send_n	Tue Feb 05 14:01:36 2013 +0100
@@ -5,10 +5,11 @@
 use LWP::UserAgent;
 use CGI;
 use CGI::Carp qw(fatalsToBrowser);
+use Net::SCP;
 
 my (
-    @feld,  $uid, $cgi, $feld, $feld4, $feld1, $feld2,
-    $feld3, $get, $url, $ua,   $ub,    $req
+    $uid,   $cgi, $feld, $feld4, $feld1, $feld2,
+    $feld3, $get, $url,  $ua,    $ub,    $req
 );
 my $x = 1;
 $uid = `uuidgen`;
@@ -21,8 +22,8 @@
 # des Web-Formulars   #
 #######################
 
-$feld1 = $cgi->param('Firma');    # FIXED
-$feld2 = $cgi->param('Name');
+$feld1 = $cgi->param('Firma');
+$feld2 = $cgi->param('Mail');
 $feld3 = $cgi->param('Test');
 $feld4 = $cgi->param('req');
 $feld1 =~ s/\&/\<26\>/g;
@@ -64,45 +65,29 @@
 $ua->request($req);
 
 open( HTML1, ">/var/www/$uid" . "1.html" );
-print HTML1 (
-'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Download</title></head><body><p>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 href="/download/'
-      . $uid
-      . '" type="application/octet-stream">Test</a></p></body></html>' );
+print HTML1 ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><head><title>Download</title></head><body><p>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/$uid\" type=\"application/octet-stream\">$uid</a></p ></body></html>" );
 close HTML1;
 
 open( HTML, ">/var/www/$uid.html" );
-print HTML (
-"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><head><title>Download</title><meta http_equiv=\"refresh\" content=\"10;URL=http://192.168.0.138/"
-      . $uid
-      . "1.html\"></head><script type=\"text/javascript\">
-   <!--
-   var homepage = 'http://192.168.0.138/" . $uid . "1.html';
-   var sekunden = 10;
-   
-   function countdownWeiterleitung()
-   {
-         sekunden--;
-            document.getElementById('counter_span').innerHTML = sekunden;
-               if ( !sekunden ) {
-                        document.location.href = homepage;
-                           }
-                        }
-                        
-                        window.setInterval('countdownWeiterleitung()', 1000);
-                        //-->
-                        
-                        </script><body><p>Ihr Download steht in k&uuml;rze bereit!<br>Sie werden in <span id=\"counter_span\" class=\"dd\">10</span> sekunden automatisch Weitergeleitet.<br>Sollte die automatische Weiterleitung nicht funktionieren, klicken Sie bitte <a href=\""
-      . $uid
-      . "1.html\">hier</a></p></body></html>"
-);
+print HTML ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><head><title>Download</title><meta http_equiv=\"refresh\" content=\"10;URL=http://192.168.0.138/". $uid . "1.html\"></head><script type=\"text/javascript\">
+<!--
+var homepage = 'http://192.168.0.138/" . $uid . "1.html';
+var sekunden = 10;
+function countdownWeiterleitung(){
+   sekunden--;
+   document.getElementById('counter_span').innerHTML = sekunden;
+   if ( !sekunden ) {
+      document.location.href = homepage;
+   }
+}
+window.setInterval('countdownWeiterleitung()', 1000);
+//-->
+</script><body><p>Ihr Download steht in k&uuml;rze bereit!<br>Sie werden in <span id=\"counter_span\" class=\"dd\">10</span> sekunden automatisch Weitergeleitet.<br>Sollte die automatische Weiterleitung nicht funktionieren, klicken Sie bitte <a style=\"text-decoration: none;\" href=\"".$uid."1.html\">hier</a>.</p><p>Bitte beachten Sie, dass Ihr Download nur 5 minuten g&uuml;ltig ist.</p></body></html>");
 
-#print HTML ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><head><title>Download</title><meta http_equiv=\"refresh\" content=\"10;URL=http://192.168.0.138/$uid\1.html\"></head><script type=\"text/javascript\">function countDown(init){if (init || --document.getElementById( \"counter\" ).firstChild.nodeValue >0 )window.setTimeout(\"countDown()\",1000);};</script><body onload=\"countDown(true)\"><p>Ihr Download steht in k&uuml;rze bereit!<br>Sie werden in <span id=\"counter\" class=\"dd\">10</span> sekunden automatisch Weitergeleitet.<br>Sollte die automatische Weiterleitung nicht funktionieren, klicken Sie bitte <a href=\"$uid\1.html\">hier</a></p></body></html>");
 close HTML;
 
 # Test
 
-#$get = HTTP::Request->new( "GET", '192.168.0.144/cgi-bin/'.$uid );
-
 #######################
 # Erstellen einer     #
 # Feedback-Seite zum  #
@@ -120,10 +105,7 @@
     ),
     -title => 'CGI-Feedback'
   );
-
-#  $cgi->h1 ('Testen wir mal'),"<br>",$cgi->i('Countdown: ');
 $cgi->h1( 'CGI-Feedback vom Programm ', $cgi->i('send') );
-
 foreach my $Feld (@Feldnamen) {
     print $cgi->strong('Feldname: '),
       $Feld,
@@ -132,16 +114,17 @@
 }
 print $cgi->i($uid), $cgi->end_html;
 
-my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
-if ($min >= 55){
-   $min +=5;
-   $min -=60;
-   $hour +=1;
+my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
+  localtime(time);
+if ( $min >= 55 ) {
+    $min += 5;
+    $min -= 60;
+    $hour += 1;
 }
 else {
-   $min +=5;
+    $min += 5;
 }
-open (WRITE, "|at $hour:$min") or die;
+open( WRITE, "|sudo at $hour:$min" ) or die;
 print WRITE "rm /var/www/$uid*\n";
 print WRITE "rm /var/www/download/$uid*\n";
 close WRITE;
--- a/htdocs/index.html	Tue Feb 05 08:05:54 2013 +0100
+++ b/htdocs/index.html	Tue Feb 05 14:01:36 2013 +0100
@@ -1,12 +1,14 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
    <head>
+      <link rel="shortcut icon" href="favicon.ico" >
+      <link rel="icon" href="animated_favicon.gif" type="image/gif" >
       <title>SSL-Zertifikat erneuern</title>
       </head>
       <body bgcolor="#00FFFF">
          <h1>Zertifikat abgelaufen?</h1>
          <p>Dann f&uuml;llen Sie doch einfach das Formular aus.</p>
-         <form action="./cgi-bin/send_n">
+         <form action="./cgi-bin/send_n" enctype="multipart/form-data">
             <table border="0" cellpadding="0" cellspacing="4">
                <tr>
                   <td align="right">Firma:</td>
@@ -14,17 +16,21 @@
                   </tr>
                   <tr>
                      <td align="right">Mail:</td>
-                     <td><input name="Name" size="40"></td>
+                     <td><input name="Mail" size="40"></td>
+                  </tr>
+                  <tr>
+                     <td align="right">Firmenstandort:</td>
+                     <td><input name="Ort" type="text" size="40"></td>
                   </tr>
                   <tr>
-                     <td align="right">Test:</td>
-                     <td><input name="Test" type="text" size="40"></td>
-                  </tr>
+                     <td align="right">Request-Code:</td>
+                     <td><textarea name="req" cols="52" rows="10"></textarea></td>
+                  </tr>   
                   <tr>
-                     <td align="right">Request-Code:<br>(optional)</td>
-                     <td><textarea name="req" cols="52" rows="10"></textarea></td>
+                     <td></td>
+                     <td><p><input type="submit" value="Formulardaten absenden"> <input type="reset"></p></p>
+                  </tr>
                </table>
-            <p><input type="submit" value="Formulardaten absenden"></p>
       </form>
    </body>
 </html>