DM 171: Week Six - eXtended Server Side Includes

XSSI: Simple Yet Effective Programming for the Masses

Click on a tab to reveal its content…

  • In General
  • Environment
  • XSSI Commands

XSSI are powerful enough to replace functionally simple CGI scripts and do not require knowledge of Perl programming. One of the best sites to learn about simple programming with XSSI is “The World’s XSSI Cookbook” at http://www.std.com/web/help/xssi-cookbook.shtml. There will be many references to the “Cookbook” as well as some paraphrasing; it is a clearly written tutorial that I am so thankful for that I keep a copy locally on my hard drive for reference.

The Neighborhood

The server and your browser create some data known as environmental variables. Knowing these will give you some ideas to be used with if instructions embedded in your pages. The <!--#printenv --> command can be used to show which variables can come into play. Create a page with the code below or download this page to be placed in your exercise three folder to give you a list of the variables.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>SSI Environmental Variables</title>
</head>

<body>
<h1>Server Side Includes - Environmental Variables
</h1>

<pre>
<!--#printenv -->
</pre>

</body>
</html>

What does it all mean? Check the next tab.

Environmental Variables

These are some of the variables that the server keeps track of, notice that not all of them are supported since the “Result” is sometimes (none). Each installation of the Apache Server Software can have its own unique setup.

The results shown are for the art.wallyzone.com server.

Code Description Result
AUTH_TYPE client authorization method if any (none)
CONTENT_LENGTH size of input posted from client (none)
CONTENT_TYPE MIME type of content (none)
DATE_GMT The current GMT time Friday, 22-Sep-2017 08:13:10 GMT
DATE_LOCAL current time/date Friday, 22-Sep-2017 03:13:10 CDT
DOCUMENT_NAME document name that was requested xssi.shtml
DOCUMENT_URI URL of the document /dm171spring2010/schedule/week06/xssi.shtml
LAST_MODIFIED document modified date Thursday, 04-Dec-2014 15:12:38 CST
PAGE_COUNT number of accesses to current document (none)
HTTP_REFERER URL of the document the client came from (none)
REMOTE_ADDR Numeric IP address of the client 54.156.69.204
REMOTE_HOST domain name of the client (none)
REMOTE_USER ID of user (none)
REQUEST_METHOD HTTP method: GET OR POST GET
SERVER_NAME server hostname art.wallyzone.com
SERVER_PORT the port used by httpd 80
SERVER_PROTOCOL Which version of Httpd compliance HTTP/1.0
SERVER_SOFTWARE The name of the server software Apache/2.4
TOTAL_HITS total pages served by server (none)

Time Format Codes

Use these codes as values for <!--#config timefmt="..." --> to get the desired results when you echo the DATE_LOCAL. Once again, the values shown are for art.wallyzone.com.

Code Description Results
%a abbreviated weekday name Fri
%A full weekday name Friday
%b abbreviated month name Sep
%B full month name September
%c locale's appropriate date and time Fri Sep 22 03:13:10 2017
%C default date and time format 20
%d day of month - 01 to 31 22
%D date as %m/%d/%y 09/22/17
%e day of month - 1 to 31 22
%h abbreviated month name (alias for %b) Sep
%H hour - 00 to 23 03
%I hour - 01 to 12 03
%j day of year - 001 to 366 265
%m month of year - 01 to 12 09
%M minute - 00 to 59 13
%n insert a newline character
%p string containing AM or PM AM
%r time as %I:%M:%S %p 03:13:10 AM
%R time as %H:%M 03:13
%S second - 00 to 61 10
%t insert a tab character
%T time as %H:%M:%S 03:13:10
%U week number of year - 00 to 53 38
%w day of week - Sunday=0 5
%W week number of year - 00 to 53 38
%x Country-specific date format 09/22/17
%X Country-specific time format 03:13:10
%y 2 digit year - YY 17
%Y 4 digit year - YYYY 2017
%Z timezone name CDT

We learned last week about including other files with the include command:

<!--#include virtual="path_to_file" -->

The other commands are well documented at “The Worlds XSSI Cookbook” much better than I could; pay special attention to:

  • #config timefmt - to configure the homework footer date
  • #echo var - to get the date (and other variables)
  • #if expr, #elif expr, #else, #endif - the four commands used to craft your if/else programming for the contextual menu homework requirement
  • #set var with value - allow you to set your own variables if needed
  • The comparison operators and Boolean operations section is important to look over to use in your if/else programming.