# Module mod_include

This module is contained in the `mod_include.c` file, and is compiled in by default. It provides for server-parsed html documents, known as SPML documents. Any document with mime type `text/x-server-parsed-html` or `text/x-server-parsed-html3` will be parsed by this module, with the resulting output given the mime type `text/html`.

## SPML -- Include file Format

The document is parsed as an HTML document, with special commands embedded as SGML comments. A command has the syntax:

> `<!--#`element attribute=value attribute=value ... `-->`

The value will often be enclosed in double quotes; many commands only allow a single attribute-value pair.

The allowed elements are:

config
  This command controls various aspects of the parsing. The valid attributes are:
  errmsg
    The value is a message that is sent back to the client if an error occurs whilst parsing the document.
  sizefmt
    The value sets the format to be used which displaying the size of a file. Valid values are `bytes` for a count in bytes, or `abbrev` for a count in Kb or Mb as appropriate.
  timefmt
    The value is a string to be used by the `strftime(3)` library routine when printing dates.
echo
  This command prints one of the include variables, defined below. If the variable is unset, it is printed as `(none)`. Any dates printed are subject to the currently configured `timefmt`. Attributes:
  var
    The value is the name of the variable to print.
exec
  The exec command executes a given shell command or CGI script. The IncludesNOEXEC Option disables this command completely. The valid attributes are:
  cgi
    The value specifies a (%-encoded) URL relative path to the CGI script. If the path does not begin with a (/), then it is taken to be relative to the current document. The document referenced by this path is invoked as a CGI script, even if the server would not normally recognise it as such. However, the directory containing the script must be enabled for CGI scripts (with ScriptAlias or the ExecCGI Option).

    The CGI script is given the PATH_INFO and query string (QUERY_STRING) of the original request from the client; these cannot be specified in the URL path. The include variables will be available to the script in addition to the standard CGI environment.

    If the script returns a Location: header instead of output, then this will be translated into an HTML anchor.

    The `include virtual` element should be used in preference to `exec cgi`.

  cmd
    The server will execute the given string using `/bin/sh`. The include variables are available to the command.
fsize
  This command prints the size of the specified file, subject to the `sizefmt` format specification. Attributes:
  file
    The value is a path relative to the directory containing the current document being parsed.
  virtual
    The value is a (%-encoded) URL-path relative to the current document being parsed. If it does not begin with a slash (/) then it is taken to be relative to the current document.
flastmod
  This command prints the last modification date of the specified file, subject to the `timefmt` format specification. The attributes are the same as for the `fsize` command.
include
  This command inserts the text of another document or file into the parsed file. Any included file is subject to the usual access control. If the directory containing the parsed file has the Option IncludesNOEXEC set, and the including the document would cause a program to be executed, then it will not be included; this prevents the execution of CGI scripts. Otherwise CGI scripts are invoked as normal using the complete URL given in the command, including any query string.

  An attribute defines the location of the document; the inclusion is done for each attribute given to the include command. The valid attributes are:

  file
    The value is a path relative to the directory containing the current document being parsed. It cannot contain `../`, nor can it be an absolute path. The `virtual` attribute should always be used in preference to this one.
  virtual
    The value is a (%-encoded) URL relative to the current document being parsed. The URL cannot contain a scheme or hostname, only a path and an optional query string. If it does not begin with a slash (/) then it is taken to be relative to the current document.
  A URL is constructed from the attribute, and the output the server would return if the URL were accessed by the client is included in the parsed output. Thus included files can be nested.

## Include variables

These are available for the `echo` command, and to any program invoked by the document.

DATE_GMT
  The current date in Greenwich Mean Time.
DATE_LOCAL
  The current date in the local time zone.
DOCUMENT_NAME
  The filename (excluding directories) of the document requested by the user.
DOCUMENT_URI
  The (%-decoded) URL path of the document requested by the user. Note that in the case of nested include files, this is not then URL for the current document.
LAST_MODIFIED
  The last modification date of the document requested by the user.

## Directives

- XBitHack

## XBitHack

Syntax: XBitHack status
Default: `XBitHack off`
Context: server config, virtual host, directory, .htaccess
Override: Options
Status: Base
Module: mod_include

The XBitHack directives controls the parsing of ordinary html documents. Status can have the following values:

off
  No special treatment of executable files.
on
  Any file that has the user-execute bit set will be treated as a server-parsed html document.
full
  As for `on` but also test the group-execute bit. If it is set, then set the Last-modified date of the returned file to be the last modified time of the file. If it is not set, then no last-modified date is sent. Setting this bit allows clients and proxies to cache the result of the request.