GeoffKnagge.com

The Special Commands

All of the special SSI tags appear in HTML files in the following form:
<!--#element attribute1=value1 attribute2=value2 ... --> 
In the above, element is the command name, which may be followed by one or more attributes that specify what information to display. The attributes are assigned values, often in quotes, and usually only one attribute can be specified per command. See the specific commands for details.

Config - error messages, time and file size format

The config command is used to customise error messages, and to specify formatting of date and file size information.
<!--#config errmsg="value" -->
<!--#config timefmt="value" -->
<!--#config sizefmt="value" -->
The available attributes are all optional, and are:
  • errmsg : The message that is sent out if an error occurs while interpreting the SHTML file. For example, this might be displayed if a file specified by #include does not exist.
  • timefmt : The format to use when specifying dates. This string is as used by the strftime call in Unix. (see below)
  • sizefmt : Possible values are bytes, for a value formatted in the form 111,111,111, or abbrev to display the file size in terms of KB or MB.
Examples:
<!--#config errmsg="[Something went wrong...]"-->
<!--#config sizefmt="abbrev"-->

Date Representation Strings

The following was taken directly from the Unix manual files for strftime, and contains the special symbols used to specify a custom date format string. For example,
<!--#config timefmt="%r on %A, %e %B %G" -->
<!--#echo var="DATE_LOCAL" -->
produces... 08:37:02 PM on Saturday, 25 May 2019
     %%        Same as %.
     %a        Locale's abbreviated weekday name.
     %A        Locale's full weekday name.
     %b        Locale's abbreviated month name.
     %B        Locale's full month name.
     %c        Locale's appropriate date and time representation.
     %C        Locale's date and time representation as  produced
               by date(1).
     %C        Century number (the year divided by 100 and  trun-
               cated  to  an integer as a decimal number [1,99]);
               single digits are preceded by 0; see standards(5).
     %d        Day of month [1,31]; single digits are preceded by
               0.
     %D        Date as %m/%d/%y.
     %e        Day of month [1,31]; single digits are preceded by
               a space.
     %g        Week-based year within century [00,99].
     %G        Week-based    year,    including    the    century
               [0000,9999].
     %h        Locale's abbreviated month name.
     %H        Hour (24-hour clock)  [0,23];  single  digits  are
               preceded by 0.
     %I        Hour (12-hour clock)  [1,12];  single  digits  are
               preceded by 0.
     %j        Day number of year [1,366]; single digits are pre-
               ceded by 0.
     %k        Hour (24-hour clock)  [0,23];  single  digits  are
               preceded by a blank.
     %l        Hour (12-hour clock)  [1,12];  single  digits  are
               preceded by a blank.
     %m        Month number [1,12]; single digits are preceded by
               0.
     %M        Minute [00,59]; leading 0  is  permitted  but  not
               required.
     %n        Insert a NEWLINE.
     %p        Locale's equivalent of either a.m. or p.m.
     %r        Appropriate time representation in  12-hour  clock
               format with %p.
     %R        Time as %H:%M.
     %S        Seconds [00,61]; the range of  values  is  [00,61]
               rather  than  [00,59]  to allow for the occasional
               leap second and even more occasional  double  leap
               second.
     %t        Insert a TAB.
     %T        Time as %H:%M:%S.
     %u        Weekday  as  a  decimal  number  [1,7],   with   1
               representing Sunday.
     %U        Week number of year as a decimal  number  [00,53],
               with Sunday as the first day of week 1.
     %V        The ISO 8601  week  number  as  a  decimal  number
               [01,53].  In the ISO 8601 week-based system, weeks
               begin on a Monday and week 1 of the  year  is  the
               week  that includes both January 4th and the first
               Thursday of the year.   If  the  first  Monday  of
               January  is  the  2nd,  3rd, or 4th, the preceding
               days are part of the last week  of  the  preceding
               year.  See NOTES below.
     %w        Weekday  as  a  decimal  number  [0,6],   with   0
               representing Sunday.
     %W        Week number of year as a decimal  number  [00,53],
               with Monday as the first day of week 1.
     %x        Locale's appropriate date representation.
     %X        Locale's appropriate time representation.
     %y        Year within century [00,99].
     %Y        Year, including the century (for example 1993).
     %Z        Time zone name or abbreviation, or no bytes if  no
               time zone information exists.

     %Ec       Locale's  alternate  appropriate  date  and   time
               representation.
     %EC       Name of the base year  (period)  in  the  locale's
               alternate representation.
     %Eg       Offset from %EC of  the  week-based  year  in  the
               locale's alternative representation.
     %EG       Full alternative representation of the  week-based
               year.
     %Ex       Locale's alternate date representation.
     %EX       Locale's alternate time representation.
     %Ey       Offset from %EC (year only) in the locale's alter-
               nate representation.
     %EY       Full alternate year representation.
     %Od       Day of the  month  using  the  locale's  alternate
               numeric symbols.
     %Oe       Same as %Od.
     %Og       Week-based year (offset from %C) in  the  locale's
               alternate  representation  and  using the locale's
               alternate numeric symbols.
     %OH       Hour (24-hour clock) using the locale's  alternate
               numeric symbols.
     %OI       Hour (12-hour clock) using the locale's  alternate
               numeric symbols.
     %Om       Month using the locale's  alternate  numeric  sym-
               bols.
     %OM       Minutes using the locale's alternate numeric  sym-
               bols.
     %OS       Seconds using the locale's alternate numeric  sym-
               bols.
     %Ou       Weekday as a  number  in  the  locale's  alternate
               numeric symbols.
     %OU       Week number of the year (Sunday as the  first  day
               of  the week) using the locale's alternate numeric
               symbols.
     %Ow       Number  of  the  weekday  (Sunday=0)   using   the
               locale's alternate numeric symbols.
     %OW       Week number of the year (Monday as the  first  day
               of  the week) using the locale's alternate numeric
               symbols.
     %Oy       Year (offset from %C) in  the  locale's  alternate
               representation  and  using  the locale's alternate
               numeric symbols.


Including Files within a file

The include command is used to insert a document within a document. For example, you may want to specify the page template for a site and import this in each of your pages, so you only need to change one file if you decide to change your layout.

You can include other SHTML files, but not CGI scripts.
<!--#include virtual="value" -->
<!--#include file="value" -->
  • virtual : Loads a file from the current server, where the file is given by a virtual address relative to the current directory. The "/" directory refers to the root HTML directory for this server. This is the form nomally used.
  • file : Gives a path relative to the current directory, but ../ cannot be used.
Example:
<!--#include virtual="/templates/guideheader.t" -->


Echo - file names and dates

The Echo command is used to print certain system variables on the web page:
<!--#echo var="value" -->
Value is one of the following :
  • DOCUMENT_NAME : The filename of the current file
  • DOCUMENT_URI : The virtual path to the current file
  • QUERY_STRING_UNESCAPED : The query sent by a form or script
  • DATE_LOCAL : Current date and time zone, formatted as specified by the timefmt config option.
  • DATE_GMT : Current date in GMT time.
  • LAST_MODIFIED : When the current document was last modified.


Fsize - file size

The fsize command displays the file size of the specified file, in a format given by the sizefmt option of the config command.
<!--#fsize virtual="value" -->
<!--#fsize file="value" -->
  • virtual : Loads a file from the current server, where the file is given by a virtual address relative to the current directory. The "/" directory refers to the root HTML directory for this server. This is the form nomally used.
  • file : Gives a path relative to the current directory, but ../ cannot be used.
Example:
<!--#fsize virtual="/index.html" -->


Flastmod - file last modified date

The flastmod command displays the file size of the specified file, in a format given by the timefmt option of the config command.
<!--#flastmod virtual="value" -->
<!--#flastmod file="value" -->
  • virtual : Loads a file from the current server, where the file is given by a virtual address relative to the current directory. The "/" directory refers to the root HTML directory for this server. This is the form nomally used.
  • file : Gives a path relative to the current directory, but ../ cannot be used.
Example:
<!--#flastmod virtual="/index.html" -->


Exec - CGI or shell command execution

This allows you to execute CGI or system commands, and display the results on the web page. For security reasons, this is usually disabled in the web server by default, and must be enabled in the config file if you wish to use it.
<!--#exec cmd="value" -->
<!--#exec cgi="value" -->
  • cmd is the form to use when executing system commands. The variables used in echo are also valid for use in the command.
  • cgi takes the virtual address given and displays the results in text form. i.e. it can't return images or other non-text outputs.
(C)opyright, Geoff Knagge.
Continued use of this site indicates your agreement to the Conditions of use and Privacy Policy.