1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sub ParseForm
{
my ($buffer, @pairs, $pair, $name, $value);
if ($ENV{'REQUEST_METHOD'} eq "POST")
{ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
else
{ $buffer = $ENV{'QUERY_STRING'}; }
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
if (defined $FORM{$name}) # vermutlich checkbox
{ $FORM{$name} = $FORM{$name} . ", " . $value; }
else
{ $FORM{$name} = $value; }
}
}
QuoteIch würde trotzdem gerne verstehen, was da passiert.
1 2 3 4 5 6 7 8 9
#!/usr/bin/perl use 5.008; use strict; use warnings; print "Content-Type: text/plain\n\n"; print "$_ => ",$ENV{$_},"\n" for keys %ENV;
1
2
3
GET /xyz/script.cgi?parameter1=4¶meter2=Z HTTP/1.1
HOST www.yourwebpage.de
... und noch weitere Sachen wie User-Agent etc. pp
1
2
3
4
5
POST /xyz/script.cgi HTTP/1.1
HOST: www.yourwebpage.de
Content-Length: 25
parameter1=4¶meter2=Z
1
2
3
4
5
6
7
#!/usr/bin/perl
use strict;
use warnings;
print "Content-Type: text/plain\n\n";
print "$_ => ",$ENV{$_},"\n" for keys %ENV;
<!--#exec cgi="envs.pl" -->
Quote
SCRIPT_NAME => /ssitest/envs.pl
SERVER_NAME => 127.0.0.1
SERVER_ADMIN => webmaster@localhost
HTTP_ACCEPT_ENCODING => gzip, deflate
HTTP_CONNECTION => keep-alive
REQUEST_METHOD => GET
HTTP_DNT => 1
HTTP_ACCEPT => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
DATE_GMT =>
SCRIPT_FILENAME => /home/jan/www/ssitest/envs.pl
DOCUMENT_NAME => index.shtml
LAST_MODIFIED =>
SERVER_SOFTWARE => Apache/2.2.22 (Ubuntu)
QUERY_STRING =>
REMOTE_PORT => 54917
HTTP_USER_AGENT => Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0
SERVER_PORT => 80
SERVER_SIGNATURE => <address>Apache/2.2.22 (Ubuntu) Server at 127.0.0.1 Port 80</address>
HTTP_CACHE_CONTROL => max-age=0
HTTP_ACCEPT_LANGUAGE => de-DE,de;q=0.8,en-US;q=0.7,en;q=0.5,en-gb;q=0.3,en-EU;q=0.2
REMOTE_ADDR => 127.0.0.1
SERVER_PROTOCOL => INCLUDED
DATE_LOCAL =>
PATH => /usr/local/bin:/usr/bin:/bin
DOCUMENT_URI => /ssitest/index.shtml
REQUEST_URI => /ssitest/index.shtml
GATEWAY_INTERFACE => CGI/1.1
SERVER_ADDR => 127.0.0.1
DOCUMENT_ROOT => /home/jan/www
USER_NAME =>
HTTP_HOST => 127.0.0.1
QuoteSCRIPT_NAME => /ssitest/envs.pl
SERVER_NAME => 127.0.0.1
SERVER_ADMIN => webmaster@localhost
REQUEST_METHOD => GET
HTTP_ACCEPT => */*
DATE_GMT =>
SCRIPT_FILENAME => /home/jan/www/ssitest/envs.pl
DOCUMENT_NAME => index.shtml
LAST_MODIFIED =>
SERVER_SOFTWARE => Apache/2.2.22 (Ubuntu)
QUERY_STRING =>
REMOTE_PORT => 54919
HTTP_USER_AGENT => curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
SERVER_SIGNATURE => <address>Apache/2.2.22 (Ubuntu) Server at 127.0.0.1 Port 80</address>
SERVER_PORT => 80
REMOTE_ADDR => 127.0.0.1
SERVER_PROTOCOL => INCLUDED
DATE_LOCAL =>
PATH => /usr/local/bin:/usr/bin:/bin
DOCUMENT_URI => /ssitest/index.shtml
REQUEST_URI => /ssitest/index.shtml
GATEWAY_INTERFACE => CGI/1.1
SERVER_ADDR => 127.0.0.1
DOCUMENT_ROOT => /home/jan/www
USER_NAME =>
HTTP_HOST => 127.0.0.1
QuoteSCRIPT_NAME => /ssitest/envs.pl
SERVER_NAME => 127.0.0.1
SERVER_ADMIN => webmaster@localhost
REQUEST_METHOD => POST
HTTP_ACCEPT => */*
SCRIPT_FILENAME => /home/jan/www/ssitest/envs.pl
SERVER_SOFTWARE => Apache/2.2.22 (Ubuntu)
QUERY_STRING =>
REMOTE_PORT => 54920
HTTP_USER_AGENT => curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
SERVER_SIGNATURE => <address>Apache/2.2.22 (Ubuntu) Server at 127.0.0.1 Port 80</address>
SERVER_PORT => 80
REMOTE_ADDR => 127.0.0.1
SERVER_PROTOCOL => HTTP/1.1
PATH => /usr/local/bin:/usr/bin:/bin
REQUEST_URI => /ssitest/envs.pl
GATEWAY_INTERFACE => CGI/1.1
SERVER_ADDR => 127.0.0.1
DOCUMENT_ROOT => /home/jan/www
HTTP_HOST => 127.0.0.1
Quotevirtual
The value is a (%-encoded) URL-path. The URL cannot contain a scheme or hostname, only a path and an optional query string. If it does not begin with a slash (/) then it is taken to be relative to the current document.
A URL is constructed from the attribute, and the output the server would return if the URL were accessed by the client is included in the parsed output. Thus included files can be nested.
If the specified URL is a CGI program, the program will be executed and its output inserted in place of the directive in the parsed file. You may include a query string in a CGI url:
<!--#include virtual="/cgi-bin/example.cgi?argument=value" -->
include virtual should be used in preference to exec cgi to include the output of CGI programs into an HTML document.
If the KeptBodySize directive is correctly configured and valid for this included file, attempts to POST requests to the enclosing HTML document will be passed through to subrequests as POST requests as well. Without the directive, all subrequests are processed as GET requests.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="de">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Test SSI</title>
</head>
<body>
<p>Datum: <!--#echo var="DATE_LOCAL" --></p>
<p>Das ist ein Text. ÄÖÜß</p>
<p>Inhalt eines externen Perl (cgi):<br><pre><!--#exec cgi="cgi-bin/env.pl" --></pre></p>
<hr>
<p>Debug (SSI #printenv):<br><pre><!--#printenv--></pre></p>
</body>
</html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/usr/bin/perl use 5.008; use strict; use warnings; my $buffer; print "Content-Type: text/plain\n\n"; #print "$_ => ",$ENV{$_},"\n" for sort keys %ENV; print '=' x 30, "\n"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); print 'Buffer [', length $buffer, "], $buffer", "\n"; print '=' x 30, "\n";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
curl --data "param1=value1¶m2=value2" -X POST http://127.0.0.1/ssitest/index.shtml
SCRIPT_NAME => /ssitest/envs.pl
SERVER_NAME => 127.0.0.1
SERVER_ADMIN => webmaster@localhost
REQUEST_METHOD => GET
CONTENT_LENGTH => 27
HTTP_ACCEPT => */*
DATE_GMT =>
SCRIPT_FILENAME => /home/jan/www/ssitest/envs.pl
DOCUMENT_NAME => index.shtml
LAST_MODIFIED =>
SERVER_SOFTWARE => Apache/2.2.22 (Ubuntu)
QUERY_STRING =>
REMOTE_PORT => 55229
HTTP_USER_AGENT => curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
SERVER_PORT => 80
SERVER_SIGNATURE => <address>Apache/2.2.22 (Ubuntu) Server at 127.0.0.1 Port 80</address>
REMOTE_ADDR => 127.0.0.1
CONTENT_TYPE => application/x-www-form-urlencoded
SERVER_PROTOCOL => INCLUDED
DATE_LOCAL =>
PATH => /usr/local/bin:/usr/bin:/bin
DOCUMENT_URI => /ssitest/index.shtml
REQUEST_URI => /ssitest/index.shtml
GATEWAY_INTERFACE => CGI/1.1
SERVER_ADDR => 127.0.0.1
DOCUMENT_ROOT => /home/jan/www
USER_NAME =>
HTTP_HOST => 127.0.0.1
==============================
Buffer [0],
==============================
1
2
3
4
5
6
7
#!/usr/bin/perl
use strict;
use warnings;
print "Content-Type: text/html\n\n";
print '<!--#exec cgi="envs.pl" -->';
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
jan@jlubuntu:~/www/ssitest$ curl --data "param1=value1¶m2=value2" -X POST http://127.0.0.1/ssitest/test.pl
SCRIPT_NAME => /ssitest/envs.pl
SERVER_NAME => 127.0.0.1
SERVER_ADMIN => webmaster@localhost
REQUEST_METHOD => GET
CONTENT_LENGTH => 27
HTTP_ACCEPT => */*
DATE_GMT =>
SCRIPT_FILENAME => /home/jan/www/ssitest/envs.pl
DOCUMENT_NAME => test.pl
LAST_MODIFIED =>
SERVER_SOFTWARE => Apache/2.2.22 (Ubuntu)
QUERY_STRING =>
REMOTE_PORT => 55235
HTTP_USER_AGENT => curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
SERVER_PORT => 80
SERVER_SIGNATURE => <address>Apache/2.2.22 (Ubuntu) Server at 127.0.0.1 Port 80</address>
REMOTE_ADDR => 127.0.0.1
CONTENT_TYPE => application/x-www-form-urlencoded
SERVER_PROTOCOL => INCLUDED
DATE_LOCAL =>
PATH => /usr/local/bin:/usr/bin:/bin
DOCUMENT_URI => /ssitest/test.pl
REQUEST_URI => /ssitest/test.pl
GATEWAY_INTERFACE => CGI/1.1
SERVER_ADDR => 127.0.0.1
DOCUMENT_ROOT => /home/jan/www
USER_NAME =>
HTTP_HOST => 127.0.0.1
==============================
Buffer [0],
==============================
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
jan@jlubuntu:~/www/ssitest$ curl --data "param1=value1¶m2=value2" -X POST http://127.0.0.1/ssitest/envs.pl
SCRIPT_NAME => /ssitest/envs.pl
SERVER_NAME => 127.0.0.1
SERVER_ADMIN => webmaster@localhost
REQUEST_METHOD => POST
CONTENT_LENGTH => 27
HTTP_ACCEPT => */*
SCRIPT_FILENAME => /home/jan/www/ssitest/envs.pl
SERVER_SOFTWARE => Apache/2.2.22 (Ubuntu)
QUERY_STRING =>
REMOTE_PORT => 55245
HTTP_USER_AGENT => curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
SERVER_PORT => 80
SERVER_SIGNATURE => <address>Apache/2.2.22 (Ubuntu) Server at 127.0.0.1 Port 80</address>
REMOTE_ADDR => 127.0.0.1
CONTENT_TYPE => application/x-www-form-urlencoded
SERVER_PROTOCOL => HTTP/1.1
PATH => /usr/local/bin:/usr/bin:/bin
REQUEST_URI => /ssitest/envs.pl
GATEWAY_INTERFACE => CGI/1.1
SERVER_ADDR => 127.0.0.1
DOCUMENT_ROOT => /home/jan/www
HTTP_HOST => 127.0.0.1
==============================
Buffer [27], param1=value1¶m2=value2
==============================
2012-11-08T09:54:10 janDie bessere Lösung: dein Script nimmt die Seite entgegen und gibt HTML mit SSI aus. Du hast vermutlich ja einen modernen Apache der 2er Serie drin, da läuft SSI auch als Outputfilter, d.h. SSI geht auch im Output von einem Script. Du musst nur z.B.
AddOutputFilterByType INCLUDES text/html
in einer .htaccess definieren.
2012-11-09T07:10:39 Draussenduscher(...)dass bei einem Subrequest nicht die gleichen Informationen ankommen wie bei einem Request(...)