So how does the script work? The user creates a file in the same directory as the url that
he wants to have a counter for. This file is called
<H4>Visitor Number : <IMG SRC="http://www.cms.dmu.ac.uk/cgi-bin/webcounter?url=/~williams/index.html&red=255&green=255&blue=0"></H4>
The values of red, green and blue can be changed to make the gif look more sexy(?).
Here is my script. (It was knocked up quite quickly):
Finally, the user put some HTML similar to this on the actual page to have the counter:
#! /bin/ksh
cat <<!
Content-type: image/gif
Last-modified: `date`
!
STUFF=`echo $QUERY_STRING | sed -e '
1,$ s@%2F@/@g
1,$ s@%7E@~@g
'`
OLDIFS=$IFS
IFS="=&"
set $STUFF
if [ $# -ne 8 ]
then
exit 1
fi
IFS=$OLDIFS
URL=$2
RED=$4
GREEN=$6
BLUE=$8
tmp=${URL#*/}
user=${tmp%%/*}
base=${tmp#*${user}}
userpath=`eval "echo ${user}"`
HTMLPATH=${userpath}/public_html/${base}
if [ ! -f "${HTMLPATH}.counter" -o ! -r "${HTMLPATH}.counter" -o ! -w "${HTMLPATH}.counter" ]
then
cat ~williams/public_html/cgi-bin/wrongrights.gif
exit 1
fi
old=$(<${HTMLPATH}.counter)
((new=old+1))
echo $new > ${HTMLPATH}.counter
randfile=/tmp/counter.${RANDOM}.gif
~williams/public_html/cgi-bin/makegifnum $new $randfile $RED $GREEN $BLUE
cat $randfile
rm $randfile
![[AUG]](/~williams/pictures/AUG.gif)