Documentation
TOPSITES:  V1.1


System Requirements

  • Customizable to work with all operating systems - designed for unix
  • Customizable to work with all web servers - designed for apache/enterprise
  • If you are using NT you should have DAF installed
  • Perl 5
  • Crontab access
  • Sendmail

Preliminaries

  • Determine the path to PERL 5 on your web server host.  Note that some web hosting companies run both PERL 4 and PERL 5.  Make ABSOLUTELY sure you are not setting this up under PERL 4.  Ask your administrator if you are not sure.
  • Download the tarfile for this program and save it to your desktop.
  • Unpack the tar archive on your desktop using a program that unpacks UNIX TAR ARCHIVES. If you don't have such a program then download WINZIP FREE from SHAREWARE.COM
  • After you have unpacked the TAR archive you will have a collection of folders and files on your desktop.  Now you have to do some basic editing of each of these files (or at least some of them).  Use a text editor such as wordpad, notepad, BBEdit, simpletext, or teachtext to edit the files.  These are NOT WORD PROCESSOR DOCUMENTS they are just simple TEXT files so don't save them as word processor documents or save them with extentions such as .txt or they will NOT WORK.   Note that there may be a some files inside of folders which are "blank".   This is normal.

Preparing the CGI scripts

Define Path To PERL 5

The first step is to open up each and every file that has a .cgi extention and edit line number one of each script.  Each of the cgi scripts is written in perl 5. For your scripts to run they must know where perl 5 is installed on your web server. The path to perl 5 is defined to a cgi script in the first line of the file. In each of the cgi scripts the first line of code looks something like this:

#!/usr/bin/perl

If the path to perl 5 on your web server is different from /usr/bin/perl you must edit the first line of each cgi script to reflect the correct path. If the path to perl 5 is the same no changes are necessary. If you do not know the path to perl 5 ask the webmaster or system administrator at your server site.  

Configure the .cgi files

configure.cgi

This is the entire cgi.  There are several variables to edit, all of which should be pretty straightforward.

  • $localurl = yourdomain name
  • $mailprogram= path to sendmail
  • $adminemail = Your email address (include backslash)
  • $sitecode = name of your topsite program (no spaces - must match to name of agents program if you are using agents of fortune)
  • $sitedepth = number of links in the topsites list
  • $threshold = number of hits required to display admin statistics
  • $cgidirectory = FULL path to your cgi-bin/topsites directory
  • $tophtml = FULL path to top.html
  • $bottomhtml = FULL path to bottom.html
  • $topsitehtml = FULL path to topsite.html
  • $clickthroughurl = URL to clickme.html
  • $topsiteurl = URL to the topsite.html results
  • $exiturl = URL of exit.cgi
  • $cgiurl = URL to the cgi-bin/topsites directory (no trailing slash)
  • $webmasterurl = URL of the webmaster login area

topsites.cgi

the lines

require "/home/superscripts/topsites/cgibin/configure.cgi";
&configure;

must be edited to reflect the ABSOLUTE path to configure.cgi on your system

Upload Your Edited CGI and Data Files

  • Upload all of the cgi files (.cgi) into your cgi-bin/topsites directory
  • Upload top.html, bottom.html, and thankyou.html into your cgi-bin/topsites/data directory

File Access Permissions

File access permissions must be set correctly for this program to run.  You must set the access permissions for each of these files.  Set all the .cgi and .pl files to 755.   Set the data directory contents to 777 and the logs directory to 777.  Set topsites.html to 777

Using Crontab to Generate Site List

Set crontab to execute topsites.cgi once per day.  Note that crontab executables must always use FULL PATHS whenever they are implemented in the cgi.  This is why all the path variables in configure.cgi use FULL PATHS and NOT RELATIVE PATHS.  Also the &require statements must use FULL paths inside the topsites.cgi file which is called from crontab.  topsites.cgi will create the file topsites.html which is the list of your top referers. 

You can also generate the list manually from the command line (telnet) with

perl topsites.cgi

Viewing Topsites with SSI

You can use this list specifically or insert the data from this page into your home page using server sides includes.  If you want to insert the topsite data via SSI use the following command:

<!--#EXEC CGI="/cgi-bin/topsites/insert.pl" -->

note that some systems may not accept the .pl extension for SSI so you may have to change it to .cgi.  Also you may have to name the page using the SSI command with a .shtml suffix instead of .htm or .html for the SSI command to work.  If you are inserting the results on another page then set the $topsiteurl inside of configure.cgi to the page you have inserted the results into and NOT the url to the topsites.html page itself.

Adding headers/footers to the Topsites Results

If you are going to simply use the actual topsites.html page generated by crontab for the page to display rather than using SSI to insert the data you can add html headers and footers to the page by editing the /cgi-bin/data/top.html (header) and /cgi-bin/data/bottom.htlm (footer).  Just cut and past whatever you want into these files.  The header goes before the list and the footer appears after the list.

Notes on Interfacing to Agents of Fortune

Make sure if you plan to integrate this with AGENTS OF FORTUNE that you have set the name of your topsites program to the same name as your affiliates program inside of configure.cgi.  Also make sure you set and read from the same IP/port as this uses cookies to track.