As
I mentioned before, you can insert the values of environment variables
in an otherwise static HTML document. Here is
an example of a document that contains a few SSI directives:
<HTML>
<HEAD><TITLE>Welcome!</TITLE></HEAD>
<BODY>
<H1>Welcome to my server at <!--#echo var="SERVER_NAME"-->...</H1>
<HR>
Dear user from <!--#echo var="REMOTE_HOST"-->,
<P>
There are many links to various CGI documents throughout the Web,
so feel free to explore.
.
.
.
<HR>
<ADDRESS>Shishir Gundavaram (<!--#echo var="DATE_LOCAL"-->)</ADDRESS>
</BODY></HTML>
SSI directives have the following format:
<!--#command parameter="argument"-->
In this example, the echo
SSI command with the var parameter is used to
display the IP name or address of the serving machine, the remote
host name, and the local time. Of course, we could have written
a CGI program to perform the same function, but this approach is
much quicker and easier, as you can see.
All environment variables that are available to CGI programs
are also available to SSI directives. There are also a few variables
that are exclusively available for use in SSI directives, such as
DATE_LOCAL,
which contains the current local time. Another is DATE_GMT:
The current GMT time is: <!--#echo var="DATE_GMT"-->
which contains the Greenwich Mean Time.
Here is another example that uses some of these exclusive
SSI environment variables to output information about the current
document:
<H2>File Summary</H2>
<HR>
The document you are viewing is titled: <!--#echo var="DOCUMENT_NAME"-->,
and you can access it a later time by opening the URL to:
<!--#echo var="DOCUMENT_URI"-->. Please add this to your bookmark list.
<HR>
Document last modified on <!--#echo var="LAST_MODIFIED"-->.
This will display the name, URL (although the variable is
titled DOCUMENT_URI), and modification time for
the current HTML document.
For a listing of CGI environment variables, see Table 2.1.
Table 5.2 shows additional SSI environment variables.
Table 5.2: Additional SSI Environment Variables
Environment Variable |
Description |
DOCUMENT_NAME |
The current file |
DOCUMENT_URI |
Virtual path to the file |
QUERY_STRING_UNESCAPED |
Undecoded query string with all shell
metacharacters escaped with "\" |
DATE_LOCAL |
Current date and time in the local time
zone |
DATE_GMT |
Current date and time in GMT |
LAST_MODIFIED |
Last modification date and time for current
file |