The Beauty of SSI - Part 2

Filed Under Web Developer

Since there was a part 1, it is inevitable there might be a part 2, as well. *smile* A few weeks ago, I stumbled upon some SSI code that I think is quite useful and wanted to share with my readers. I had not previously been aware of this capability with SSI. Like ASP, PHP and other scripting languages, SSI has its own tags that you can use to generate useful information for yourself and the website visitor.

Server Side Include (SSI) Tags

Displays current date and time:

CODE:

The current date and time is <!–#config timefmt=”%A, %B %d, %Y, %I:%M %p”–> <!–#echo var=”DATE_LOCAL” –>.

OUTPUT:

The current date and time is Monday, October 15, 2007, 07:39 AM.

Tell the User what browser they are using (conditional):

CODE:

You are using
<!–#if expr=”$HTTP_USER_AGENT = /Opera/”–>
the Opera browser.
<!–#elif expr=”$HTTP_USER_AGENT = /Firefox/”–>
the Firefox browser.
<!–#elif expr=”$HTTP_USER_AGENT = /MSIE/”–>
the Internet Explorer browser.
<!–#else –>
a browser different than most people.
<!–#endif –>

OUTPUT:

You are using the [NAMED] browser.


Identify the User’s IP Address:

CODE:

Your IP Address is <!–#echo var=”REMOTE_ADDR” –>.

OUTPUT:

Your IP Address is 64.178.113.79.


Indicate Date a Page was Last Modified:

CODE:

This page was last modified on
<!–#config timefmt=”%A, %B %d, %Y at %I:%M:%S %p”–>
<!–#echo var=”LAST_MODIFIED”–>.

OUTPUT:

This page was last modified on Saturday, September 29, 2007 at 09:39:06 PM.

A few more useful tags:

Document File Name: <!–#echo var=”DOCUMENT_NAME”–>
Document’s URL: <!–#echo var=”DOCUMENT_URI”–>
Referring Page: <!–#echo var=”HTTP_REFERER”–>

If you want to find out more about SSI tags, do a Google search for SSI Tags. There is a wealth of information available online.


Comments

Leave a Reply

You must be logged in to post a comment.