Tools » Server Side Includes (ssi). . .

Our server side includes can include certain information such as the current date, the file's last modification date, and the size or last modification of other files.

NOTE: In order for the includes to work, you must name your page ".shtml" or ".shtm"

»The Code
»SSI Environment Variables
»Time and Date Formats


SSI Code

All directives to the server are formatted as SGML comments within the document. This is in case the document should ever find itself in the client's hands unparsed. Each directive has the following format:

<!--#command tag1="value1" tag2="value2" -->

Each command takes different arguments, most only accept one tag at a time. Here is a breakdown of the commands and their associated tags:

config - The config directive controls various aspects of the file parsing. There are two valid tags:

errmsg - controls what message is sent back to the client if an error includes while parsing the document. When an error occurs, it is logged in the server's error log.

E.g.: <!--#config errmsg="Server Error - Please contact webmaster..." -->

timefmt - gives the server a new format to use when providing dates. This is a string compatible with the strftime library call under most versions of UNIX.

E.g.: <!--#config timefmt="%A, %B %d, %Y" --> See Time and Date Formats.

sizefmt - determines the formatting to be used when displaying the size of a file. Valid choices are bytes, for a formatted byte count (formatted as 1,234,567), or abbrev - for an abbreviated version displaying the number of kilobytes or megabytes the file occupies.

E.g.: <!--#config sizefmt="bytes" -->

include - include will insert the text of a document into the parsed document. Any included file is subject to the usual access control. This command accepts two tags:

virtual - gives a virtual path to a document on the server. You must access a normal file this way, you cannot access a CGI script in this fashion. You can, however, access another parsed document.

E.g.: <!--#include virtual="/stuff/mystuff.html" -->

file - gives a pathname relative to the current directory.  ../ cannot be used in this pathname, nor can absolute paths be used. As above, you can send other parsed documents, but you cannot send CGI scripts.

E.g.: <!--#include file="mystuff.html" -->

echo - prints the value of one of the include variables (See Environment Variables). Any dates are printed subject to the currently configured timefmt. The only valid tag to this command is var, whose value is the name of the variable you wish to echo.

E.g.: <!--#echo var="DATE_LOCAL" -->  See the SSI Environment Variables.

fsize - prints the size of the specified file. Valid tags are the same as with the include command. The resulting format of this command is subject to the sizefmt parameter to the config command.

E.g.: <!--#fsize file="myfile.html" -->

flastmod - prints the last modification date of the specified file, subject to the formatting preference given by the timefmt parameter to config. Valid tags are the same as with the include command.

E.g.: <!--#flastmod virtual="/coolstuff/mystuff.html" -->

exec - executes a given shell command or CGI script.

E.g.: <!--#exec cgi="script.cgi" -->

 

Copyright © 1996-2002 . 7th Gate Web Hosting, Inc . All rights reserved.