# HG changeset patch # User Eric Schmalfuß (prakti) # Date 1360233950 -3600 # Node ID bd470c2d0a0aa55e602de8dff5df6f68cf5dd1fb # Parent 0e2b0e64bc2143e67da494fb370dbfc8809b5ded Ready to go. diff -r 0e2b0e64bc21 -r bd470c2d0a0a htdocs/cgi-bin/receive --- 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/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 (''); close OUT; + +# Folgend Test-Script + +#if ($Formular{req} ne ''){ +# open (OUT, ">$uid.pem"); +# print OUT "$Formular{req}"; +# close OUT; +#} diff -r 0e2b0e64bc21 -r bd470c2d0a0a htdocs/cgi-bin/send --- 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=''; 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/\/g; +} +$requ=join(" ",@req); +open (OUT,">req"); +print OUT "@req"; +close OUT; +open (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/*"); diff -r 0e2b0e64bc21 -r bd470c2d0a0a htdocs/cgi-bin/status --- 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 = ; 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")); diff -r 0e2b0e64bc21 -r bd470c2d0a0a htdocs/templates/download.html --- 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 @@ + + Download diff -r 0e2b0e64bc21 -r bd470c2d0a0a htdocs/templates/index.html --- 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 @@ - - + + SSL-Zertifikat erneuern @@ -46,10 +46,10 @@

-

+ [% reset %]

-

Sie haben bereits eine Anfrage gesendet?
Klicken Sie bittehier.

+

Sie haben bereits eine Anfrage gesendet?
Klicken Sie bitte hier.

diff -r 0e2b0e64bc21 -r bd470c2d0a0a htdocs/templates/status.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 @@ - - + + Auftragsstatus @@ -23,13 +23,16 @@ - Format: 1A2B3C4B-5E6F-7G8H-9I0J-1K2L3M4N5O6P + [% aerror %] + + + + [% test %] [% END %] -

-

+

diff -r 0e2b0e64bc21 -r bd470c2d0a0a htdocs/templates/wait.html --- 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 @@ - - + + Anfrage wird bearbeitet @@ -11,5 +11,6 @@

Ihre Anfrage wurde an die zuständige CA übermittelt.
Dieser Vorgang kann einige Zeit in Anspruch nehmen.
Bitte notieren Sie sich die folgende Nummer.
Mit dieser Nummer können Sie später den Status ihres Auftrages überprüfen

[%uid%]

Danke für ihr entgegengebrachtes Vertrauen.

+

zurück