htdocs/cgi-bin/send_n
changeset 8 73d827714711
parent 7 2f11b54a69fe
child 9 a915e7231d63
equal deleted inserted replaced
7:2f11b54a69fe 8:73d827714711
     3 use warnings;
     3 use warnings;
     4 use strict;
     4 use strict;
     5 use LWP::UserAgent;
     5 use LWP::UserAgent;
     6 use CGI;
     6 use CGI;
     7 use CGI::Carp qw(fatalsToBrowser);
     7 use CGI::Carp qw(fatalsToBrowser);
       
     8 use Net::SCP;
     8 
     9 
     9 my (
    10 my (
    10     @feld,  $uid, $cgi, $feld, $feld4, $feld1, $feld2,
    11     $uid,   $cgi, $feld, $feld4, $feld1, $feld2,
    11     $feld3, $get, $url, $ua,   $ub,    $req
    12     $feld3, $get, $url,  $ua,    $ub,    $req
    12 );
    13 );
    13 my $x = 1;
    14 my $x = 1;
    14 $uid = `uuidgen`;
    15 $uid = `uuidgen`;
    15 $uid =~ s/-//g;
    16 $uid =~ s/-//g;
    16 chomp $uid;
    17 chomp $uid;
    19 #######################
    20 #######################
    20 # Auswerten der Daten #
    21 # Auswerten der Daten #
    21 # des Web-Formulars   #
    22 # des Web-Formulars   #
    22 #######################
    23 #######################
    23 
    24 
    24 $feld1 = $cgi->param('Firma');    # FIXED
    25 $feld1 = $cgi->param('Firma');
    25 $feld2 = $cgi->param('Name');
    26 $feld2 = $cgi->param('Mail');
    26 $feld3 = $cgi->param('Test');
    27 $feld3 = $cgi->param('Test');
    27 $feld4 = $cgi->param('req');
    28 $feld4 = $cgi->param('req');
    28 $feld1 =~ s/\&/\<26\>/g;
    29 $feld1 =~ s/\&/\<26\>/g;
    29 $feld1 =~ s/\=/\<3D\>/g;
    30 $feld1 =~ s/\=/\<3D\>/g;
    30 $feld1 =~ s/\%/\<25\>/g;
    31 $feld1 =~ s/\%/\<25\>/g;
    62 $req->accept_decodable;
    63 $req->accept_decodable;
    63 $req->content("ID=$uid&Name=$feld1&Mail=$feld2&Test=$feld3&req=$feld4");
    64 $req->content("ID=$uid&Name=$feld1&Mail=$feld2&Test=$feld3&req=$feld4");
    64 $ua->request($req);
    65 $ua->request($req);
    65 
    66 
    66 open( HTML1, ">/var/www/$uid" . "1.html" );
    67 open( HTML1, ">/var/www/$uid" . "1.html" );
    67 print HTML1 (
    68 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>" );
    68 '<!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/'
       
    69       . $uid
       
    70       . '" type="application/octet-stream">Test</a></p></body></html>' );
       
    71 close HTML1;
    69 close HTML1;
    72 
    70 
    73 open( HTML, ">/var/www/$uid.html" );
    71 open( HTML, ">/var/www/$uid.html" );
    74 print HTML (
    72 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\">
    75 "<!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/"
    73 <!--
    76       . $uid
    74 var homepage = 'http://192.168.0.138/" . $uid . "1.html';
    77       . "1.html\"></head><script type=\"text/javascript\">
    75 var sekunden = 10;
    78    <!--
    76 function countdownWeiterleitung(){
    79    var homepage = 'http://192.168.0.138/" . $uid . "1.html';
    77    sekunden--;
    80    var sekunden = 10;
    78    document.getElementById('counter_span').innerHTML = sekunden;
    81    
    79    if ( !sekunden ) {
    82    function countdownWeiterleitung()
    80       document.location.href = homepage;
    83    {
    81    }
    84          sekunden--;
    82 }
    85             document.getElementById('counter_span').innerHTML = sekunden;
    83 window.setInterval('countdownWeiterleitung()', 1000);
    86                if ( !sekunden ) {
    84 //-->
    87                         document.location.href = homepage;
    85 </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>");
    88                            }
       
    89                         }
       
    90                         
       
    91                         window.setInterval('countdownWeiterleitung()', 1000);
       
    92                         //-->
       
    93                         
       
    94                         </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=\""
       
    95       . $uid
       
    96       . "1.html\">hier</a></p></body></html>"
       
    97 );
       
    98 
    86 
    99 #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>");
       
   100 close HTML;
    87 close HTML;
   101 
    88 
   102 # Test
    89 # Test
   103 
       
   104 #$get = HTTP::Request->new( "GET", '192.168.0.144/cgi-bin/'.$uid );
       
   105 
    90 
   106 #######################
    91 #######################
   107 # Erstellen einer     #
    92 # Erstellen einer     #
   108 # Feedback-Seite zum  #
    93 # Feedback-Seite zum  #
   109 # Test mit Weiter-    #
    94 # Test mit Weiter-    #
   118             -content    => "2;URL=http://192.168.0.138/$uid.html"
   103             -content    => "2;URL=http://192.168.0.138/$uid.html"
   119         }
   104         }
   120     ),
   105     ),
   121     -title => 'CGI-Feedback'
   106     -title => 'CGI-Feedback'
   122   );
   107   );
   123 
       
   124 #  $cgi->h1 ('Testen wir mal'),"<br>",$cgi->i('Countdown: ');
       
   125 $cgi->h1( 'CGI-Feedback vom Programm ', $cgi->i('send') );
   108 $cgi->h1( 'CGI-Feedback vom Programm ', $cgi->i('send') );
   126 
       
   127 foreach my $Feld (@Feldnamen) {
   109 foreach my $Feld (@Feldnamen) {
   128     print $cgi->strong('Feldname: '),
   110     print $cgi->strong('Feldname: '),
   129       $Feld,
   111       $Feld,
   130       $cgi->strong(', Inhalt: '),
   112       $cgi->strong(', Inhalt: '),
   131       $cgi->param($Feld), "<br>";
   113       $cgi->param($Feld), "<br>";
   132 }
   114 }
   133 print $cgi->i($uid), $cgi->end_html;
   115 print $cgi->i($uid), $cgi->end_html;
   134 
   116 
   135 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
   117 my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
   136 if ($min >= 55){
   118   localtime(time);
   137    $min +=5;
   119 if ( $min >= 55 ) {
   138    $min -=60;
   120     $min += 5;
   139    $hour +=1;
   121     $min -= 60;
       
   122     $hour += 1;
   140 }
   123 }
   141 else {
   124 else {
   142    $min +=5;
   125     $min += 5;
   143 }
   126 }
   144 open (WRITE, "|at $hour:$min") or die;
   127 open( WRITE, "|sudo at $hour:$min" ) or die;
   145 print WRITE "rm /var/www/$uid*\n";
   128 print WRITE "rm /var/www/$uid*\n";
   146 print WRITE "rm /var/www/download/$uid*\n";
   129 print WRITE "rm /var/www/download/$uid*\n";
   147 close WRITE;
   130 close WRITE;
   148 __END__
   131 __END__