###################################################################### ## GOPHER HIT COUNTER FOR USE WITH GOPHERNICUS ## ###################################################################### # For use with the Gophernicus gopher server # # # # Save this file as counter.sh where your gophermap is stored. # # Change permissions of the file to be +X executable # # From a shell issue: chmod +x counter.sh # # Or use your FTP/SFTP client to make the file +X executable # # # # In your gophermap, include this line where you want the counter to # # to appear: # # =./counter.sh # # # ###################################################################### ###################################################################### #!/bin/sh # Figure out a safe file to keep our counter HASH=`echo "$SELECTOR" | md5sum | cut -d" " -f1` FILE=/var/tmp/gopher-counter-$HASH # Get count and the previous visitors IP address if [ -f $FILE ]; then COUNT="`cut -d' ' -f1 $FILE`" else COUNT="1" fi OLD_ADDR="`cut -d' ' -f2 $FILE`" # Increase counter only if the user is new if [ "$OLD_ADDR" != "$REMOTE_ADDR" ]; then COUNT=$(( COUNT + 1 )) echo "$COUNT $REMOTE_ADDR" > $FILE fi # Output counter message echo "$1$COUNT$2 People have visited this Gopher Hole" ###################################################################### ## END counter.sh ## ######################################################################