diff --git a/cgi-bin/doc2pdf.sh b/cgi-bin/doc2pdf.sh new file mode 100755 index 0000000..ed55579 --- /dev/null +++ b/cgi-bin/doc2pdf.sh @@ -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 - - + diff --git a/cgi-bin/lo2pdf.sh b/cgi-bin/lo2pdf.sh new file mode 100755 index 0000000..e15c324 --- /dev/null +++ b/cgi-bin/lo2pdf.sh @@ -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} + diff --git a/cgi-bin/printenv b/cgi-bin/printenv new file mode 100755 index 0000000..bceb4e5 --- /dev/null +++ b/cgi-bin/printenv @@ -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"; +} + diff --git a/cgi-bin/test-cgi b/cgi-bin/test-cgi new file mode 100755 index 0000000..0a632e0 --- /dev/null +++ b/cgi-bin/test-cgi @@ -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 diff --git a/conf/kapitel/kapitel_09.conf b/conf/kapitel/kapitel_09.conf new file mode 100644 index 0000000..0534310 --- /dev/null +++ b/conf/kapitel/kapitel_09.conf @@ -0,0 +1,91 @@ +##### Kapitel 9 - Dynamische Inhalte + +### Klassisches CGI + + + LoadModule cgid_module modules/mod_cgid.so + + + LoadModule cgi_module modules/mod_cgi.so + + +AddHandler cgi-script .cgi + + + Options +ExecCGI + + + Options +ExecCGI + + +### 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/ + + SetHandler perl-script + PerlResponseHandler ModPerl::Registry + PerlOptions +ParseHeaders + Options +ExecCGI + Require all granted + + +AddHandler perl-script .pl + + PerlResponseHandler ModPerl::Registry + PerlOptions +ParseHeaders + + + Options +ExecCGI + + + + SetHandler perl-script + PerlResponseHandler ModPerl::Registry + PerlOptions +ParseHeaders + + Options +ExecCGI + + +### 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" + diff --git a/htdocs-firma1.sv/test.php b/htdocs-firma1.sv/test.php new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-firma1.sv/test.php @@ -0,0 +1 @@ + diff --git a/htdocs-firma1.sv/test.php5 b/htdocs-firma1.sv/test.php5 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-firma1.sv/test.php5 @@ -0,0 +1 @@ + diff --git a/htdocs-firma1.sv/test.php7 b/htdocs-firma1.sv/test.php7 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-firma1.sv/test.php7 @@ -0,0 +1 @@ + diff --git a/htdocs-firma1.sv/test.php8 b/htdocs-firma1.sv/test.php8 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-firma1.sv/test.php8 @@ -0,0 +1 @@ + diff --git a/htdocs-firma2.sv/test.php b/htdocs-firma2.sv/test.php new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-firma2.sv/test.php @@ -0,0 +1 @@ + diff --git a/htdocs-firma2.sv/test.php5 b/htdocs-firma2.sv/test.php5 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-firma2.sv/test.php5 @@ -0,0 +1 @@ + diff --git a/htdocs-firma2.sv/test.php7 b/htdocs-firma2.sv/test.php7 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-firma2.sv/test.php7 @@ -0,0 +1 @@ + diff --git a/htdocs-firma2.sv/test.php8 b/htdocs-firma2.sv/test.php8 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-firma2.sv/test.php8 @@ -0,0 +1 @@ + diff --git a/htdocs-ipbased.sv/test.php b/htdocs-ipbased.sv/test.php new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-ipbased.sv/test.php @@ -0,0 +1 @@ + diff --git a/htdocs-ipbased.sv/test.php5 b/htdocs-ipbased.sv/test.php5 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-ipbased.sv/test.php5 @@ -0,0 +1 @@ + diff --git a/htdocs-ipbased.sv/test.php7 b/htdocs-ipbased.sv/test.php7 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-ipbased.sv/test.php7 @@ -0,0 +1 @@ + diff --git a/htdocs-ipbased.sv/test.php8 b/htdocs-ipbased.sv/test.php8 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs-ipbased.sv/test.php8 @@ -0,0 +1 @@ + diff --git a/htdocs/meine-cgis/printenv.cgi b/htdocs/meine-cgis/printenv.cgi new file mode 100755 index 0000000..bceb4e5 --- /dev/null +++ b/htdocs/meine-cgis/printenv.cgi @@ -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"; +} + diff --git a/htdocs/test.php b/htdocs/test.php new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs/test.php @@ -0,0 +1 @@ + diff --git a/htdocs/test.php5 b/htdocs/test.php5 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs/test.php5 @@ -0,0 +1 @@ + diff --git a/htdocs/test.php7 b/htdocs/test.php7 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs/test.php7 @@ -0,0 +1 @@ + diff --git a/htdocs/test.php8 b/htdocs/test.php8 new file mode 100644 index 0000000..147cebc --- /dev/null +++ b/htdocs/test.php8 @@ -0,0 +1 @@ + diff --git a/perl/printenv b/perl/printenv new file mode 100755 index 0000000..bceb4e5 --- /dev/null +++ b/perl/printenv @@ -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"; +} +