2 |
2 |
3 use strict; |
3 use strict; |
4 use warnings; |
4 use warnings; |
5 use CGI; |
5 use CGI; |
6 use CGI::Carp qw(fatalsToBrowser); |
6 use CGI::Carp qw(fatalsToBrowser); |
|
7 use Net::SCP; |
7 |
8 |
8 my ( |
9 my ( |
9 $Daten, $value, $name, $text, $anhang, $input, |
10 $Daten, $value, $name, $text, $anhang, $input, |
10 $q, $key, $wert, $param, %result, $uid |
11 $q, $key, $wert, $param, %result, $uid |
11 ); |
12 ); |
12 my %Formular; |
13 my %Formular; |
13 my @Formularfelder; |
14 my @Formularfelder; |
14 |
15 |
15 #$anhang = $ENV{'QUERY_STRING'}; |
|
16 read( STDIN, $Daten, $ENV{'CONTENT_LENGTH'} ); |
16 read( STDIN, $Daten, $ENV{'CONTENT_LENGTH'} ); |
17 print $Daten; |
17 print $Daten; |
18 &verarbeiten; |
18 &verarbeiten; |
19 |
19 |
20 sub verarbeiten { |
20 sub verarbeiten { |
21 @Formularfelder = split( /&/, $Daten ); |
21 @Formularfelder = split( /&/, $Daten ); |
22 foreach my $Feld (@Formularfelder) { |
22 foreach my $Feld (@Formularfelder) { |
23 ( $name, $value ) = split( /=/, $Feld ); |
23 ( $name, $value ) = split( /=/, $Feld ); |
24 $value=~ s/\<26\>/&/; |
|
25 $value =~ tr/+/ /; |
24 $value =~ tr/+/ /; |
26 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; |
25 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; |
|
26 $value =~ s/\<3D\>/\=/g; |
|
27 $value =~ s/\<25\>/\%/g; |
|
28 $value =~ s/\<2B\>/\+/g; |
|
29 $value =~ s/\<26\>/\&/g; |
27 $Formular{$name} = $value; |
30 $Formular{$name} = $value; |
28 } |
31 } |
29 } |
32 } |
30 $uid=$Formular{ID}; |
33 $uid=$Formular{ID}; |
31 chomp$uid; |
34 chomp$uid; |
35 my @values = values(%Formular); |
38 my @values = values(%Formular); |
36 @values = reverse @values; |
39 @values = reverse @values; |
37 |
40 |
38 # Folgend Test-Script |
41 # Folgend Test-Script |
39 |
42 |
40 open OUT,">test"; |
43 if ($Formular{req} ne ''){ |
41 print OUT "\@schluessel: @schluessel\n\@werte: @values\n\n"; |
44 open (OUT, ">$uid.pem"); |
42 print OUT $Daten; |
45 print OUT "$Formular{req}"; |
|
46 close OUT; |
|
47 } |
|
48 |
|
49 open OUT,">$uid"; |
|
50 print OUT "\@schluessel:\t=\t\@werte:\n"; |
|
51 print OUT "------------\t\t-------\n\n"; |
|
52 for(my $x=0;$x<=$#schluessel;$x++){ |
|
53 print OUT "$schluessel[$x]\t\t=\t$values[$x]\n"; |
|
54 } |
43 close OUT; |
55 close OUT; |
44 |
56 |
|
57 my $scp=Net::SCP->new(); |
|
58 $scp->scp($uid,'root@192.168.0.138:/var/www/download/'); |
|
59 system ("rm $uid"); |
|
60 system ("rm $uid.pem"); |
|
61 __END__ |
|
62 |
45 # Test |
63 # Test |
46 $uid=$uid.'.html'; |
|
47 my $x=0; |
64 my $x=0; |
48 open( OUT, ">/var/www/$uid" ); |
65 open( OUT, ">/var/www/$uid.html" ); |
49 print OUT ( |
66 print OUT ( |
50 '<!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> |
67 '<!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> |
51 <title>CGI-Feedback</title><body><h1>CGI-Feedback vom Programm <i>recieve</i></h1>' |
68 <title>CGI-Feedback</title><body><h1>CGI-Feedback vom Programm <i>recieve</i></h1>' |
52 ); |
69 ); |
53 foreach (@schluessel) { |
70 foreach (@schluessel) { |