[Home] [About The World] [Kiosk Web Hosting] [Customer Help]
[Memo] [Login] [WebMail Login]


USING SERVER-SIDE INCLUDES (SSIs)

Note: SSIs are supported by The World Kiosk high-end Web services, but not in HPA (Home Page Alone) basic Web services.

SSIs have been enabled for all Kiosk sites except those that have special setups (such as password protection) currently. If SSIs aren't working in your Kiosk, send a note to kiosk@world.std.com and we'll turn them on for you.

Server-side includes are a simple yet powerful way of doing a few tricks with your Web pages -- you can include the contents of a file (such as a standard footer) in all your pages, put the current or last modification date on the page automatically, and so on. SSIs are processed by our Web server before the page is served, so that visitors to your site see only the results, and cannot see the source for the command. Only files with names ending with .shtml are processed for SSIs, so be sure to give your files the correct filename extension. (index.shtml is supported as a default page name, along with index.html.) Note that because the SSIs are processed by the Web server and not a Web browser, you can normally not see them working if you view your pages off-line.

SSIs must be typed with the exact syntax shown here: they look like HTML comments, but there must be NO SPACE AFTER "<!--" and ONE SPACE BEFORE "-->". Also, they are usually case-sensitive.

This document is a brief introduction the basic SSI command language. Our Apache server also supports some additional commands, known as XSSIs. For full details on every supported command (such as the wonderful "#if"), see The World's XSSI Cookbook.




"#echo" : display a variable

<!--#echo var="LAST_MODIFIED" -->
Displays the date and/or time your Web page was last changed. Use "config timefmt" first to specify what it looks like.
<!--#echo var="DATE_LOCAL" -->
Displays the current date in the Web server's local time zone (Boston).
<!--#echo var="DATE_GMT" -->
Displays the current date in Greenwich Mean Time.
<!--#echo var="DOCUMENT_NAME" -->
Displays the name of the document (i.e. "index.shtml")
<!--#echo var="DOCUMENT_URI" -->
Displays the URL of the document (i.e. "/news/index.shtml") relative to the server root. Note that it is "URI", not "URL" in the command! (The NCSA uses the term "URI" -- Uniform Resource Indicator -- while practically everyone else uses the term "URL" -- Uniform Resource Locator. SSIs were first developed by the NCSA.)
<!--#echo var="QUERY_STRING_UNESCAPED" -->
Displays the query (form) data that was appended to the end of the URL of this page, if any. In other words, if "index.html?find=name" was the URL used, this would say "find=name". Only useful for debugging CGI forms.



"#include" : include text or an HTML fragment from another file,
or run a CGI and display the results

To include a text or HTML file:

<!--#include file="filename" -->
Includes a file in the current directory, or in a subdirectory of the current directory. May NOT start with ".", "..", or "/".
<!--#include virtual="/path/filename" -->
Includes a file in the specified path from the server root (your main Kiosk directory). MUST begin with "/". Example: if your navigation bar is in "includes/navbar.inc" in your Kiosk directory, you would use <!--#include virtual="/includes/navbar.inc" -->.

The included files can be plain text or fragments of HTML. They should not be complete Web pages starting with <HTML> and <BODY> (those would usually be in the .shtml file that includes the smaller file), but they can contain HTML tags. The filename extension is arbitrary -- some people use .txt, .html, or .inc for these bits. If you are including a .shtml file, it is also checked for SSI commands, so you can include a file inside an included file.

To include the output of a CGI program:

<!--#include virtual="/cgi-bin/program.cgi" -->
The output of the CGI must still start with the HTTP response header followed by a blank line, like any other CGI. However, the output is not displayed as a complete Web page, but is included in your .shtml page. As a result, you can use this to write a program that displays different text (text counters, fortune cookies, etc.) on your page each time the program is run.

This is equivalent to the "#exec" command, and should be used insted of "#exec". Note that CGIs can be included only with "#include virtual", not "#include file". The output of the CGI is not checked for any further SSI commands, so it needs to output ordinary text and HTML.




"#fsize" : How large is a file?

<!--#fsize file="index.html" -->
<!--#fsize virtual="/path/index.html" -->
This tells you how many bytes are in the specified file (with the same "file" or "virtual" parameter as "#include".) Use "#config sizefmt" to specify whether you want a number of bytes or k.



"#flastmod" : How old is a file?

<!--#flastmod file="index.html" -->
<!--#flastmod virtual="/path/index.html" -->
Displays the modification date of the specified file, with the same "file"/"virtual" syntax as "#include". Use "#config timefmt" to change the format. Use "#echo var="LAST_MODIFIED"" instead if you want to get the date of the same page the command is in.



"#exec" : run a CGI script and include the results in the current page

Use "#include virtual" (listed above) instead of "#exec". It will execute CGIs the same way but presents fewer security risks.




"#config" : change the time, date, file size, and error output formats

<!--#config timefmt="%A, %B %d, %Y" -->
Configures how times and dates will be displayed. For a list of the percent-sign-things you can put here, type the "man strftime" UNIX command.
<!--#config sizefmt="bytes" -->
<!--#config sizefmt="abbrev" -->
Tells the "fsize" command whether to say "123,456" or "123k" for a 123,456-byte file.
<!--#config errmsg="You goofed, check your spelling." -->
Changes the default SSI error message from "[an error occurred while processing this directive]" to whatever you want. I don't know why you'd want to make up your own error messages, but you can.



To see SSIs in action, see:
Working examples of SSIs
Source code of the same examples
The World's XSSI Cookbook (with more details)



(@) THE WORLD
Comments? Questions? Problems? Contact us.
Page last modified February 14, 2003.
Web site contents & design Copyright © 2003 Software Tool & Die.
  Legal info.
Spammers are crooks! Don't do business with crooks!