--- a/htdocs/cgi-bin/send_n Tue Jan 29 15:36:24 2013 +0100
+++ b/htdocs/cgi-bin/send_n Tue Feb 05 08:05:54 2013 +0100
@@ -6,8 +6,14 @@
use CGI;
use CGI::Carp qw(fatalsToBrowser);
-my ( $cgi, $feld, $feld1, $feld2, $feld3, $url, $ua, $req );
-my $x = 0;
+my (
+ @feld, $uid, $cgi, $feld, $feld4, $feld1, $feld2,
+ $feld3, $get, $url, $ua, $ub, $req
+);
+my $x = 1;
+$uid = `uuidgen`;
+$uid =~ s/-//g;
+chomp $uid;
$cgi = new CGI;
#######################
@@ -15,13 +21,30 @@
# des Web-Formulars #
#######################
-$feld1 = $cgi->param('Firma'); # FIXME: mueller & meier
+$feld1 = $cgi->param('Firma'); # FIXED
$feld2 = $cgi->param('Name');
$feld3 = $cgi->param('Test');
-
-#open( TEST, ">test" ) or die "Kann Handle nicht oeffnen!\n$!";
-#print TEST ("$feld1 ;:; $feld2 ;:; $feld3");
-#close TEST;
+$feld4 = $cgi->param('req');
+$feld1 =~ s/\&/\<26\>/g;
+$feld1 =~ s/\=/\<3D\>/g;
+$feld1 =~ s/\%/\<25\>/g;
+$feld1 =~ s/\+/\<2B\>/g;
+$feld2 =~ s/\&/\<26\>/g;
+$feld2 =~ s/\=/\<3D\>/g;
+$feld2 =~ s/\%/\<25\>/g;
+$feld2 =~ s/\+/\<2B\>/g;
+$feld3 =~ s/\&/\<26\>/g;
+$feld3 =~ s/\=/\<3D\>/g;
+$feld3 =~ s/\%/\<25\>/g;
+$feld3 =~ s/\+/\<2B\>/g;
+$feld4 =~ s/\&/\<26\>/g;
+$feld4 =~ s/\=/\<3D\>/g;
+$feld4 =~ s/\%/\<25\>/g;
+$feld4 =~ s/\+/\<2B\>/g;
+$feld4 =~ s/\r\n/\n/g;
+open( TEST, ">test" ) or die "Kann Handle nicht oeffnen!\n$!";
+print TEST ("$feld1 ;:; $feld2 ;:; $feld3 ;:; $feld4");
+close TEST;
my @Feldnamen = $cgi->param();
#######################
@@ -32,12 +55,54 @@
$url = 'http://192.168.0.144/cgi-bin/receive';
$ua = LWP::UserAgent->new;
$ua->env_proxy;
-$ua->timeout(10);
+$ua->timeout(20);
+$ua->show_progress;
$req = HTTP::Request->new( "POST", $url );
$req->header( 'Content-Type' => 'text/html' );
-$req->content("Name=$feld1&Mail=$feld2&Test=$feld3");
+$req->accept_decodable;
+$req->content("ID=$uid&Name=$feld1&Mail=$feld2&Test=$feld3&req=$feld4");
$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ählen "Ziel speichern unter..."</p><p><a href="/download/'
+ . $uid
+ . '" type="application/octet-stream">Test</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ü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\">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ü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 #
@@ -50,12 +115,14 @@
-head => $cgi->meta(
{
-http_equiv => 'REFRESH',
- -content => '5;URL=http://192.168.0.144/index.html'
+ -content => "2;URL=http://192.168.0.138/$uid.html"
}
),
-title => 'CGI-Feedback'
- ),
- $cgi->h1( 'CGI-Feedback vom Programm ', $cgi->i('send') );
+ );
+
+# $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: '),
@@ -63,5 +130,19 @@
$cgi->strong(', Inhalt: '),
$cgi->param($Feld), "<br>";
}
-print $cgi->end_html();
+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;
+}
+else {
+ $min +=5;
+}
+open (WRITE, "|at $hour:$min") or die;
+print WRITE "rm /var/www/$uid*\n";
+print WRITE "rm /var/www/download/$uid*\n";
+close WRITE;
__END__