Apache2-SSI
view release on metacpan or search on metacpan
[Apache2::Filter](https://metacpan.org/pod/Apache2::Filter){.perl-module}
object.
When running under Apache mod\_perl this is set automatically from the
special [\"handler\"](#handler){.perl-module} method.
apache\_filter\_handler
-----------------------
This method is called from [\"handler\"](#handler){.perl-module} to
handle the Apache response when this module
[Apache2::SSI](https://metacpan.org/pod/Apache2::SSI){.perl-module} is
used as a filter handler.
See also
[\"apache\_response\_handler\"](#apache_response_handler){.perl-module}
apache\_request
---------------
Sets or gets the
[Apache2::RequestRec](https://metacpan.org/pod/Apache2::RequestRec){.perl-module}
object. As explained in the [\"new\"](#new){.perl-module} method, you
can get this Apache object by requiring the package
[Apache2::RequestUtil](https://metacpan.org/pod/Apache2::RequestUtil){.perl-module}
and calling [\"request\" in
Apache2::RequestUtil](https://metacpan.org/pod/Apache2::RequestUtil#request){.perl-module}
such as `Apache2::RequestUtil-`request\> assuming you have set
`PerlOptions +GlobalRequest` in your Apache Virtual Host configuration.
When running under Apache mod\_perl this is set automatically from the
special [\"handler\"](#handler){.perl-module} method, such as:
my $r = $f->r; # $f is the Apache2::Filter object provided by Apache
apache\_response\_handler
-------------------------
This method is called from [\"handler\"](#handler){.perl-module} to
handle the Apache response when this module
[Apache2::SSI](https://metacpan.org/pod/Apache2::SSI){.perl-module} is
used as a response handler.
See also
[\"apache\_filter\_handler\"](#apache_filter_handler){.perl-module}
clone
-----
Create a clone of the object and return it.
decode\_base64
--------------
Decode base64 data provided. When running under Apache mod\_perl, this
uses [\"decode\" in
APR::Base64](https://metacpan.org/pod/APR::Base64#decode){.perl-module}
module, otherwise it uses [\"decode\" in
MIME::Base64](https://metacpan.org/pod/MIME::Base64#decode){.perl-module}
If the decoded data contain utf8 data, this will decoded the utf8 data
using [\"decode\" in
Encode](https://metacpan.org/pod/Encode#decode){.perl-module}
If an error occurred during decoding, it will return undef and set an
[\"error\"](#error){.perl-module} object accordingly.
decode\_entities
----------------
Decode html data containing entities. This uses [\"decode\_entities\" in
HTML::Entities](https://metacpan.org/pod/HTML::Entities#decode_entities){.perl-module}
If an error occurred during decoding, it will return undef and set an
[\"error\"](#error){.perl-module} object accordingly.
Example:
$ssi->decode_entities( 'Tous les êtres humains naissent libres et égaux en dignité et en droits.' );
# Tous les êtres humains naissent libres et égaux en dignité et en droits.
decode\_uri
-----------
Decode uri encoded data. This uses [\"uri\_unescape\" in
URI::Escape](https://metacpan.org/pod/URI::Escape#uri_unescape){.perl-module}.
Not to be confused with x-www-form-urlencoded data. For that see
[\"decode\_url\"](#decode_url){.perl-module}
If an error occurred during decoding, it will return undef and set an
[\"error\"](#error){.perl-module} object accordingly.
Example:
$ssi->decode_uri( 'https%3A%2F%2Fwww.example.com%2F' );
# https://www.example.com/
decode\_url
-----------
Decode x-www-form-urlencoded encoded data. When using Apache mod\_perl,
this uses [\"decode\" in
APR::Request](https://metacpan.org/pod/APR::Request#decode){.perl-module}
and [\"decode\" in
Encode](https://metacpan.org/pod/Encode#decode){.perl-module}, otherwise
it uses [\"url\_decode\_utf8\" in
URL::Encode](https://metacpan.org/pod/URL::Encode#url_decode_utf8){.perl-module}
(its XS version) to achieve the same result.
If an error occurred during decoding, it will return undef and set an
[\"error\"](#error){.perl-module} object accordingly.
Example:
$ssi->decode_url( 'Tous+les+%C3%83%C2%AAtres+humains+naissent+libres+et+%C3%83%C2%A9gaux+en+dignit%C3%83%C2%A9+et+en+droits.' );
# Tous les êtres humains naissent libres et égaux en dignité et en droits.
document\_filename
------------------
<!--#if expr="-R '192.168.1.0/24' -->
Visitor is part of my private network
<!--#endif -->
or
<!--#if expr="v('REMOTE_ADDR') -R '192.168.1.0/24' -->
<!--#include file="/home/john/special_hidden_login_feature.html" -->
<!--#endif -->
[Apache2::Connection](https://metacpan.org/pod/Apache2::Connection){.perl-module}
also has a [\"remote\_addr\" in
Apache2::Connection](https://metacpan.org/pod/Apache2::Connection#remote_addr){.perl-module}
method, but this returns a
[APR::SockAddr](https://metacpan.org/pod/APR::SockAddr){.perl-module}
object that is used to get the binary version of the ip. However you can
also get the string version like this:
use APR::SockAddr ();
my $ip = $r->connection->remote_addr->ip_get();
Versions above 2.2 make a distinction between ip from direct connection,
or the real ip behind a proxy, i.e. [\"useragent\_ip\" in
Apache2::Connection](https://metacpan.org/pod/Apache2::Connection#useragent_ip){.perl-module}
request\_uri
------------
This is an alias for [\"document\_uri\"](#document_uri){.perl-module}
server\_version
---------------
Returns the server version as a
[version](https://metacpan.org/pod/version){.perl-module} object can
caches that value.
Under mod\_perl2, it uses [\"get\_server\_description\" in
Apache2::ServerUtil](https://metacpan.org/pod/Apache2::ServerUtil#get_server_description){.perl-module}
and outside of mod\_perl, it tries to find `apxs` using
[File::Which](https://metacpan.org/pod/File::Which){.perl-module} and in
last resort, tries to find the `apache2` or `httpd` binary to get its
version information.
sizefmt
-------
Sets or gets the formatting for file sizes. Value can be either `bytes`
or `abbrev`
timefmt
-------
Sets or gets the formatting for date and time values. The format takes
the same values as [\"strftime\" in
POSIX](https://metacpan.org/pod/POSIX#strftime){.perl-module}
Encoding
========
At present time, the html data are treated as utf8 data and decoded and
encoded back as such.
If there is a need to broaden support for other charsets, let me know.
SSI Directives
==============
This is taken from Apache documentation and summarised here for
convenience and clarity to the perl community.
config
------
<!--#config errmsg="Error occurred" sizefmt="abbrev" timefmt="%B %Y" -->
<!--#config errmsg="Oopsie" -->
<!--#config sizefmt="bytes" -->
# Thursday 24 December 2020
<!--#config timefmt="%A $d %B %Y" -->
echo
----
<!--#set var="HTMl_TITLE" value="Un sujet intéressant" -->
<!--#echo var="HTMl_TITLE" encoding="entity" -->
Encoding can be either `entity`, `url` or `none`
exec
----
# pwd is "print working directory" in shell
<!--#exec cmd="pwd" -->
<!--#exec cgi="/uri/path/to/prog.cgi" -->
include
-------
# Filesystem file path
<!--#include file="/home/john/var/quote_of_the_day.txt" -->
# Relative to the document root
<!--#include virtual="/footer.html" -->
flastmod
--------
<!--#flastmod file="/home/john/var/quote_of_the_day.txt" -->
<!--#flastmod virtual="/copyright.html" -->
fsize
-----
<!--#fsize file="/download/software-v1.2.tgz" -->
<!--#fsize virtual="/images/logo.jpg" -->
printenv
--------
<!--#printenv -->
set
( run in 0.806 second using v1.01-cache-2.11-cpan-39bf76dae61 )