Follow us on Twitter!
Things are more like they are now than they have ever been before. - Dwight D. Eisenhower
Thursday, April 24, 2014
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Members Online
Total Online: 27
Guests Online: 24
Members Online: 3

Registered Members: 82889
Newest Member: Geriztul
Latest Articles

SSI (Server Side Includes)

Arrow Image using SSI

Alright, SSI is short for Server Side Includes and is a type of HTML comment that directs the Web server to dynamically generate data for the Web page upon request.

SSI directives have the following syntax:

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

Basic SSI commands:

Today\'s date:

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

The echo element just spits out the value of a variable. There are a number of standard variables, which include the whole set of environment variables that are available to CGI programs. Also, you can define your own variables with the set element.

If you don\'t like the format in which the date gets printed, you can use the config element, with a timefmt attribute, to modify that formatting.

<!--#config timefmt=\"%A %B %d, %Y\" -->
Today is <!--#echo var=\"DATE_LOCAL\" -->

Modification date of the file:

This document last modified <!--#flastmod file=\"index.html\" -->

This element is also subject to timefmt format configurations.
Including the results of a CGI program

to output the results of a CGI program, such as everybody\'s favorite, or a hit counter.\'\'

<!--#include virtual=\"/cgi-bin/\" -->

Find out when the document was last modified:

The following code, placed in your HTML document will put a time stamp on your page.

<!--#config timefmt=\"%A %B %d, %Y\" -->
This file last modified <!--#flastmod file=\"ssi.shtml\" -->

Note: change ssi.shtml to the actual file name.

In most cases though you going to have to use the last modified command to view its latest modification date:
<!--#config timefmt=\"%D\" -->
This file last modified <!--#echo var=\"LAST_MODIFIED\" -->

If you are a person hosting a website with like 5 pages then this SSI command will make it easier on your footers if you want a the same look for all thoses pages. Using an include file for a header or a footer can reduce the annoyance of these updates. You just have to make one footer file, and then include it into each page with the include SSI command. The file attribute is a file path that the CMD will find for you.

<!--#include virtual=\"/footer.html\" -->

What other things you can configure:

In addition to being able to config the time format, you can also config two other things.

Usually, when something goes wrong with your SSI directive, you get the message

[an error occurred while processing this directive]

If you want to change that message to something else, you can do so with the errmsg attribute to the config element:

<!--#config errmsg=\"[It appears that you don\'t know how to use SSI]\" -->

SSI Executing Commands:
You can actually have SSI execute a command using the shell /bin/sh, to be precise or the DOS shell, if you\'re on Win32.

This will give you a directory listing:

<!--#exec cmd=\"ls\" -->

or, on Windows

<!--#exec cmd=\"dir\" -->

You may notice some strange formatting with this directive on Windows, because the output from dir contains the string <dir>\' in it which will confuses browsers.

Note: that this feature is exceedingly dangerous and if your a web master disable it.

Advanced SSI techniques

Instead of giving out somekind of content SSI and Apache give you the option of setting variables.

Note: Codes in this article are only available to you if you are running Apache 1.2 or later.

Setting variables:
Using the set directive, you can set variables for later use and the cmd looks like this:
<!--#set var=\"name\" value=\"Rich\" -->

Give values to your variables:
[color=\"*0ff00\"]!--#set var=\"modified\" value=\"$LAST_MODIFIED\" -->[/
Note: To put a literal dollar sign into the value of your variable, you need to escape the dollar sign with a backslash.
<!--#set var=\"cost\" value=\"\\$100\" -->

If you want to put a variable in the midst of a longer string to reduce confusion between simliar charectors, place the name of the variable in braces.
<!--#set var=\"date\" value=\"${DATE_LOCAL}_${DATE_GMT}\" -->

Conditional expres<i></i>sions:

This allows you to effectively generate multiple logical pages out of one actual page.
The structure of this conditional creation is:

<!--#if expr=\"test_condition\" -->
<!--#elif expr=\"test_condition\" -->
<!--#else -->
<!--#endif -->

In your configuration file, you could put the following line to see comparison operators technic

BrowserMatchNoCase macintosh Mac
BrowserMatchNoCase MSIE InternetExplorer

This will set environment variables Mac and Internet Explorer to true only if the client is running Internet Explorer on a Macintosh.

Then, in your SSI-enabled document, you might do the following:

<!--#if expr=\"${Mac} && ${InternetExplorer}\" -->
Apologetic text goes here
<!--#else -->
Cool JavaScript code goes here
<!--#endif -->


system_meltdownon November 19 2006 - 16:43:21
Maybe he published it there too...
system_meltdownon November 19 2006 - 16:44:32
Yea he did:
wolfmankurdon November 19 2006 - 20:26:30
well looks awefully like
only_samuraion November 20 2006 - 15:12:38
has anyone tried this? I cant seem to get this to work. I actually copied and pasted your code into a HTML doc and it did absolutely nothing.
Post Comment


You must have completed the challenge Basic 1 and have 100 points or more, to be able to post.