Re: [gopher] Someone out there with python skills want to help?
On 6.10.2010 12:07, daniel g wrote:
there must be more than one way to skin a cat.
is there a way u or anyone knows to get a gophermap to patch thru to the
os or to the gophermap so I can write in a hit counter?
1) Remove pygopherd, install gophernicus
2) Create a gophermap and in it have a line like this:
=/path/to/counter.sh "Woohoo! You're number " "."
Here's the (grossly over-engineered) counter.sh:
#!/bin/sh
##
## A simple visitor counter to use with gophermaps
##
## Usage: counter.sh <pre message> <post message>
##
# 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
COUNT="`cut -d' ' -f1 $FILE`"
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"
The reason I wrote Gophernicus was that none of the existing gopher
servers did what I wanted them to do. Not that they're bad software, I
just had different ideas.
- Kim
_______________________________________________
Gopher-Project mailing list
Gopher-Project@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/gopher-project
Reply to: