Home > Web Design > Perl > RushHour 1.0 Search this site:   
  Janis Kenderdine's Home on the Web  

Fifer’s Web site — on the Web since 1995!

 
My Web Sites | How’d You Do That? | Screen Design & Layout | My Perl Scripts

RushHour 1.0

Disclaimer

Feel free to use, copy, distribute, and change - but you use it all at your own risk. I take no responsibility for any issues that might arise through use of any of my code.

Hopefully you’ll find something useful in here. If you have any questions, feel free to e-mail me and maybe I’ll know the answer.

RushHour 1.0 Posted: 13 February 2005

I know there's a ton of web-traffic analysis and counters out there, even in perl - but many of them required a stupid logo be on your page, or you couldn't change anything in the code, etc. - so I decided to write my own. Although it would be nice to find out how many people use my code, I'm not going to require that they ugly-up their site with an icon or broken image links. It's exactly this reason that I ultimately decided to write my own script to do more or less the same stuff. The counter/info-collector is fairly small in load-up size, and is completely hidden/invisible on the page. The reports have basic info and information the average home-user web-master is concerned with. I mean, how many of us really care about some of the granular info we're given? We just want to see what people are looking for when they find our site or pages, and how many came through, right?

Also, since my Web site is hosted on a bigger server, programs that used access logs were overkill, and to be frank, useless - because I couldn't get the information JUST pertaining to my pages. I had the whole server! I was pleased to find out that aside from the main server defaults, that my site seemed to be one of the most popular on the site, but still - it didn't give me the useful info that I wanted. So - this script does not use server access-logs. It works just like an invisible counter. Maybe eventually I'll put in a visible counter option, but for now, this is just for tallying web traffic, and traffic analysis.

Version 1.0 is pretty simple - it just gives some basic info like ip address of visitors, their user-agent info, pages they visited (and at what time), keywords used and referral pages (if available), and attempts to break out the obvious web-crawlers and bots from the "useful" information. There's a graph at the top that shows you the popularity of various pages per day or by month. I haven't really made a year option yet, as I think it would be a bit too much information for one page, and to be honest, I haven't collected enough data to test year-information. Maybe in a future version. But right now, this is a simple thing to count unique visitors and graph page popularity.

Please visit back when I get more features posted in newer versions.

Installation (Fix)

  • Server-side includes need to be enabled on your server
  • Try dumping this ssi into your webpage and make sure it returns a value: <!--#echo var="REQUEST_URI" -->
  • Save the script to your cgi-enabled directory: perlcrumbs1.0.tar
  • tar xvfp perlcrumbs1.0.tar to decompress
  • Make sure the opening #! is correct for your system
  • Make sure the permissions are set to read and execute, or do a chmod 755 perlcrumbs1.0.cgi

Customizing the script

Start customizing things in the code:

#############CUSTOMIZE HERE ###############

## Uncomment this if your home directory is http://www.yourdomain.com/ (the site root)
## and give the home directory a displayname
#$homedir = "Home";

This one's pretty self-explanatory. Is your site root the same as the domain-name route? (http://www.yourdomain.com/) Or is it a subdirectory, like mine? (http://www.fifedrum.org/fifer/)

If it's the same as the domain-name, then delete the # at the beginning of the $homedir = "Home"; line so it reads:

Example:

#############CUSTOMIZE HERE ###############

## Uncomment this if your home directory is http://www.yourdomain.com/ (the site root)
## and give the home directory a displayname
$homedir = "Home";


## Seperator you want to use between directories
$dirseperator = " &gt; ";

This is where you determine what you want to use to seperate the directories with. Do you want a > symbol? The ascii code for this is &gt; - or if you wanted to use a slash, put in a slash, or a vertical bar | like in the example here.

Example:

## Seperator you want to use between directories
$dirseperator = " | ";


## Uncomment this and apply any classes or id's that need to go within the <a href> tag
#$classid = 'class="menu" id="whatever"';

If you have a css style applied to hyper-links (within the <a href> tag), assign its value here and delete the # at the beginning of the line. If you don't have anything, just leave it commented out.

Example:

## Uncomment this and apply any classes or id's that need to go within the <a href> tag
$classid = 'class="highlight"';


## You must have a "directoryname, displayname" pair for each
## directory, or it won't show up.
%sitemap = (fifer, "Home",
            news, "News",
            perl, "Perl",
            docs, "Documents",
            misc, "Miscellaneous");

################### STOP ##################

This is where you assign names to the directories. The directory names in the directory hierarchy on your server is the left element in the pair, and your "english" display-name is the right element. It doesn't matter what order these are in, or how they pertain to the directory structure. Don't use mydir/special, "Special Directory" to skip over mydir. Just don't make mydir a pair, (but make a special, "Special Directory" pair) and it will skip over naming it.


Good! You should be done customizing the script, and should be ready to stick it on a page!

Including the script on pages

On each page, put the following line where you want the breadcrumbs to show up:

<!--#include virtual="/cgi-bin/perlcrumbs1.0.cgi" --> (pointing to the actual location of the script, of course)

Make sure there's a space between the quotes and the --> or it won't work on some (all?) machines.

If you have a name for the page you're on, put that after the include directive so it reads like:

<!--#include virtual="/cgi-bin/perlcrumbs1.0.cgi" --> This Page's Name

If you have your breadcrumbs in an include file that's repeated on all pages, you can pass the individual page names to it by putting an ssi directive on each individual page:

<!--#set var="pagename" value="This is the Awesome Page" -->

Then in the include, put in:

<!--#include virtual="/cgi-bin/perlcrumbs1.0.cgi" --><!--#if expr="${pagename}"--><!--#echo var="pagename" --><!--#endif -->

It should show something like:

Home > Web Design > Perl > This is the Awesome Page

If you have any problems, e-mail me.