Kapitel 09: CGI, dynamische Inhalte
This commit is contained in:
parent
5deafab3ac
commit
f2d31d7e80
10
cgi-bin/doc2pdf.sh
Executable file
10
cgi-bin/doc2pdf.sh
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PATH=/usr/sbin:/bin:/usr/bin:/sbin:/usr/X11R6/bin
|
||||||
|
HOME=/tmp
|
||||||
|
|
||||||
|
echo >> /tmp/doc2pdf.log $PATH_TRANSLATED
|
||||||
|
|
||||||
|
echo -e "Content-Type: application/pdf\n"
|
||||||
|
/usr/bin/antiword -p a4 $PATH_TRANSLATED | ps2pdf - -
|
||||||
|
|
20
cgi-bin/lo2pdf.sh
Executable file
20
cgi-bin/lo2pdf.sh
Executable file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PATH=/usr/sbin:/bin:/usr/bin:/sbin:/usr/X11R6/bin
|
||||||
|
HOME=/tmp
|
||||||
|
|
||||||
|
echo -e "Content-Type: application/pdf\n"
|
||||||
|
|
||||||
|
mkdir -p ${HOME}/lo_pdfs
|
||||||
|
/usr/bin/soffice \
|
||||||
|
--headless \
|
||||||
|
"-env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}" \
|
||||||
|
--convert-to pdf:writer_pdf_Export \
|
||||||
|
--outdir ${HOME}/lo_pdfs \
|
||||||
|
${PATH_TRANSLATED}
|
||||||
|
|
||||||
|
PDF=$(basename ${PATH_TRANSLATED})
|
||||||
|
PDF=${PDF%.*}.pdf
|
||||||
|
cat ${HOME}/lo_pdfs/${PDF}
|
||||||
|
rm ${HOME}/lo_pdfs/${PDF}
|
||||||
|
|
27
cgi-bin/printenv
Executable file
27
cgi-bin/printenv
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
# To permit this cgi, replace # on the first line above with the
|
||||||
|
# appropriate #!/path/to/perl shebang, and on Unix / Linux also
|
||||||
|
# set this script executable with chmod 755.
|
||||||
|
#
|
||||||
|
# ***** !!! WARNING !!! *****
|
||||||
|
# This script echoes the server environment variables and therefore
|
||||||
|
# leaks information - so NEVER use it in a live server environment!
|
||||||
|
# It is provided only for testing purpose.
|
||||||
|
# Also note that it is subject to cross site scripting attacks on
|
||||||
|
# MS IE and any other browser which fails to honor RFC2616.
|
||||||
|
|
||||||
|
##
|
||||||
|
## printenv -- demo CGI program which just prints its environment
|
||||||
|
##
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
print "Content-type: text/plain; charset=iso-8859-1\n\n";
|
||||||
|
foreach my $var (sort(keys(%ENV))) {
|
||||||
|
my $val = $ENV{$var};
|
||||||
|
$val =~ s|\n|\\n|g;
|
||||||
|
$val =~ s|"|\\"|g;
|
||||||
|
print "${var}=\"${val}\"\n";
|
||||||
|
}
|
||||||
|
|
42
cgi-bin/test-cgi
Executable file
42
cgi-bin/test-cgi
Executable file
|
@ -0,0 +1,42 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# To permit this cgi, replace # on the first line above with the
|
||||||
|
# appropriate #!/path/to/sh shebang, and set this script executable
|
||||||
|
# with chmod 755.
|
||||||
|
#
|
||||||
|
# ***** !!! WARNING !!! *****
|
||||||
|
# This script echoes the server environment variables and therefore
|
||||||
|
# leaks information - so NEVER use it in a live server environment!
|
||||||
|
# It is provided only for testing purpose.
|
||||||
|
# Also note that it is subject to cross site scripting attacks on
|
||||||
|
# MS IE and any other browser which fails to honor RFC2616.
|
||||||
|
|
||||||
|
# disable filename globbing
|
||||||
|
set -f
|
||||||
|
|
||||||
|
echo "Content-type: text/plain; charset=iso-8859-1"
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo CGI/1.0 test script report:
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo argc is $#. argv is "$*".
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo SERVER_SOFTWARE = $SERVER_SOFTWARE
|
||||||
|
echo SERVER_NAME = $SERVER_NAME
|
||||||
|
echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE
|
||||||
|
echo SERVER_PROTOCOL = $SERVER_PROTOCOL
|
||||||
|
echo SERVER_PORT = $SERVER_PORT
|
||||||
|
echo REQUEST_METHOD = $REQUEST_METHOD
|
||||||
|
echo HTTP_ACCEPT = "$HTTP_ACCEPT"
|
||||||
|
echo PATH_INFO = "$PATH_INFO"
|
||||||
|
echo PATH_TRANSLATED = "$PATH_TRANSLATED"
|
||||||
|
echo SCRIPT_NAME = "$SCRIPT_NAME"
|
||||||
|
echo QUERY_STRING = "$QUERY_STRING"
|
||||||
|
echo REMOTE_HOST = $REMOTE_HOST
|
||||||
|
echo REMOTE_ADDR = $REMOTE_ADDR
|
||||||
|
echo REMOTE_USER = $REMOTE_USER
|
||||||
|
echo AUTH_TYPE = $AUTH_TYPE
|
||||||
|
echo CONTENT_TYPE = $CONTENT_TYPE
|
||||||
|
echo CONTENT_LENGTH = $CONTENT_LENGTH
|
91
conf/kapitel/kapitel_09.conf
Normal file
91
conf/kapitel/kapitel_09.conf
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
##### Kapitel 9 - Dynamische Inhalte
|
||||||
|
|
||||||
|
### Klassisches CGI
|
||||||
|
|
||||||
|
<IfModule !mpm_prefork_module>
|
||||||
|
LoadModule cgid_module modules/mod_cgid.so
|
||||||
|
</IfModule>
|
||||||
|
<IfModule mpm_prefork_module>
|
||||||
|
LoadModule cgi_module modules/mod_cgi.so
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
AddHandler cgi-script .cgi
|
||||||
|
|
||||||
|
<Directory /usr/local/apache2/htdocs/meine-cgis>
|
||||||
|
Options +ExecCGI
|
||||||
|
</Directory>
|
||||||
|
<Directory /usr/local/apache2/htdocs-*>
|
||||||
|
Options +ExecCGI
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
### PHP8 als Modul
|
||||||
|
|
||||||
|
LoadModule php_module modules/libphp.so
|
||||||
|
AddType application/x-httpd-php .php
|
||||||
|
|
||||||
|
### mod_perl
|
||||||
|
|
||||||
|
LoadModule perl_module modules/mod_perl.so
|
||||||
|
|
||||||
|
Alias /perl/ /usr/local/apache2/perl/
|
||||||
|
<Location /perl/>
|
||||||
|
SetHandler perl-script
|
||||||
|
PerlResponseHandler ModPerl::Registry
|
||||||
|
PerlOptions +ParseHeaders
|
||||||
|
Options +ExecCGI
|
||||||
|
Require all granted
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
AddHandler perl-script .pl
|
||||||
|
<Location /meine-cgis/>
|
||||||
|
PerlResponseHandler ModPerl::Registry
|
||||||
|
PerlOptions +ParseHeaders
|
||||||
|
</Location>
|
||||||
|
<Directory /usr/local/apache2/htdocs/>
|
||||||
|
Options +ExecCGI
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<LocationMatch "^/printenv(\.html)?$">
|
||||||
|
SetHandler perl-script
|
||||||
|
PerlResponseHandler ModPerl::Registry
|
||||||
|
PerlOptions +ParseHeaders
|
||||||
|
|
||||||
|
Options +ExecCGI
|
||||||
|
</LocationMatch>
|
||||||
|
|
||||||
|
### Alte PHP als CGI-Interpreter
|
||||||
|
|
||||||
|
LoadModule actions_module modules/mod_actions.so
|
||||||
|
|
||||||
|
AddHandler php5-script .php5
|
||||||
|
Action php5-script /cgi-bin/php-5.6.40
|
||||||
|
|
||||||
|
AddHandler php7-script .php7
|
||||||
|
Action php7-script /cgi-bin/php-7.4.33
|
||||||
|
|
||||||
|
AddHandler php8-script .php8
|
||||||
|
Action php8-script /cgi-bin/php-8.1.42
|
||||||
|
|
||||||
|
### doc2pdf.sh
|
||||||
|
|
||||||
|
Action application/msword /cgi-bin/doc2pdf2.sh
|
||||||
|
|
||||||
|
### docx2pdf.sh
|
||||||
|
|
||||||
|
#Action application/msword /cgi-bin/lo2pdf.sh
|
||||||
|
Action application/vnd.ms-excel /cgi-bin/lo2pdf.sh
|
||||||
|
|
||||||
|
Action application/vnd.openxmlformats-officedocument.wordprocessingml.document /cgi-bin/lo2pdf.sh
|
||||||
|
Action application/vnd.openxmlformats-officedocument.spreadsheetml.sheet /cgi-bin/lo2pdf.sh
|
||||||
|
|
||||||
|
Action application/vnd.oasis.opendocument.text /cgi-bin/lo2pdf.sh
|
||||||
|
Action application/vnd.oasis.opendocument.spreadsheet /cgi-bin/lo2pdf.sh
|
||||||
|
|
||||||
|
### PHP-FPM
|
||||||
|
|
||||||
|
# In /etc/php/*/fpm/pool.d/www.conf: "security.limit_extensions = .php .phpfpm"
|
||||||
|
#LoadModule proxy_module modules/mod_proxy.so
|
||||||
|
#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
|
||||||
|
# # ProxyPassMatch ^/(.*\.phpfpm)$ fcgi://127.0.0.1:4001/usr/local/apache2/htdocs/$1
|
||||||
|
#ProxyPassMatch ^/(.*\.phpfpm)$ "unix:/run/php/php8.1-fpm.sock|fcgi://localhost/usr/local/apache2/htdocs/$1"
|
||||||
|
|
1
htdocs-firma1.sv/test.php
Normal file
1
htdocs-firma1.sv/test.php
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs-firma1.sv/test.php5
Normal file
1
htdocs-firma1.sv/test.php5
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs-firma1.sv/test.php7
Normal file
1
htdocs-firma1.sv/test.php7
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs-firma1.sv/test.php8
Normal file
1
htdocs-firma1.sv/test.php8
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs-firma2.sv/test.php
Normal file
1
htdocs-firma2.sv/test.php
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs-firma2.sv/test.php5
Normal file
1
htdocs-firma2.sv/test.php5
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs-firma2.sv/test.php7
Normal file
1
htdocs-firma2.sv/test.php7
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs-firma2.sv/test.php8
Normal file
1
htdocs-firma2.sv/test.php8
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs-ipbased.sv/test.php
Normal file
1
htdocs-ipbased.sv/test.php
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs-ipbased.sv/test.php5
Normal file
1
htdocs-ipbased.sv/test.php5
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs-ipbased.sv/test.php7
Normal file
1
htdocs-ipbased.sv/test.php7
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs-ipbased.sv/test.php8
Normal file
1
htdocs-ipbased.sv/test.php8
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
27
htdocs/meine-cgis/printenv.cgi
Executable file
27
htdocs/meine-cgis/printenv.cgi
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
# To permit this cgi, replace # on the first line above with the
|
||||||
|
# appropriate #!/path/to/perl shebang, and on Unix / Linux also
|
||||||
|
# set this script executable with chmod 755.
|
||||||
|
#
|
||||||
|
# ***** !!! WARNING !!! *****
|
||||||
|
# This script echoes the server environment variables and therefore
|
||||||
|
# leaks information - so NEVER use it in a live server environment!
|
||||||
|
# It is provided only for testing purpose.
|
||||||
|
# Also note that it is subject to cross site scripting attacks on
|
||||||
|
# MS IE and any other browser which fails to honor RFC2616.
|
||||||
|
|
||||||
|
##
|
||||||
|
## printenv -- demo CGI program which just prints its environment
|
||||||
|
##
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
print "Content-type: text/plain; charset=iso-8859-1\n\n";
|
||||||
|
foreach my $var (sort(keys(%ENV))) {
|
||||||
|
my $val = $ENV{$var};
|
||||||
|
$val =~ s|\n|\\n|g;
|
||||||
|
$val =~ s|"|\\"|g;
|
||||||
|
print "${var}=\"${val}\"\n";
|
||||||
|
}
|
||||||
|
|
1
htdocs/test.php
Normal file
1
htdocs/test.php
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs/test.php5
Normal file
1
htdocs/test.php5
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs/test.php7
Normal file
1
htdocs/test.php7
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
1
htdocs/test.php8
Normal file
1
htdocs/test.php8
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php phpinfo(); ?>
|
27
perl/printenv
Executable file
27
perl/printenv
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
# To permit this cgi, replace # on the first line above with the
|
||||||
|
# appropriate #!/path/to/perl shebang, and on Unix / Linux also
|
||||||
|
# set this script executable with chmod 755.
|
||||||
|
#
|
||||||
|
# ***** !!! WARNING !!! *****
|
||||||
|
# This script echoes the server environment variables and therefore
|
||||||
|
# leaks information - so NEVER use it in a live server environment!
|
||||||
|
# It is provided only for testing purpose.
|
||||||
|
# Also note that it is subject to cross site scripting attacks on
|
||||||
|
# MS IE and any other browser which fails to honor RFC2616.
|
||||||
|
|
||||||
|
##
|
||||||
|
## printenv -- demo CGI program which just prints its environment
|
||||||
|
##
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
print "Content-type: text/plain; charset=iso-8859-1\n\n";
|
||||||
|
foreach my $var (sort(keys(%ENV))) {
|
||||||
|
my $val = $ENV{$var};
|
||||||
|
$val =~ s|\n|\\n|g;
|
||||||
|
$val =~ s|"|\\"|g;
|
||||||
|
print "${var}=\"${val}\"\n";
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue