Server Side Includes

Server side includes use the webserver to include files into your web page.  This allows your common code to be in a single file.  When you update the file, all of your pages are updated.

Notes:

Includes

<!--#include file="test.txt" -->

Conditionals

<!--#if expr="${HTTP_USER_AGENT} = /MSIE/" -->
  <B>Too bad, your using Internet Explorer</B><BR>
<!--#else -->
  <B>Good choice in browsers</B><BR>
<!--#endif -->


<!--#if expr="$brtype = /msie/" -->
<BODY BACKGROUND="I_heart_bill.gif">
<!--#elif expr="$brtype = /netscape/" -->
<BODY BACKGROUND="netscape.gif">
<!--#else -->
<BODY BACKGROUND="waves.gif">
<!--#endif -->
The slashes cause it to search for the substring in the string.  Without the slashes it must be an exact match.

The symbols "!=", "||" and "&&" have their expected values.  The backslash can be used to quote slashes.

Setting Variables

<!--#set var="brtype" value="netscape4" -->

Predefined Variables

AUTH_TYPE client authorization method if any
CONTENT_LENGTH size of input posted from client
CONTENT_TYPE MIME type of content
DATE_GMT The current GMT (greenwich, UK) can be formatted using #config
DATE_LOCAL current time/date, can be formatted using #config
DOCUMENT_NAME document name that was requested
DOCUMENT_URI URL of the document
LAST_MODIFIED document modified date, can be formatted using #config
PAGE_COUNT number of accesses to current document since server was brought on line
HTTP_REFERER URL of the document the client came from
REMOTE_ADDR Numeric IP address of the client
REMOTE_HOST domain name of the client (DNS option must be active on server)
REMOTE_USER ID of user, rarely ever found
REQUEST_METHOD HTTP method: GET OR POST
SERVER_NAME server hostname
SERVER_PORT the port used by httpd (usually 80)
SERVER_PROTOCOL Which version of Httpd compliance
SERVER_SOFTWARE The name of the server software, i.e., apache 1.2.5
TOTAL_HITS total pages served by server since brought on line

Echo Command

<!--#echo var="DATE_LOCAL" -->

Formatting the date:

<!--#config timefmt="%m/%d/%y" -->

Will give you a date such as 02/17/97

The complete list of unix style date format code follow:

CODE PURPOSE OF CODE
%a abbreviated weekday name
%A full weekday name
%b abbreviated month name
%B full month name
%c locale's appropriate date and time representation
%C default date and time format
%d day of month - 01 to 31
<%D date as %m/%d/%y
%e day of month - 1 to 31 (single digits are preceded by a blank)
%h abbreviated month name (alias for %b)
%H hour - 00 to 23
%I hour - 01 to 12
%j day of year - 001 to 366
%m month of year - 01 to 12
%M minute - 00 to 59
%n insert a newline character
%p string containing AM or PM
%r time as %I:%M:%S %p
%R time as %H:%M
%S second - 00 to 61
%t insert a tab character
%T time as %H:%M:%S
%U week number of year (Sunday is the first day of the week) - 00 to 53
%w day of week - Sunday=0
%W week number of year (Monday is the first day of the week) - 00 to 53
%x Country-specific date format
%X Country-specific time format
%y year within century - 00 to 99
%Y year as CCYY (4 digits)
%Z timezone name

  Creating a back button

<A HREF='<!--#echo var="HTTP_REFERER"-->'>BACK BUTTON<A>