.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "SSI 3pm"
.TH SSI 3pm "2022-06-10" "perl v5.34.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
.Vb 1
\& CGI::SSI \- Use SSI from CGI scripts
.Ve
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& # autotie STDOUT or any other open filehandle
\&
\& use CGI::SSI (autotie => \*(AqSTDOUT\*(Aq);
\&
\& print $shtml; # browser sees resulting HTML
\&
\& # or tie it yourself to any open filehandle
\&
\& use CGI::SSI;
\&
\& open(FILE,\*(Aq+>\*(Aq.$html_file) or die $!;
\& $ssi = tie(*FILE, \*(AqCGI::SSI\*(Aq, filehandle => \*(AqFILE\*(Aq);
\& print FILE $shtml; # HTML arrives in the file
\&
\& # or use the object\-oriented interface
\&
\& use CGI::SSI;
\&
\& $ssi = CGI::SSI\->new();
\&
\& $ssi\->if(\*(Aq"$varname" =~ /^foo/\*(Aq);
\& $html .= $ssi\->process($shtml);
\& $ssi\->else();
\& $html .= $ssi\->include(file => $filename);
\& $ssi\->endif();
\&
\& print $ssi\->exec(cgi => $url);
\& print $ssi\->flastmod(file => $filename);
\&
\& #
\& # or roll your own favorite flavor of SSI
\& #
\&
\& package CGI::SSI::MySSI;
\& use CGI::SSI;
\& @CGI::SSI::MySSI::ISA = qw(CGI::SSI);
\&
\& sub include {
\& my($self,$type,$file_or_url) = @_;
\& # my idea of include goes something like this...
\& return $html;
\& }
\& 1;
\& _\|_END_\|_
\&
\& #
\& # or use .htaccess to include all files in a dir
\& #
\&
\& # in .htaccess
\& Action cgi\-ssi /cgi\-bin/ssi/process.cgi
\&
\& SetHandler cgi\-ssi
\&
\&
\& # in /cgi\-bin/ssi/process.cgi
\& #!/usr/local/bin/perl
\& use CGI::SSI;
\& CGI::SSI\->handler();
\& _\|_END_\|_
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\s-1CGI::SSI\s0 is meant to be used as an easy way to filter shtml
through \s-1CGI\s0 scripts in a loose imitation of Apache's mod_include.
If you're using Apache, you may want to use either mod_include or
the Apache::SSI module instead of \s-1CGI::SSI.\s0 Limitations in a \s-1CGI\s0
script's knowledge of how the server behaves make some \s-1SSI\s0
directives impossible to imitate from a \s-1CGI\s0 script.
.PP
Most of the time, you'll simply want to filter shtml through \s-1STDOUT\s0
or some other open filehandle. \f(CW\*(C`autotie\*(C'\fR is available for \s-1STDOUT,\s0
but in general, you'll want to tie other filehandles yourself:
.PP
.Vb 2
\& $ssi = tie(*FH, \*(AqCGI::SSI\*(Aq, filehandle => \*(AqFH\*(Aq);
\& print FH $shtml;
.Ve
.PP
Note that you'll need to pass the name of the filehandle to \f(CW\*(C`tie()\*(C'\fR as
a named parameter. Other named parameters are possible, as detailed
below. These parameters are the same as those passed to the \f(CW\*(C`new()\*(C'\fR
method. However, \f(CW\*(C`new()\*(C'\fR will not tie a filehandle for you.
.PP
\&\s-1CGI::SSI\s0 has it's own flavor of \s-1SSI.\s0 Test expressions are Perlish.
You may create and use multiple \s-1CGI::SSI\s0 objects; they will not
step on each others' variables.
.PP
Object-Oriented methods use the same general format so as to imitate
\&\s-1SSI\s0 directives:
.PP
.Vb 1
\&
\&
\& would be
\&
\& $ssi\->include(virtual => \*(Aq/foo/bar.footer\*(Aq);
.Ve
.PP
likewise,
.PP
.Vb 1
\&
\&
\& would be
\&
\& $ssi\->exec(cgi => \*(Aq/cgi\-bin/foo.cgi\*(Aq);
.Ve
.PP
Usually, if there's no chance for ambiguity, the first argument may
be left out:
.PP
.Vb 1
\&
\&
\& could be either
\&
\& $ssi\->echo(var => \*(Aqvar_name\*(Aq);
\&
\& or
\&
\& $ssi\->echo(\*(Aqvar_name\*(Aq);
.Ve
.PP
Likewise,
.PP
.Vb 1
\& $ssi\->set(var => $varname, value => $value)
\&
\& is the same as
\&
\& $ssi\->set($varname => $value)
.Ve
.ie n .IP "$ssi\->new([%args])" 4
.el .IP "\f(CW$ssi\fR\->new([%args])" 4
.IX Item "$ssi->new([%args])"
Creates a new \s-1CGI::SSI\s0 object. The following are valid (optional) arguments:
.Sp
.Vb 8
\& DOCUMENT_URI => $doc_uri,
\& DOCUMENT_NAME => $doc_name,
\& DOCUMENT_ROOT => $doc_root,
\& errmsg => $oops,
\& sizefmt => (\*(Aqbytes\*(Aq || \*(Aqabbrev\*(Aq),
\& timefmt => $time_fmt,
\& MAX_RECURSIONS => $default_100, # when to stop infinite loops w/ error msg
\& COOKIE_JAR => HTTP::Cookies\->new,
.Ve
.ie n .IP "$ssi\->config($type, $arg)" 4
.el .IP "\f(CW$ssi\fR\->config($type, \f(CW$arg\fR)" 4
.IX Item "$ssi->config($type, $arg)"
\&\f(CW$type\fR is either 'sizefmt', 'timefmt', or 'errmsg'. \f(CW$arg\fR is similar to
those of the \s-1SSI\s0 \f(CW\*(C`spec\*(C'\fR, referenced below.
.ie n .IP "$ssi\->set($varname => $value)" 4
.el .IP "\f(CW$ssi\fR\->set($varname => \f(CW$value\fR)" 4
.IX Item "$ssi->set($varname => $value)"
Sets variables internal to the \s-1CGI::SSI\s0 object. (Not to be confused
with the normal variables your script uses!) These variables may be used
in test expressions, and retrieved using \f(CW$ssi\fR\->echo($varname). These
variables also will not be available in external, included resources.
.ie n .IP "$ssi\->echo($varname)" 4
.el .IP "\f(CW$ssi\fR\->echo($varname)" 4
.IX Item "$ssi->echo($varname)"
Returns the value of the variable named \f(CW$varname\fR. Such variables may
be set manually using the \f(CW\*(C`set()\*(C'\fR method. There are also several built-in
variables:
.Sp
.Vb 5
\& DOCUMENT_URI \- the URI of this document
\& DOCUMENT_NAME \- the name of the current document
\& DATE_GMT \- the same as \*(Aqgmtime\*(Aq
\& DATE_LOCAL \- the same as \*(Aqlocaltime\*(Aq
\& LAST_MODIFIED \- the last time this script was modified
.Ve
.ie n .IP "$ssi\->exec($type, $arg)" 4
.el .IP "\f(CW$ssi\fR\->exec($type, \f(CW$arg\fR)" 4
.IX Item "$ssi->exec($type, $arg)"
\&\f(CW$type\fR is either 'cmd' or 'cgi'. \f(CW$arg\fR is similar to the \s-1SSI\s0 \f(CW\*(C`spec\*(C'\fR
(see below).
.ie n .IP "$ssi\->include($type, $arg)" 4
.el .IP "\f(CW$ssi\fR\->include($type, \f(CW$arg\fR)" 4
.IX Item "$ssi->include($type, $arg)"
Similar to \f(CW\*(C`exec\*(C'\fR, but \f(CW\*(C`virtual\*(C'\fR and \f(CW\*(C`file\*(C'\fR are the two valid types.
\&\s-1SSI\s0 variables will not be available outside of your \s-1CGI::SSI\s0 object,
regardless of whether the virtual resource is on the local system or
a remote system.
.ie n .IP "$ssi\->flastmod($type, $filename)" 4
.el .IP "\f(CW$ssi\fR\->flastmod($type, \f(CW$filename\fR)" 4
.IX Item "$ssi->flastmod($type, $filename)"
Similar to \f(CW\*(C`include\*(C'\fR.
.ie n .IP "$ssi\->fsize($type, $filename)" 4
.el .IP "\f(CW$ssi\fR\->fsize($type, \f(CW$filename\fR)" 4
.IX Item "$ssi->fsize($type, $filename)"
Same as \f(CW\*(C`flastmod\*(C'\fR.
.ie n .IP "$ssi\->printenv" 4
.el .IP "\f(CW$ssi\fR\->printenv" 4
.IX Item "$ssi->printenv"
Returns the environment similar to Apache's mod_include.
.ie n .IP "$ssi\->cookie_jar([$jar])" 4
.el .IP "\f(CW$ssi\fR\->cookie_jar([$jar])" 4
.IX Item "$ssi->cookie_jar([$jar])"
Returns the currently-used HTTP::Cookies object. You may optionally
pass in a new HTTP::Cookies object. The jar is used for web requests
in exec cgi and include virtual directives.
.SS "FLOW-CONTROL \s-1METHODS\s0"
.IX Subsection "FLOW-CONTROL METHODS"
The following methods may be used to test expressions. During a \f(CW\*(C`block\*(C'\fR
where the test \f(CW$expr\fR is false, nothing will be returned (or printed,
if tied).
.ie n .IP "$ssi\->if($expr)" 4
.el .IP "\f(CW$ssi\fR\->if($expr)" 4
.IX Item "$ssi->if($expr)"
The expr can be anything Perl, but care should be taken. This causes
problems:
.Sp
.Vb 2
\& $ssi\->set(varname => "foo");
\& ok
.Ve
.Sp
The \f(CW$varname\fR is expanded as you would expect. (We escape it so as to use
the \f(CW$varname\fR within the \s-1CGI::SSI\s0 object, instead of that within our
progam.) But the \f(CW$/\fR inside the regex is also expanded. This is fixed
by escaping the \f(CW\*(C`$\*(C'\fR:
.Sp
.Vb 1
\& ok
.Ve
.Sp
The expressions used in if and elif tags/calls are tricky due to
the number of escapes required. In some cases, you'll need to
write \f(CW\*(C`\e\e\e\e\*(C'\fR to mean \f(CW\*(C`\e\*(C'\fR.
.ie n .IP "$ssi\->elif($expr)" 4
.el .IP "\f(CW$ssi\fR\->elif($expr)" 4
.IX Item "$ssi->elif($expr)"
.PD 0
.ie n .IP "$ssi\->else" 4
.el .IP "\f(CW$ssi\fR\->else" 4
.IX Item "$ssi->else"
.ie n .IP "$ssi\->endif" 4
.el .IP "\f(CW$ssi\fR\->endif" 4
.IX Item "$ssi->endif"
.PD
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\f(CW\*(C`Apache::SSI\*(C'\fR and the \s-1SSI\s0 \f(CW\*(C`spec\*(C'\fR at
http://www.apache.org/docs/mod/mod_include.html
.SH "AUTHOR"
.IX Header "AUTHOR"
(c) 2000\-2005 James Tolley All Rights Reserved.
.PP
This is free software. You may copy and/or modify it under
the same terms as perl itself.
.SH "CREDITS"
.IX Header "CREDITS"
Many Thanks to Corey Wilson and Fitz Elliot for bug reports and fixes.