Apr 12, 2008

SSI Commands, CGI

SSI Commands

This page lists SSI commands and provides a brief description of what they do. SSI Commands are specified using the following syntax:

<!—#COMMAND PARAMETER="ARGUMENT"—>

The <!-- and the --> brackets must be included.

The commands are as follows:

Command

Parameter

Argument Type

Function

#config

ermsg

message

Sets the server error message to the string "message"

sizefmt

format

The value format is "abbrev" or "bytes". This configures the output of the #fsize command to show file size in bytes or kilobytes(abbrev).

timefmt

string

Controls how date and time are displayed. Format of the string is described on a later page.

#echo

var

environment variable

Echo the environment variable value.

#exec

cmd

Executable file name

Execute the specified program.

cgi

CGI file name

Execute the specified CGI program.

#flastmod

file

file name

Tells the last time the named file was modified

#fsize

file

file name

Tells the file size of the named file.

#include

file

file name

Puts the contents of the named file inside the current file.

virtual

file name

The path to the file is relative to the web server root directory.

Additional SSI Variables

In addition to the available CGI variables, SSI adds the following additional environment variables:

  • DATE_GMT - The present date and time in Greenwich Mean Time.
  • DATE_LOCAL - The current local time zone date and time.
  • DOCUMENT_NAME - The web page file being displayed such as an HTML file.
  • DOCUMENT_URL - Relative to the web server root path, this is the virtual path to the file.
  • LAST_MODIFIED - The date and time of the last modification of the current file.
  • QUERY_STRING_UNESCAPED - The undecoded query string, including a backward slash (\) followed by some special characters.

These environment variables may be used with the echo command to output the information contained by the environment variables. They may also be used in the server script that is called by the #EXEC command to add more functionality on the server side. I use this to save a hit count value in the server script program to a different file for every web page it is called from based on the name of the .SHTML file the SSI command is in. This way only one script program is required to record hit counts and all that is required beyond that is to put the #EXEC command on each page you want to record hits for.

No comments:

Post a Comment

Popular Posts