Sources for World Map stat counter

Okay, as promised, here is the sources to the worldmap stat counter.

To use the stat, you must have the following installed on the webhost:
1. GD library (usually called "gd" or "libgd")
2. netpbm tools (usually called "netpbm") - this gives you tools like pnmtojpeg, jpegtopnm, etc
3. "Fly" - this is a command line interface to GD, from here:

How to use it
1. Extract the archive to a directory.

2. Get the's GeoIP Lite City CSV database from here:

3. Convert those CSV databases to binary databases like this:

./ /path/to/geoiplite/block-database.csv /path/to/geoiplite/location.csv

You will get ipinfo.dat and locinfo.dat in the current directory.

4. Copy these two 'dat' files to your cgi-bin directory, along with ipgeocode and and map.png

5. expects that its standard input is feed with IP addresses, one per line. It will produce a JPEG file on standard output, having all the locations of those IP addresses marked.

6. You will need to create a CGI script which calls and feed it with the IP address, as well as returning a proper CGI header etc. For sjppblog, this script would do:

echo -ne "Content-Type: image/jpeg\r\n"
echo -ne "Content-Disposition: inline; filename=\"stat.jpg\"\r\n"
echo -ne "\r\n"
awk -F"|"  '{print $1}' /path/to/your/sjpplog/online.ppl.uo 2> /dev/null | sort | uniq | ./

That's all, you're good to go!

Some notes:
1. map.png is a PNG file converted from the original JPEG image here: You can change the image, just make sure it is in PNG format and modify the dimensions in with the new image's.

2. The archive contains 32-bit static programs. This will work on all version of x86 Linuxes (both 32 an 64-bit), so you don't need to re-compile it (although you can if you want - all the sources are included).

3. Fly unfortunately isn't included in most distributions so you have to compile it yourself. I would have included a compiled version in the archive except that in addition to libgd it also depends on other large system libs like libpng, libjpeg, libfreetype etc. It is used in the final rendering of the "marks" in the map image; if you don't like to use it you can modify to use other command-line tools like imagemagick, graphicsmagic, gmic, etc.

4. The GeoIP Lite database is courtesy of The conversion is purely for performance reasons, one can do exactly the same thing using awk and grep but the speed is much slower (more than 100 times slower).

5. As usual, the sources are provided in terms of GNU GPL Version 3 license.

Posted on 14 Jun 2013, 23:41 - Categories: General
Edit - Delete


Posted on 27 Mar 2016, 09:34 by 01micko
"Alternative map and perl script"
As some readers may know I have the map up at the new Puppy Linux Blog.

However I have made a few changes.
  • dot colour

  • different map

  • perl script to generate the image (not in production at the moment)

  • The dot colour is elementary but the map is best if it is exactly the same aspect ratio. I have a package for download.

    The package includes the perl script, a map pre cropped and resized plus the original map I found on the web (it accounts for the 1MB size of the package!) and a Makefile for the 'fly' executable using gcc -static.

    The perl script was just an exercise. James' original shell version does actually run a tad faster. However, I am a perl novice so any perl gurus might be able to speed it up. It is in production at a testing site and the speed difference is not really noticeable. If you run pplog (or derivative) it should be a drop in replacement.


    Posted on 27 Mar 2016, 09:46 by 01micko
    "Static Fly"
    I have uploaded another package including 32 bit static 'fly' exec (1183K) - runs in 64 bit. I should have included it in the first one!

    Posted on 27 Mar 2016, 16:19 by 01micko
    "One more thing"
    The map requires credit to the author like so:
    Map credit to Daniel R. Strebe 15 August 2011.

    See (cc by-sa 3.0)

    Posted on 27 Mar 2016, 21:53 by jamesbond
    "RE: static fly"
    To clarify: the binary of "fly" that Mick included in his package above is a (x86) 32-bit static binary that will run in both 32-bit and 64-bit systems.

    Thank you Mick for building this static binary and the alternative scripts.

    Add Comment

    Show Smilies
    Security Code 9625781
    Mascot of Fatdog64
    Password (to protect your identity)