Ready to go.
--- a/htdocs/cgi-bin/receive Wed Feb 06 13:22:28 2013 +0100
+++ b/htdocs/cgi-bin/receive Thu Feb 07 11:45:50 2013 +0100
@@ -10,16 +10,14 @@
$Daten, $value, $name, $text, $anhang, $input,
$q, $key, $wert, $param, %result, $uid
);
-my %Formular;
my @Formularfelder;
-
+my %field;
read( STDIN, $Daten, $ENV{'CONTENT_LENGTH'} );
-print $Daten;
&verarbeiten;
sub verarbeiten {
@Formularfelder = split( /&/, $Daten );
- foreach my $Feld (@Formularfelder) {
+ foreach my $Feld (@Formularfelder) {
( $name, $value ) = split( /=/, $Feld );
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
@@ -27,38 +25,37 @@
$value =~ s/\<25\>/\%/g;
$value =~ s/\<2B\>/\+/g;
$value =~ s/\<26\>/\&/g;
- $Formular{$name} = $value;
+ $value =~ s/\<n\>/\\n/g;
+ $field{$name} = $value;
}
}
-$uid=$Formular{ID};
-chomp$uid;
-my @test=$Formular{req};
-my @schluessel = keys(%Formular);
-@schluessel = reverse @schluessel;
-my @values = values(%Formular);
-@values = reverse @values;
+
-# Folgend Test-Script
-
-if ($Formular{req} ne ''){
- open (OUT, ">$uid.pem");
- print OUT "$Formular{req}";
- close OUT;
-}
-
-open OUT,">$uid";
+#$"=" .:. ";
+$uid=$field{id};
+chomp ($uid);
+open (OUT,">/var/www/tmp/$uid") or die "$!\n";
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";
+foreach (sort keys %field) {
+ print OUT "$_:\t\t\t $field{$_}\n";
}
+print OUT $Daten;
close OUT;
my $scp=Net::SCP->new();
-$scp->scp($uid,'root@192.168.0.138:/var/www/download/');
-unlink $uid, "$uid.pem";
+$scp->scp("/var/www/tmp/$uid",'root@192.168.0.138:/var/www/download/');
+#unlink grep { -M > 3/(24*36) } glob("/var/www/tmp/*");
__END__
+#$uid=$Formular{ID};
+#chomp$uid;
+#my @test=$Formular{req};
+#my @schluessel = keys(%Formular);
+#@schluessel = reverse @schluessel;
+#my @values = values(%Formular);
+#@values = reverse @values;
+
# Test
my $x=0;
open( OUT, ">/var/www/$uid.html" );
@@ -76,3 +73,11 @@
}
print OUT ('</body></html>');
close OUT;
+
+# Folgend Test-Script
+
+#if ($Formular{req} ne ''){
+# open (OUT, ">$uid.pem");
+# print OUT "$Formular{req}";
+# close OUT;
+#}
--- a/htdocs/cgi-bin/send Wed Feb 06 13:22:28 2013 +0100
+++ b/htdocs/cgi-bin/send Thu Feb 07 11:45:50 2013 +0100
@@ -10,16 +10,19 @@
use Cwd;
use FindBin qw($RealBin);
use Data::UUID;
-
+my $requ;
my $cgi = new CGI;
my $tt = Template->new({INCLUDE_PATH => "$RealBin/../templates"})
or die "Can't create template object: $Template::ERROR\n";
+my $reset='<input type="reset">';
if (!$cgi->param("_submit")) {
print CGI::header(-type => "text/html", -charset => "utf-8");
- $tt->process("index.html");
+ $tt->process("index.html",{
+ reset => $reset,
+ });
exit 0;
}
@@ -27,49 +30,59 @@
# anzeigen
# CHECK
-
- my (%error, $ffarbe, $ofarbe, $mfarbe, $rfarbe);
- if ($cgi->param("firma") eq ''){
- $error{firma} = "missing company";
- $ffarbe='rot';
- }
- else{$ffarbe='black'}
- if ($cgi->param("mail") eq ''){
- $error{mail}= "missing mail";
- $mfarbe='red';
- }
- elsif ($cgi->param("mail") !~ m/^[a-zA-Z0-9\.-_]*\@\w+\.\w{2,}/){
- $error{mail}="no valid mail";
- $mfarbe='red';
- }
- else{$mfarbe='black'}
- if ($cgi->param("ort") eq ''){
- $error{ort}= "missing city";
- $ofarbe='red';
- }
- else{$ofarbe='black'}
- if ($cgi->param("req") eq ''){
- $error{req}="missing request";
- $rfarbe='red';
- }
- else{$rfarbe='black'}
- if (%error) {
- print CGI::header(-type => "text/html", -charset => "utf-8");
- $tt->process("index.html", {
- dump => $cgi->Dump(),
- now => time(),
- error => \%error,
- firma => $cgi->param("firma"),
- ffarbe=>$ffarbe,
- mail => $cgi->param("mail"),
- mfarbe=>$mfarbe,
- ort => $cgi->param("ort"),
- ofarbe=>$ofarbe,
- req => $cgi->param("req"),
- rfarbe=>$rfarbe,
- }) or die $tt->error();
- exit 0;
- }
+my @req =$cgi->param("req");
+foreach (@req){
+ s/\r\n/\<n\>/g;
+}
+$requ=join(" ",@req);
+open (OUT,">req");
+print OUT "@req";
+close OUT;
+open (IN,"<req");
+my @req2=<IN>;
+close IN;
+my (%error, $ffarbe, $ofarbe, $mfarbe, $rfarbe);
+if ($cgi->param("firma") eq ''){
+ $error{firma} = "missing company";
+ $ffarbe='red';
+}
+else{$ffarbe='black'}
+if ($cgi->param("mail") eq ''){
+ $error{mail}= "missing mail";
+ $mfarbe='red';
+}
+elsif ($cgi->param("mail") !~ m/^[a-zA-Z0-9\.-_]*\@\w+\.\w{2,}/){
+ $error{mail}="no valid mail";
+ $mfarbe='red';
+}
+else{$mfarbe='black'}
+if ($cgi->param("ort") eq ''){
+ $error{ort}= "missing city";
+ $ofarbe='red';
+}
+else{$ofarbe='black'}
+if ($cgi->param("req") eq ''){
+ $error{req}="missing request";
+ $rfarbe='red';
+}
+else{$rfarbe='black'}
+if (%error) {
+ print CGI::header(-type => "text/html", -charset => "utf-8");
+ $tt->process("index.html", {
+ dump => $cgi->Dump(),
+ now => time(),
+ error => \%error,
+ firma => $cgi->param("firma"),
+ ffarbe=>$ffarbe,
+ mail => $cgi->param("mail"),
+ mfarbe=>$mfarbe,
+ ort => $cgi->param("ort"),
+ ofarbe=>$ofarbe,
+ req => $cgi->param("req"),
+ rfarbe=>$rfarbe,
+ }) or die $tt->error();
+ exit 0;
+}
# alles ist ok
@@ -78,20 +91,19 @@
$ub=new Data::UUID;
$uid=$ub->create_str;
open (UUID, ">>UUID") or die "$!\n";
-print UUID $uid;
+print UUID "$uid\n";
close UUID;
#######################
# Auswerten der Daten #
# des Web-Formulars #
#######################
-
my %field = (
firma => $cgi->param('firma'),
mail => $cgi->param('mail'),
ort => $cgi->param('ort'),
- req => $cgi->param('req'),
+# req => $cgi->param('req'),
);
-
+$"=" .:. ";
foreach (values %field) {
s/\&/\<26\>/g;
s/\=/\<3D\>/g;
@@ -102,8 +114,10 @@
my $test='test';
open( TEST,"> $test" ) or die "Kann $test nicht öffnen: $!\n";
foreach (sort keys %field) {
- print "$_: $field{$_}\n";
+ print TEST "$_: $field{$_}\n";
}
+print TEST "@req\n";
+print TEST " .:. @req2\n";
close TEST;
my @Feldnamen = $cgi->param();
@@ -120,13 +134,14 @@
$req = HTTP::Request->new( "POST", $url );
$req->header( 'Content-Type' => 'text/html' );
$req->accept_decodable;
-$req->content("ID=$uid&Name=$field{firma}&Mail=$field{mail}&Test=$field{ort}&req=$field{req}");
+$req->content("id=$uid&firma=$field{firma}&mail=$field{mail}&ort=$field{ort}&req=$requ");
$ua->request($req);
print CGI::header(-type => "text/html", -charset => "utf-8");
$tt->process("wait.html",{
uid => $uid
}) or die $tt->error;
+exit 0;
unlink grep { -M > 3/(24*36) } glob("/var/www/tmp/*");
--- a/htdocs/cgi-bin/status Wed Feb 06 13:22:28 2013 +0100
+++ b/htdocs/cgi-bin/status Thu Feb 07 11:45:50 2013 +0100
@@ -9,7 +9,7 @@
use FindBin qw($RealBin);
my $cgi = new CGI;
-my $tt = Template->new({INCLUDE_PATH => "$RealBin/../templates"})
+my $tt = Template->new({INCLUDE_PATH => "$RealBin/../templates/"})
or die "Can't create template object: $Template::ERROR\n";
if (!$cgi->param("_submit")) {
@@ -19,12 +19,14 @@
$tt->process("status.html");
exit 0;
}
-
+my $id=$cgi->param("anummer");
+chomp $id;
+my @uuid;
open (UUID, "<UUID");
-my @uuid = <UUID>;
+ @uuid = <UUID>;
close UUID;
-
-my ($error, $farbe);
+my $uuid = join(" .:;:. ",@uuid);
+my ($error, $farbe, $aerror);
if ($cgi->param("anummer") eq ''){
$error="missing Key";
$farbe='rot';
@@ -33,32 +35,42 @@
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}/){
$error="invalid Key";
$farbe="red";
+ $aerror="Format: 1A2B3C4B-5E6F-7G8H-9I0J-1K2L3M4N5O6P";
+
}
-else{
- foreach (@uuid){
- if ($cgi->param("anummer") eq $_) {
+
+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}/){
+ for(my $x=0;$x<=$#uuid;$x++){
+ chomp($uuid[$x]);
+ if ($cgi->param("anummer") eq $uuid[$x]) {
$farbe="black";
- next;
+ $error='';
+ if (-e "/var/www/download/$id"){
+ last;
+ }
+ else{$error="Your order will be processed";}
+ last;
}
- else{
- $error="no such Job-ID";
- exit 0;
- }
+ else {$error="No such ID";}
}
}
+
if ($error){
print CGI::header(-type => "text/html", -charset => "utf-8");
$tt->process("status.html", {
farbe => $farbe,
anummer => $cgi->param("anummer"),
- error => \$error,
+ error => $error,
+ aerror => $aerror,
+ test => $uuid,
}) or die $tt->error();
exit 0;
}
-my $scp=Net::SCP->new();
-$scp->scp("root@192.168.0.144:/usr/lib/cgi-bin/".$cgi->param("anummer"), "/var/www/download/".$cgi->param("anummer"));
-
print CGI::header(-type => "text/html", -charset => "utf-8");
$tt->process("download.html",{
- uuid => $cgi->param("anummer")
-});
+ uuid => $id,
+})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 Wed Feb 06 13:22:28 2013 +0100
+++ b/htdocs/templates/download.html Thu Feb 07 11:45:50 2013 +0100
@@ -1,6 +1,8 @@
<!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="http://192.168.0.138/favicon.ico" >
+ <link rel="icon" href="httP://192.168.0.138/animated_favicon.gif" type="image/gif" >
<title>Download</title>
</head>
<body>
--- a/htdocs/templates/index.html Wed Feb 06 13:22:28 2013 +0100
+++ b/htdocs/templates/index.html Thu Feb 07 11:45:50 2013 +0100
@@ -2,8 +2,8 @@
<!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" >
+ <link rel="shortcut icon" href="http://192.168.0.138/favicon.ico" >
+ <link rel="icon" href="httP://192.168.0.138/animated_favicon.gif" type="image/gif" >
<title>SSL-Zertifikat erneuern</title>
</head>
<body bgcolor="#00FFFF">
@@ -46,10 +46,10 @@
<tr>
<td></td>
<td><p><input type="submit" name="_submit" value="Formulardaten absenden">
- <input type="reset"></p></p>
+ [% reset %]</p></p>
</tr>
</table>
- <p>Sie haben bereits eine Anfrage gesendet?<br />Klicken Sie bitte<a href="/cgi-bin/status">hier</a>.</p>
+ <p>Sie haben bereits eine Anfrage gesendet?<br />Klicken Sie bitte <a href="/cgi-bin/status">hier</a>.</p>
</form>
</body>
</html>
--- a/htdocs/templates/status.html Wed Feb 06 13:22:28 2013 +0100
+++ b/htdocs/templates/status.html Thu Feb 07 11:45:50 2013 +0100
@@ -1,8 +1,8 @@
<!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" >
+ <link rel="shortcut icon" href="http://192.168.0.138/favicon.ico" >
+ <link rel="icon" href="httP://192.168.0.138/animated_favicon.gif" type="image/gif" >
<title>Auftragsstatus</title>
</head>
<body bgcolor="#00FFFF">
@@ -23,13 +23,16 @@
</tr>
<tr>
<td></td>
- <td>Format: 1A2B3C4B-5E6F-7G8H-9I0J-1K2L3M4N5O6P</td>
+ <td>[% aerror %]</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>[% test %]</td>
</tr>
[% END %]
<tr>
<td></td>
- <td><p><input type="submit" name="_submit" value="Status prüfen">
- <input type="reset"></p></p>
+ <td><p><input type="submit" name="_submit" value="Status prüfen"></p>
</tr>
</table>
</form>
--- a/htdocs/templates/wait.html Wed Feb 06 13:22:28 2013 +0100
+++ b/htdocs/templates/wait.html Thu Feb 07 11:45:50 2013 +0100
@@ -2,8 +2,8 @@
<!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" >
+ <link rel="shortcut icon" href="http://192.168.0.138/favicon.ico" >
+ <link rel="icon" href="httP://192.168.0.138/animated_favicon.gif" type="image/gif" >
<title>Anfrage wird bearbeitet</title>
</head>
<body bgcolor="#00FFFF">
@@ -11,5 +11,6 @@
<p>Ihre Anfrage wurde an die zuständige CA übermittelt.<br />Dieser Vorgang kann einige Zeit in Anspruch nehmen.<br />Bitte notieren Sie sich die folgende Nummer.<br />Mit dieser Nummer können Sie später den Status ihres Auftrages überprüfen</p>
<p>[%uid%]</p>
<p>Danke für ihr entgegengebrachtes Vertrauen.</p>
+ <p><a href="http://192.168.0.138/cgi-bin/send">zurück</a></p>
</body>
</html>