Hacker1 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Everyone,

I am not a professional programmer, just a weekend hacker that likes to fool around with the code while learning.

I have an auction web site with a pre-made auction package. I take pride in making minor changes to suite me and would like to be able to Map new visitors to my site against a 300px by 200px world map.

My auction package has an Html main page but calls various Perl programs to outline and define the page.

I have a file called usersonline.txt that records visitors to my site in this format: 1322136524/59.150.117.190 The number to the left is a time code and the right is the url.

A timer is set to delete an inactive entry after every 15 minutes.

What I think I need is a Javascript to continuously monitor my usersonline.txt file for any changes because my main page display for Visitors = ? is only updated upon each page refresh.

When a change is detected, I would need to somehow convert the url to longitude and latitude coodinates and then convert those coordinates to x,y pixel coodinates for placing a red blinking .gif dot on my world map.

The blinking dot would stop blinking after 15 minutes and remain red to mark the visit.

That's about it. Any ideas? I am willing to take it one step at a time.

Thanks for any help.
Hacker1

Replies are listed 'Best First'.
Re: Mapping visitors to my site
by marto (Cardinal) on Nov 24, 2011 at 13:29 UTC

    You could investigate using Geo::IP (see a review of alternatives), matching lat/long for each address in usersonline.txt. Using Image::WorldMap to create a map with the access points plotted. You could refresh this using JavaScript/AJAX as required.

Re: Mapping visitors to my site
by ww (Archbishop) on Nov 24, 2011 at 14:44 UTC
    In my opinion, both choroba and marto are right... but you're still going to have problems.
    1. on a "300px by 200px world map" your "blinking .gif dot" is going to have to be nearly (or maybe more than) big enough to obliterate Texas, and portions of adjoining jurisidictions in order to be seen. I tested, (with my somewhat elderly and inefficient Mark I eyeballs) with a 5px black dot, on a commonly available world map after reducing the map to 300x200px.
    2. Attempts at mapping IPs to geography commonly results to mapping the location of an ISP, not of the user (with possible exception of those with a dedicated IP and a backbone to a big pipe)... and if the user is confined to a dialup link to the ISP, the location could be off by most of a continent.
    Not recommended!

    P.S. None of the above considers the users visting thru an anonymizer

Re: Mapping visitors to my site
by TJPride (Pilgrim) on Nov 24, 2011 at 14:21 UTC
    There are ways to get an estimate of people's lat/long based off their IP. However, converting that lat/long for a spherical Earth to a point on a rectangular map is very complicated. If you really want something like this, you are probably better off using a database and Google Maps.

    1) Users are logged to the database or file, and their IP is converted to lat/long up front using some sort of tool.

    2) AJAX is used to query the database for new entries since the last check (pass the most recent sequential ID that you have, database gives you everything after that)

    3) The entries are dynamically added to the Google Map using their API.

Re: Mapping visitors to my site
by choroba (Cardinal) on Nov 24, 2011 at 13:24 UTC
    What you call url is an IP address. I see no easy way, if any at all, to convert it to longitude and latitude.
Re: Mapping visitors to my site
by pvaldes (Chaplain) on Nov 25, 2011 at 11:59 UTC

    well, I know this could sound silly, but... Why you don't simply ask them?

    An example that should't be very complicated to do:

    http://gmt.soest.hawaii.edu/
Re: Mapping visitors to my site
by Anonymous Monk on Nov 25, 2011 at 16:33 UTC
    Just use google analytics - it shows a worldmap view of your web logs (countries with more hits are shaded darker, etc.)

      Thank you for all of your above replies.

      Cheers,
      Hacker1

      (ps) any way of being notified by email when someone answeres my question?