Apache2-SSI
view release on metacpan or search on metacpan
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.
instantiation.
# Pretend the ssi directives are accessed from this ip
$ssi->remote_ip( '192.168.2.20' );
This is useful when one wants to check how the rendering will be when
accessed from certain ip addresses.
This is used primarily when there is an expression such as
<!--#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 also has a "remote_addr" in Apache2::Connection
method, but this returns a APR::SockAddr 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();
<!--#if expr="$QUERY_STRING = /^something/" -->
<!--#if expr="$QUERY_STRING == /^something/" -->
# works also with eq, ne, lt, le, gt and ge
<!--#if expr="9 gt 3" -->
<!--#if expr="9 -gt 3" -->
# Other operators work too, namely == != < <= > >= =~ !~
<!--#if expr="9 > 3" -->
<!--#if expr="9 !> 3" -->
<!--#if expr="9 !gt 3" -->
# Checks the remote ip is part of this subnet
<!--#if expr="-R 192.168.2.0/24" -->
<!--#if expr="192.168.2.10 -R 192.168.2.0/24" -->
<!--#if expr="192.168.2.10 -ipmatch 192.168.2.0/24" -->
# Checks if variable is non-empty
<!--#if expr="-n $some_variable" -->
# Checks if variable is empty
<!--#if expr="-z $some_variable" -->
# Checks if the visitor can access the uri /restricted/uri
<!--#if expr="-A /restricted/uri" -->
For subnet checks, this uses Net::Subnet
Expressions that would not work outside of Apache, i.e. it will return
*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
instantiation.
# Pretend the ssi directives are accessed from this ip
$ssi->remote_ip( '192.168.2.20' );
This is useful when one wants to check how the rendering will be when
accessed from certain ip addresses.
This is used primarily when there is an expression such as
<!--#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:
<!--#if expr="$QUERY_STRING = /^something/" -->
<!--#if expr="$QUERY_STRING == /^something/" -->
# works also with eq, ne, lt, le, gt and ge
<!--#if expr="9 gt 3" -->
<!--#if expr="9 -gt 3" -->
# Other operators work too, namely == != < <= > >= =~ !~
<!--#if expr="9 > 3" -->
<!--#if expr="9 !> 3" -->
<!--#if expr="9 !gt 3" -->
# Checks the remote ip is part of this subnet
<!--#if expr="-R 192.168.2.0/24" -->
<!--#if expr="192.168.2.10 -R 192.168.2.0/24" -->
<!--#if expr="192.168.2.10 -ipmatch 192.168.2.0/24" -->
# Checks if variable is non-empty
<!--#if expr="-n $some_variable" -->
# Checks if variable is empty
<!--#if expr="-z $some_variable" -->
# Checks if the visitor can access the uri /restricted/uri
<!--#if expr="-A /restricted/uri" -->
For subnet checks, this uses
[Net::Subnet](https://metacpan.org/pod/Net::Subnet){.perl-module}
SHA256 7ebb7567348603885426d6180a88d8cfeb581476debfcf7d673867990422825f t/32.virtual.t
SHA256 48b2761a05cba07d3717b107abcbddd2a8cb52a22655ef98aefdb7d0da248de7 t/33.if.t
SHA256 4dd1af9c338539008cef7b5e63ba1fa00077692cc43b0e3c4c1c82f383c88792 t/34.set_var.t
SHA256 8ff1ff97a5fa89c178c0aee3542df8fb49f38085cfeeb4e78327f15099e08e75 t/35.exec.t
SHA256 188511c70f570cb1f6716016c0a5ead410e111e5532802462b537a0893f6eba4 t/36.escape.t
SHA256 7e42143e9f5194ce7c6cd067d1280540e7f1272f54683dca42f11c98c108ddff t/37.flastmod.t
SHA256 93759a6d231186e70482fd0fa97051e6f653928a111965af10989ea62fff3435 t/38.fsize.t
SHA256 01e49da5fa09fe5b5aa3e67db370a702d67fd232fc29c0746580a5f00f08506c t/39.functions.t
SHA256 692e27c76a103082685765bdbb7e9b2f77a3f7843948de332f8dfd29f4b46102 t/40.misc.t
SHA256 2934636ad93f93304171731cd54e3fb8115d46ab83c3715a988bf0ff9052d30d t/41.ap2perl.t
SHA256 08d207f8042493f22310d28d351b07683a3e03876c5929fab867447091d84f27 t/42.expression.t
SHA256 8574f5f68b9824b5b6241bf713d50b2a4b1a8c0980c9bbb5e0c6221963e8c52c t/50.finfo.t
SHA256 3235a17ec6fb6c22e363cb3f66ed5562e391e3704b4f916db6b00c16eb82eb82 t/60.uri.t
SHA256 b34fe4df7f0e4a8816e2e3f6abfc590bc421085b8e4182665c1e6db403db2851 t/70.file.t
SHA256 2b824d7b6a057223d8b2059a89356b47b5e5431e1eb613f863f86dbd8cc79045 t/71.file_type.t
SHA256 ffd07b113292fc6a13305412c7b86d73c202d0d5e48e08b1d7475f09ba162388 t/80.notes.t
SHA256 1ac335fc6d3884982a19bff677b26a6d9584def595506cf9b3f7e9c8bd8885a0 t/80.sharedmem.pl
SHA256 971ccdd5a786a5eed5b4f4f6906222c22937441ae530c69dd5029d35a4f77219 t/90.coverage.t
SHA256 002e7da6ca742bd5dd4458c871b11a6b8c9d5f4d1be7435f568ac8aa5729d673 t/90.manifest.t
SHA256 e8ba8508d53f2ecfaf00c825a5e0cdbec32e9b95392a4486d877c6e35d970f3d t/91.signature.t
SHA256 ca6fd25bdec9442b264cbf228045681d1921490c0bb04dd099c3613c400b570a t/99.kwalitee.t
lib/Apache2/SSI.pm view on Meta::CPAN
See also the property C<trunk> to enable experimental expressions.
=item C<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 -->
=item C<sizefmt>
The default way to format a file size. By default, this is C<abbrev>, which means a human readable format such as C<2.5M> for 2.5 megabytes. Other possible value is C<bytes> which would have the C<fsize> ssi directive return the size in bytes.
See L<Apache2 documentation|https://httpd.apache.org/docs/current/en/howto/ssi.html> for more information on this.
lib/Apache2/SSI.pm view on Meta::CPAN
This value can also be overriden by being provided during object instantiation.
# Pretend the ssi directives are accessed from this ip
$ssi->remote_ip( '192.168.2.20' );
This is useful when one wants to check how the rendering will be when accessed from certain ip addresses.
This is used primarily when there is an expression such as
<!--#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 -->
L<Apache2::Connection> also has a L<Apache2::Connection/remote_addr> method, but this returns a L<APR::SockAddr> 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. L<Apache2::Connection/useragent_ip>
lib/Apache2/SSI.pm view on Meta::CPAN
<!--#if expr="$QUERY_STRING = /^something/" -->
<!--#if expr="$QUERY_STRING == /^something/" -->
# works also with eq, ne, lt, le, gt and ge
<!--#if expr="9 gt 3" -->
<!--#if expr="9 -gt 3" -->
# Other operators work too, namely == != < <= > >= =~ !~
<!--#if expr="9 > 3" -->
<!--#if expr="9 !> 3" -->
<!--#if expr="9 !gt 3" -->
# Checks the remote ip is part of this subnet
<!--#if expr="-R 192.168.2.0/24" -->
<!--#if expr="192.168.2.10 -R 192.168.2.0/24" -->
<!--#if expr="192.168.2.10 -ipmatch 192.168.2.0/24" -->
# Checks if variable is non-empty
<!--#if expr="-n $some_variable" -->
# Checks if variable is empty
<!--#if expr="-z $some_variable" -->
# Checks if the visitor can access the uri /restricted/uri
<!--#if expr="-A /restricted/uri" -->
For subnet checks, this uses L<Net::Subnet>
Expressions that would not work outside of Apache, i.e. it will return an empty string:
lib/Apache2/SSI/File/Type.json view on Meta::CPAN
"video/x-jng",
[]
],
[
0,
0,
4,
"belong",
null,
"=",
235082497,
"N",
"application/x-hdf",
[]
],
[
0,
0,
7,
"string",
null,
t/htdocs/ssi/03.10.if.html view on Meta::CPAN
<!--#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 -->
t/htdocs/ssi/03.11.if.html view on Meta::CPAN
<!--#if expr="'192.168.1.10' -ipmatch '192.168.2.0/24'" -->
Failed test
<!--#else -->
Ok, remote ip is not part of my subnet
<!--#endif -->
t/htdocs/ssi/03.12.if.html view on Meta::CPAN
<!--#if expr="'192.168.1.10' !-ipmatch '192.168.2.0/24'" -->
Ok, remote ip is not part of my subnet
<!--#else -->
Failed test
<!--#endif -->
( run in 1.192 second using v1.01-cache-2.11-cpan-7add2cbd662 )