From the Blog

Posted by Jake DiMare at 3:59 pm

These last couple of days have been ridiculously busy but I want to keep blogging every weekday.

I’m developing a Flash screen takeover for one of my clients. They are using it to advertise the unveiling of their new site…so it’s not going to be some annoying ad for a hybrid car or anything. It should make sense to the user.

The fun part has been figuring out how to effectively layer flash units on top of one another. I will definitely share what I learn when this is done.


Continuing my series on web development stuff for hacks, this post includes the necessary information to detect a user’s IP address (as well as other variables) with SSI on an Apache server. SSI stands for Server Side Includes and they are directives which are placed in HTML pages and evaluated on the server while the pages are being served allowing for some dynamic content. For more information on SSI, Apache has a pretty good tutorial.

By the way, this post assumes you have control over your web server. If you do not check with your hosting company to see if they allow SSI. Also, there is something available for SSI on Windows servers but I don’t know much about it.

The first part of this exercise is to ensure the web server is configured properly. SSI is available on Apache servers with mod_include installed and enabled. For more information on mod_include visit the Apache web site for your version of Apache. In order to use SSI the following directive must be present in either the httpd.conf file or in an .htaccess file:

Options +Includes

The following directives must also be present in the httpd.conf file to tell Apache which files to parse for SSI:

AddType text/html .shtml
AddHandler server-parsed .shtml

I figured out where the last three directives were located by opening httpd.conf with pico and then used the Command W feature to search for Options, then SHTML. If these directives are already present but preceded by a # then simple remove the # (it comments out the line it precedes in httpd.conf).

On my server the Options directive was already configured as:

Options Indexes FollowSymLinks MultiViews

and the first time I made the mistake of adding a second line starting with Options

like this:

Options Indexes FollowSymLinks MultiViews
Options Includes

This DID NOT work, the web server would not restart. Instead, the correct syntax


Options Indexes FollowSymLinks MultiViews Includes

Finally, it is necessary to add the following line inside the virtual directory for the specific site which will be running the SSI files:

Options +Includes

In context this will look something like:

<VirtualHost *:80>
DocumentRoot /Library/WebServer/Documents/yoursite
Options +Includes

Once you have properly configured your server it is time to test this out. The simplest approach is to create an SHTM file, for instance index.shtml. Then place this code into the HEAD of your SHTML document:


// Set a variable IP with the IP address
var ip = ‘<!–#echo var=”REMOTE_ADDR”–>’;

//Then put it in an Alert box (or do anything else you want with it)
alert(“Your IP address is “+ip);


If everything has been done properly you will see this:


Inside the alert window it will say: “Your IP address is″ (of course, replace the 0′s with your IP address)

Some web coding fixes turn out to be so simple that there is not a lot of good direction on the topic easily found online. Ironically, what little information I could find all turned out to be overcomplicated and didn’t work. For a self-taught hack like me this means figuring it out for myself. To save you the trouble, in case you are anything like me, I will try to share what I learned. If you have questions please don’t hesitate to ask in the comments.

Recently a user requested a revision to a form with two fields that makes it possible to submit the form when the user enters a value into the second field and clicks ‘Enter’. As you may have noticed using Google, if a form has one field and the user hits enter while the focus is on the field, it will submit. However, if a form has more than one field, by default, it is necessary to use the submit button. Thankfully, we can use a form field attribute and a very simple function to get around this.

First, revise the form field with an attribute that will recognize the event called ‘onKeyUp=’.  There is also an attribute called ‘onKeyPress=’ but this can get sticky because Safari assigns the return key (above shift) and the enter key (on the numeric keypad)  different values onKeyPress.

Next, let’s assume the desired result of submitting the form is to call another function used to validate the form called ‘runForm()’. By simply adding onKeyUp=”runForm()” the form will submit. However, this is not finished. By simply stopping here the validation function will run regardless of which key the user hits. For obvious reasons, this will not do.

Instead, wrap the ‘runForm()’ function with another function, we’ll call ‘enterForm()’, containing an if statement that tests the event to determine which key the user hit. We’ll also need to pass the event to the function so it can test which key was hit. Thus, the entire form field will now look like this:

<input id=”Your_ID” name=”Your_Name value=”Your_Value” onKeyUp=”enterForm(event)”>

Finally, up in the header we need to create this ridiculously simple new function:

function enterForm(event) {
if(event.keyCode == 13) {
//alert(“You pressed enter”);

function enterForm(event) {

if(event.keyCode == 13) {




You may have deduced, the value of the return and the enter key onKeyUp is ’13′. What we have done is created a function called enterForm() and passed in the event variable. The function checks the keyCode value associated with the event using an if statement. If the keyCode value is 13 the function calls the separate validation function. If the keyCode value is anything but 13 the function does nothing.

Like I said earlier, if you have any questions about this please don’t hesitate to ask …I’ll do my best to answer.