|
|
|
To access the contents, click the chapter and section titles.
HTML 4.0 Sourcebook
(Publisher: John Wiley & Sons, Inc.)
Author(s): Ian S. Graham
ISBN: 0471257249
Publication Date: 04/01/98
Fsize is useful for presenting information about a file to be downloaded, particularly when the size varies often. For example:
...Download</A> the mail
archive: (<!--#fsize file=main.html --> bytes)
The output format is set by the sizefmt argument of the config command.
|
Table 11.2 Environment Variables Defined Only Within Parsed HTML Documents. These variables are also available to CGI programs executed from within a parsed HTML document.
|
|
Variable Name
| Content
|
DOCUMENT_NAME
| The name of the document being parsed. This is the raw name, stripped of any leading path information, extra path information, or query string data. For example, if the accessed URL were of the form /path/to/file.shtml/extra/path?foo, DOCUMENT_NAME would simply be file.shtml.
|
DOCUMENT_URI
| The virtual (relative to server document directory) path to the document, such as ~fosdick/path/file.shtml, or /path/subpath/templates/template2.html. This will include any extra path information in the requesting URL, but not appended query string data.
|
DATE_LOCAL
| The current date using the local time zone. The format of this date is controlled using the timefmt argument of the config command.
|
DATE_GMT
| Same as DATE_LOCAL, but in Greenwich Mean Time.
|
LAST_MODIFIED
| The last modification date of the current document. The format is specified by timefmt.
|
The following variable is not available on all HTTP servers
|
DOCUMENT_PATH_INFO
| Contains any extra path information in the requesting URL. For example, if the requesting URL were /path/to/file.shtml/extra/path?foo, the DOCUMENT_PATH_INFO would be /extra/path.
|
|
FlastmodInclude Last Modification Time of Listed File
This includes the last modification time of a file specified using the file or virtual arguments, as described in the include command section. Like fsize, flastmod is useful for providing up-to-date information about files that are periodically changed. For example:
This file was last changed on:
<!--#flastmod virtual=/path/dir1/dir2/main.html -->
The output format is determined by the timefmt argument of the config command.
ExecExecute Shell Script of CGI Program
This directive executes the indicated Bourne-shell command or CGI program and includes the program output inline in the document. The two possible arguments are:
cmd=cmd_string
- Causes the string cmd_string to be executed using the Bourne shell (sh). Cmd_string can be a simple one-line shell program that does simple tasks, such as listing directory contents or running a program to filter data for inclusion. The SSI directive is replaced by the output of the shell program.
cgi=cgi_program
- Executes the given CGI program, where the location of the program is given by the virtual path to the program; recall that the SSI directive is replaced by the output of the program. Also note that the script must return a valid MIME type. You cannot pass query strings or path information to the script using the standard URL mechanisms. Thus expressions like
<!--#exec cgi=/cgi-bin/script.cgi/path1/path2?query -->
- are invalid. The only way you can access the script is with the command:
<!--#exec cgi=/cgi-bin/script.cgi -->
However, suppose the parsable script stuff.shtml contained the command
<!--#exec cgi=/cgi-bin/script.cgi -->
and you access the file stuff.shtml via a URL of the form:
.../stuff.shtml/extra/path?query_string
- In this case, the query_string and /extra/path information are available to the script script.cgi called from stuff.shtml. This is illustrated in an example at the end of this section.
Environment Variables Within Execed CGIs
The variables defined in Table 11.2 are also available within gateway or shell programs that are executed using the exec command. In addition, any extra path or query information appended to the parsed HTML document name are passed to the CGI program within the PATH_INFO and QUERY_STRING variables, as per standard practice. At the same time, several servers define additional environment variables to provide information about the executing script. The most common of these additional variables are given in Table 11.3. These variables are defined by the Apache servers (Version 1 and greater), but not by NCSA servers prior to version 1.5.
NOTE: Possible Problems with Environment Variables
Some servers do not set the environment variables listed in Table 11.3 or at the bottom or Table 11.2, while others improperly set their content. To be safe, you should verify the accuracy of all environment variables prior to installing any CGI programs invoked via server-side includes.
|
Table 11.3 Environment Variables Defined Only Within CGI Programs Invoked by a Parsed HTML Document. These variables are not universally available on all servers.
|
|
Variable Name
| Content
|
SCRIPT_NAME
| The name of the script being executed, including the virtual path information needed to locate the script.
|
SCRIPT_FILENAME
| The complete absolute name of the file, including the path to the file from the root of the filesystem.
|
|
ConfigSet SSI Configuration Settings
This directive controls aspects of the output of the other parsed commands, such as the formats of the date and size output strings, or the error message string to include if parsing fails. Config can take three different arguments, one argument per command. These are:
errmsg=error_string
- Sets the error message to use if there is an error in parsing the parsable commands.
timefmt=format
- Sets the format for printing dates. This format is specified as per the C strftime library call (strftime is commonly found on UNIX computers).
sizefmt=bytes,abbrev
- Sets the format for the specification of file sizes. The value bytes prints file sizes in bytes, while abbrev uses kilobytes or megabytes as abbreviated forms, where applicable.
Some examples of config format specifications are:
<!--#config sizefmt=abbrev -->
<!--#config timefmt=%m%d%y -->
<!--#config errmsg=Unable to parse scripts -->
|