Create Web Page Footer

See the download page to obtain this program

Description

This script prints a customisable web page footer and also updates a count of page accesses. This page is an example of what the script does. A fair amount of customisation will be necessary, though this should be reasonably obvious even for a non-Perl programmer.

The script makes uses of the #exec feature of a web server like Apache to execute a program like webfoot when an HTML page is served. An Apache server may require a file using #exec to be named '*.shtml' (server-side HTML). Alternatively, Apache may be configured to permit #exec if a '*.html' file has the execute bit set. Finally, Apache may be configured to allow #exec in all '*.html' files.

The log file lists page names separated by a tab from page access counts:

  home/general/basic	5
  home/general/campus	3

Here, home indicates the root of the user's web pages. It is likely that the page access counts will be imported into a spreadsheet for further processing.

Options

The command line options are:

-a
output count of accesses to this page
-d
output last modification date of a page; the script does this by default without selection of this option
-n
output normal size footer; the script does this by default without selection of this option
-s
output small size footer; this is an alternative to -n
-u
output URL of a page; the script does this by default without selection of this option

Default actions can be turned off by preceding an option with `+', e.g. `+u' suppresses the default output of a URL.

Usage

The script is called using the #exec feature of a web server like Apache:

  <!--#exec cmd="/home/me/bin/webfoot home/somedir/pagename"-->

The first part of this command is the directory where webfoot was installed. The options described earlier may be given after this. The second part is the name of the page that is being accessed. Here, home means the user's home web directory. For example, for the author this is /home/kjt/www which corresponds to http://www.cs.stir.ac.uk/~kjt/. The remainder of the path identifies the file; note that there is no `.html' suffix. To create a footer for /home/kjt/www/general/links.html, the author would give the parameter home/general/links in the call.

The following result codes are generated: 0 (success), 1 (could not open log file), 2 (could not close log file), 3 (could not lock log file), 4 (could not unlock log file). The script uses file locking to prevent the page count file from being simultaneously updated. Although this works for the author, the Perl manual warns that this may not be successful on an NFS-mounted file system.

The initial part of the script sets up a number of values that will certainly need to be customised: the user's home directory ($home), the user's home web page directory ($web_home), the user's home web page URL ($url_home), the file of page counts ($logfile), and a user directory for images ($img_home). The script generates references to images for email, web address and page search. Sample images are supplied with the distribution. (Some of these are borrowed from image collections available on the net.)

You will probably wish to re-program the appearance of the footer. The script also handles various page aliases (e.g.\ $url_cgi and $url_research); these are specific to the author and will certainly need to be changed.

To check that the script is working correctly, call it from the command line with appropriate parameters. The result will be printed to standard output.

Change the first line of the script according to where Perl is located. Although tested with Perl5, the script may work with only minor changes for Perl4.

Licence

webfoot is free software, distributed under the GNU Public License Version 2. You may re-distribute this software provided you preserve this README file. The contents of this package may be used freely for non-commercial purposes provided this README file and copyright notices are retained. Copyright remains with the author. No warranties are given as to the accuracy or suitability of this package.

History

First public version Ken Turner, 22nd November 1998


Up one level to Web Utilities

Web Ken Turner Home   Email    Search Search Web Pages

Last Update: 15th July 2006
URL: https://www.cs.stir.ac.uk/~kjt/software/web/webfoot.html