Tools

Here are some tools you may wish to use. Help yourself. No warranty.

In general, consider this software to be beta quality. That is, it works OK for me, but it isn't as forgiving of errors and configuration variations as it should be.

If you find bugs, and fix them yourself, please send mail to me and I may be able to incorporate your fix.

My Java Tools have their own page. Look there for Globe, I Ching, Password Generator, and Pie Chart applets.

Directory

Web Tools

Webtrax: Analyze and report on a web server log.

This program looks over a day's logs from a web server and prints a pretty report. (This program was originally by John Callender, who has a book from O'Reilly called  Perl for Web Site Management with lots of useful tools.) I modified it thoroughly, adding the histograms, history, and many bug fixes and improvements, and rewrote the HTML output to link to a help file for Webtrax and to display Java pie charts. Paul Schmidt contributed several features. See the history comments at the top of the program for details. Feel free to hack this up however you like. Let me know if you find any bugs.

webtrax.pl (04/10/06) Version 23
Perl program: webtrax.pl will process the file httpd_access.0 and write the file report.txt. Several other files are produced that are used by subsequent runs:
  • summary.txt has one line for each of the last 30 days
  • cumtld.hit lists hits by top level domain
  • cumpage.hit lists hits by page
webtrax.rc (04/10/06)
Sample configuration file for webtrax.
logextractor (04/10/06)
Simple program to pre-process and extract log files. Instructions in the help file.

To install webtrax, you can copy a tarfile (24K) and follow the instructions in the help file (11/28/07, 99K, 6 pictures).

The way I use webtrax is to have a cron job run it once a day.

headpage.cgi: Generate HTML pages on the fly

headpage.cgi is a Perl program that can be called as a CGI from a web server. It reads a template and returns a HTML page that will be sent to a web browser. The template can return literal text, or can do various computations.

It is useful for setting up a page that changes at random on each load, or for setting up a page that is different depending on the browser or accessing computer.

Usage:

  1. Set this cgi file up so that the server interprets it as a CGI.
    • For some servers, you can name it index.cgi
    • If you need to name it index.html or something because people have bookmarked it, and your server uses NCSA conventions, you can add a line to your .htaccess that says
         AddType application/x-httpd-cgi index.html
      
    • change the mode of this file to 710
    • place the file in your public_html directory, or wherever your web server looks for CGI files.
  2. Create a template, say headpage.txt describing your output. See below for format.
    • Put it in the same directory as the CGI.
    • Secure it 740
  3. If your script references other files, put them in the same directory, and secure them 740.

The format of the template file is as follows:

:anything       prints anything
print:anything  prints anything
raw:file        includes file without parsing
include:file    includes file with parsing
today:xxx       prints "xxx: dd mmm yyyy hh:mm"
fileinfo:fff    prints "(mm/dd/yy xxK)" 
                   with the date mod & size for fff
moddate:fff:nn  prints "nn: dd mmm yyyy hh:mm" 
                   with the date mod for file fff
ranpick:fff     outputs one random line from file fff
ranpickpic:fff:pre:post     outputs random IMG tag from fff
lookup:fff:xxx:yy  finds xxx: in fff and prints rest, else yy
allvars:        outputs all environment variables
varmatch:var:value:file  includes file if var =~ value
setcookie:name:value     sets a cookie
cookieval:name  outputs the value of cookie "name"
exit:           exits (useful in a nested structure)

If you invoke headpage as

    <a href="headpage.cgi?textfile">
     

Then the template will come from textfile. If no query string is specified, the template will be read from headpage.txt.

Example: Here is a simple template that sets up a button the user can click to be sent to a randomly chosen place from a list. If it is invoked from a particular host, it adds a special message; it also displays all the environment variables as an aid to debugging.

    :<html><head><title>Jump page</title></head><body>
    :<h1>Mystery Jump</h1>
    moddate:jumplist:Updated
    :<p>
    ranpick:jumplist.txt
    :Click here for a mystery jump</a>
    :<p>
    varmatch:REMOTE_HOST:george.vip.best.com:headpage1.txt
    :<p>
    allvars:
    :</body></html>

Where each line in jumplist.txt is of the form

    <a href="somewhere"> 

And headpage1.txt contains

    :<font size=4 color=red>Hi George</font>

If a page sets a cookie, subsequent requests for the page will have the cookie in the HTTP_COOKIE variable, available for testing with varmatch or display with cookieval. The setcookie lines must come before anything is printed.

cal.cgi: Display a calendar, loading boxes from a control file

cal.cgi is a Perl program that can be called as a CGI from a web server. It returns a HTML page that will be sent to a web browser. The page displays a calendar for one month as an HTML table. One or more control files specifies the layout and contents of the calendar. Try it out: this calendar came from the control file calinput.txt, which in turn includes holidays.txt. The control files may specify any number of lines that precede and follow the calendar, so the resulting web page can include any other HTML items you specify, from calendar pictures to search engine links.

If you invoke cal.cgi as

    <a href="cal.cgi?file">

Then the control file will come from file. If no query string is specified, the template will be read from calinput.txt.

The control file contains lines in the following format:

*                 Comment
month nn          Print calendar for month nn (1-12)
year nn           Print calendar for year nn (e.g. 99 or 1999)
title restofline  Calendar title
head restofline   Any number of these, precede calendar
foot restofline   Any number of these, follow calendar
mm/dd/yy text     Put text in box for dd if it's mm in yy
mm/dd text        Put text in box for dd if it's mm
color mm/dd col   Color the box for dd "col"
every thursday[+1] in Nov text   Put text in box for date
first thursday[+1] in Nov text   Put text in box for date
second thursday[+1] in Nov text  Put text in box for date
third thursday[+1] in Nov text   Put text in box for date
fourth thursday[+1] in Nov text  Put text in box for date
fifth thursday[+1] in Nov text   Put text in box for date
last thursday[+1] in Nov text    Put text in box for date
include fn        Process fn as input (holidays etc)
boxwidth nn       Set box width (15)
boxheight nn      Set box height (4)
stylesheet name   Use specified style sheet instead of the builtin one

The text placed in the boxes can contain HTML, such as hyperlinks. The program tries to make all boxes the same size, but they'll expand to hold the input provided if necessary, and graphics in a box will confuse the sizing. The day number has class="daynumber", and the text has class="boxcontent".

Security Tools

gpw: Password Generator

This package generates pronounceable passwords. It uses the statistics of three-letter combinations (trigraphs) taken from whatever dictionaries you feed it. Thus pronouceability may differ from language to language. It is based on the ideas in Morrie Gasser's password generator for Multics, and Dan Edwards's generator for CTSS.  FIPS Standard 181 describes a similar digraph-based generator, derived from Gasser's. (My programs are in C++ but are trivially convertible to C, just remove the word const.)

05/29/02: Minor changes to gpw.Makefile to compile under FreeBSD and Panther with gcc 3.3.
01/07/06: Made minor changes to gpw.C and loadtris.C to compile under with gcc 4.0.

gpw.C
Generate passwords. Execute
    gpw [npasswords] [passwordlenth]

To generate pronounceable passwords. Default is 10 passwords of length 8.

gpw.C #includes a big table of constants from trigram.h giving frequencies.

loadtris.C
Generates trigram.h from your dictionaries.
gpw.Makefile
Compiles gpw for your system.

The same password generator in Java and Javascript is available online.

01/08/06