Apache2-SSI
view release on metacpan or search on metacpan
Apache mod_perl. This must be the uri of the document being served,
such as "/my/path/index.html". So, if you are using this outside of
the rim of Apache mod_perl and your file resides, for example, at
"/home/john/www/my/path/index.html" and your document root is
"/home/john/www", then the document uri would be
"/my/path/index.html"
*errmsg*
The error message to be returned when a ssi directive fails. By
default, it is "[an error occurred while processing this directive]"
*html*
The html data to be parsed. You do not have to provide that value
now. You can provide it to "parse" as its first argument when you
call it.
*legacy*
Takes a boolean value suchas 1 or 0 to indicate whether the Apache2
expression supported accepts legacy style.
Legacy Apache expression typically allows for perl style variable
"${REQUEST_URI}" versus the modern style of "%{REQUEST_URI}" and
just an equal sign to imply a regular expression such as:
$HTTP_COOKIES = /lang\%22\%3A\%22([a-zA-Z]+\-[a-zA-Z]+)\%22\%7D;?/
Modern expression equivalent would be:
%{HTTP_COOKIES} =~ /lang\%22\%3A\%22([a-zA-Z]+\-[a-zA-Z]+)\%22\%7D;?/
See Regexp::Common::Apache2 for more information.
See also the property *trunk* to enable experimental expressions.
*remote_ip*
This is used when you want to artificially set the remote ip
address, i.e. the address of the visitor accessing the page. This is
used essentially by the SSI directive:
my $ssi = Apache2::SSI->new( remote_ip => '192.168.2.10' ) ||
die( Apache2::SSI->error );
<!--#if expr="-R '192.168.2.0/24' || -R '127.0.0.1/24'" -->
Remote ip is part of my private network
<!--#else -->
Go away!
<!--#endif -->
*sizefmt*
The default way to format a file size. By default, this is "abbrev",
which means a human readable format such as "2.5M" for 2.5
megabytes. Other possible value is "bytes" which would have the
"fsize" ssi directive return the size in bytes.
See Apache2 documentation
<https://httpd.apache.org/docs/current/en/howto/ssi.html> for more
information on this.
*timefmt*
The default way to format a date time. By default, this uses the
display according to your locale, such as "ja_JP" (for Japan) or
"en_GB" for the United Kingdoms. The time zone can be specified in
the format, or it will be set to the local time zone, whatever it
is.
See Apache2 documentation
<https://httpd.apache.org/docs/current/en/howto/ssi.html> for more
information on this.
*trunk*
This takes a boolean value such as 0 or 1 and when enabled this
allows the support for Apache2 experimental expressions.
See Regexp::Common::Apache2 for more information.
Also, see the property *legacy* to enable legacy Apache2
expressions.
handler
This is a key method expected by mod_perl. Depending on how this module
is used, it will redirect either to "apache_filter_handler" or to
"apache_response_handler"
ap2perl_expr
This method is used to convert Apache2 expressions into perl equivalents
to be then eval'ed.
It takes an hash reference provided by "parse" in Apache2::Expression,
an array reference to store the output recursively and an optional hash
reference of parameters.
It parse recursively the structure provided in the hash reference to
provide the perl equivalent for each Apache2 expression component.
It returns the array reference provided used as the content buffer. This
array is used by "parse_expr" and then joined using a single space to
form a string of perl expression to be eval'ed.
apache_filter
Set or get the Apache2::Filter object.
When running under Apache mod_perl this is set automatically from the
special "handler" method.
apache_filter_handler
This method is called from "handler" to handle the Apache response when
this module Apache2::SSI is used as a filter handler.
See also "apache_response_handler"
apache_request
Sets or gets the Apache2::RequestRec object. As explained in the "new"
method, you can get this Apache object by requiring the package
Apache2::RequestUtil and calling "request" in Apache2::RequestUtil 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" method, such as:
my $r = $f->r; # $f is the Apache2::Filter object provided by Apache
Under Apache mod_perl, this uses "lookup_uri" in Apache2::SubRequest to
achieve that. Outside of Apache it will attempt to lookup the uri
relative to the document root if it is an absolute uri or to the current
document uri.
It returns a Apache2::SSI::URI object.
mod_perl
Returns true when running under mod_perl, false otherwise.
parse
Provided with html data and if none is provided will use the data
specified with the method "html", this method will parse the html and
process the ssi directives.
It returns the html string with the ssi result.
parse_config
Provided with an hash reference of parameters and this sets three of the
object parameters that can also be set during object instantiation:
*echomsg*
The value is a message that is sent back to the client if the echo
element attempts to echo an undefined variable.
This overrides any default value set for the parameter *echomsg*
upon object instantiation.
*errmsg*
This is the default error message to be used as the result for a
faulty ssi directive.
See the "echomsg" method.
*sizefmt*
This is the format to be used to format the files size. Value can be
either "bytes" or "abbrev"
See also the "sizefmt" method.
*timefmt*
This is the format to be used to format the dates and times. The
value is a date formatting based on "strftime" in POSIX
See also the "timefmt" method.
parse_echo
Provided with an hash reference of parameter and this process the "echo"
ssi directive and returns its output as a string.
For example:
Query string passed: <!--#echo var="QUERY_STRING" -->
There are a number of standard environment variable accessible under SSI
on top of other environment variables set. See "SSI Directives" section
below.
parse_echo_date_gmt
Returns the current date with time zone set to gmt and based on the
provided format or the format available for the current locale such as
"ja_JP" or "en_GB".
parse_echo_date_local
Returns the current date with time zone set to the local time zone
whatever that may be and on the provided format or the format available
for the current locale such as "ja_JP" or "en_GB".
Example:
<!--#echo var="DATE_LOCAL" -->
parse_echo_document_name
Returns the document name. Under Apache, this returns the environment
variable "DOCUMENT_NAME", if set, or the base name of the value returned
by "filename" in Apache2::RequestRec
Outside of Apache, this returns the environment variable
"DOCUMENT_NAME", if set, or the base name of the value for
"document_uri"
Example:
<!--#echo var="DOCUMENT_NAME" -->
If the uri were "/some/where/file.html", this would return only
"file.html"
parse_echo_document_uri
Returns the value of "document_uri"
Example:
<!--#echo var="DOCUMENT_URI" -->
The document uri would include, if any, any path info and query string.
parse_echo_last_modified
This returns document last modified date. Under Apache, there is a
standard environment variable called "LAST_MODIFIED" (see the section on
"SSI Directives"), and if somehow absent, it will return instead the
formatted last modification datetime for the file returned with
"filename" in Apache2::RequestRec. The formatting of that date follows
whatever format provided with "timefmt" or by default the datetime
format for the current locale (e.g. "ja_JP").
Outside of Apache, the similar result is achieved by returning the value
of the environment variable "LAST_MODIFIED" if available, or the
formatted datetime of the document uri as set with "document_uri"
Example:
<!--#echo var="LAST_MODIFIED" -->
parse_eval_expr
Provided with a string representing an Apache2 expression and this will
parse it, transform it into a perl equivalent and return its value.
It does the parsing using "parse" in Apache2::Expression called from
"parse_expr"
If the expression contains regular expression with capture groups, the
value of capture groups will be stored and will be usable in later
expressions, such as:
<!--#config errmsg="[Include error]" -->
<!--#if expr="%{HTTP_COOKIE} =~ /lang\%22\%3A\%22([a-zA-Z]+\-[a-zA-Z]+)\%22\%7D;?/"-->
<!--#set var="CONTENT_LANGUAGE" value="%{tolower:$1}"-->
<!--#elif expr="-z %{CONTENT_LANGUAGE}"-->
<!--#set var="CONTENT_LANGUAGE" value="en"-->
<!--#endif-->
<!DOCTYPE html>
<html lang="<!--#echo encoding="none" var="CONTENT_LANGUAGE" -->">
parse_exec
Provided with an hash reference of parameters and this process the
"exec" ssi directives.
Example:
<!--#exec cgi="/uri/path/to/progr.cgi" -->
or
<!--#exec cmd="/some/system/file/path.sh" -->
parse_expr
It takes a string representing an Apache2 expression and calls "parse"
in Apache2::Expression to break it down, and then calls "ap2perl_expr"
to transform it into a perl expression that is then eval'ed by
"parse_eval_expr".
It returns the perl representation of the Apache2 expression.
To make this work, certain Apache2 standard functions used such as
"base64" or "md5" are converted to use this package function
equivalents. See the "parse_func_*" methods for more information.
parse_elif
Parse the "elif" condition.
Example:
<!--#if expr=1 -->
Hi, should print
( run in 0.787 second using v1.01-cache-2.11-cpan-ceb78f64989 )