All things geolocation ...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • borked
    Totally Borked
    • Feb 2005
    • 6284

    #1

    All things geolocation ...

    A few threads have recently come up (again) about geolocation ( geoip ), so I thought I'd give a few pointers and an example of how easy it is.

    First off, maxmind's geoip database is probably the best option as it's free.

    However, it requires installation, which isn't easy and if you want to query specific IP addresses, you can't use the apache module. So you end up using the PHP or Perl modules, which are *really* frikken slow.

    So, for those not wanting to go that route, geoplugin.com has a webservice that uses Maxmind's data (the free database for the webservice as maxmind refuse to allow their paid database for direct external IP lookups).

    This webservice is a bit better than simply using the maxmind geoip db as it also returns data on nearby places to a location and a currency converter.

    To use geoplugin, there's a really easy to use PHP class, that even the brain-dead person can add to their pages.

    Someone recently asked about GeoIP adverts for their dating site.
    If anyone wants the script that displays the image below (you can choose your own images, but these ones are public domain and royalty-free images), just give me a shout and I'll send it on.

    An example geo-localised advert displaying your city (as seen by maxmind's geoip db) and places around you.


    [/PublicServiceAnnouncement]

    For coding work - hit me up on andy // borkedcoder // com
    (consider figuring out the email as test #1)



    All models are wrong, but some are useful. George E.P. Box. p202
  • borked
    Totally Borked
    • Feb 2005
    • 6284

    #2
    And if I find anyone hotlinking that gif, I'll come and cut your nuts off, cos I said I'd give you the script for free, ya lazy bandwidth-hogging freeloaders

    For coding work - hit me up on andy // borkedcoder // com
    (consider figuring out the email as test #1)



    All models are wrong, but some are useful. George E.P. Box. p202

    Comment

    • Dopy
      Confirmed User
      • Feb 2001
      • 1572

      #3
      Great for me, its only 1500 KM off position.

      Comment

      • rowan
        Too lazy to set a custom title
        • Mar 2002
        • 17393

        #4
        Never seen geo dating ads do surrounding areas, which seems like something obvious... guess someone has to think of it first! :D How do you determine the surrounding cities, is that part of the maxmind db too?

        (I don't recognise any of the names in your sample because my geo IP loc pretty much always shows me in another state)

        Comment

        • borked
          Totally Borked
          • Feb 2005
          • 6284

          #5
          Originally posted by Dopy
          Great for me, its only 1500 KM off position.
          what is it saying? I think I have image caching on

          For coding work - hit me up on andy // borkedcoder // com
          (consider figuring out the email as test #1)



          All models are wrong, but some are useful. George E.P. Box. p202

          Comment

          • Dopy
            Confirmed User
            • Feb 2001
            • 1572

            #6
            Originally posted by borked
            what is it saying? I think I have image caching on

            Don't worry lol my connection always shows the Spanish mainland not my real offshore location.

            Comment

            • borked
              Totally Borked
              • Feb 2005
              • 6284

              #7
              Originally posted by rowan
              Never seen geo dating ads do surrounding areas, which seems like something obvious... guess someone has to think of it first! :D How do you determine the surrounding cities, is that part of the maxmind db too?

              (I don't recognise any of the names in your sample because my geo IP loc pretty much always shows me in another state)
              Surrounding areas are calculated from latitude/longitude parameters of the visitor IP - complicated maths cos the world isn't flat ;)
              $theta = $lon1 - $lon2;
              $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
              $dist = acos($dist);
              $dist = rad2deg($dist);
              $miles = $dist * 60 * 1.1515;
              $unit = strtoupper($unit);

              Surrounding areas can be turned off in that add image:

              Nearby ON: and with Nearby OFF:
              Last edited by borked; 12-07-2008, 07:32 AM.

              For coding work - hit me up on andy // borkedcoder // com
              (consider figuring out the email as test #1)



              All models are wrong, but some are useful. George E.P. Box. p202

              Comment

              • Davy
                Confirmed User
                • Apr 2006
                • 4323

                #8
                Running your php code on my server?
                I don't think so... no thanks.
                ---
                ICQ 14-76-98 <-- I don't use this at all

                Comment

                • rowan
                  Too lazy to set a custom title
                  • Mar 2002
                  • 17393

                  #9
                  Originally posted by borked
                  Surrounding areas are calculated from latitude/longitude parameters of the visitor IP - complicated maths cos the world isn't flat ;)
                  $theta = $lon1 - $lon2;
                  $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
                  $dist = acos($dist);
                  $dist = rad2deg($dist);
                  $miles = $dist * 60 * 1.1515;
                  $unit = strtoupper($unit);

                  Surrounding areas can be turned off in that add image:

                  Nearby ON: and with Nearby OFF:
                  Yep, I know about matching up nearby localities, do it with my photo website... I'm just curious where you got the loc db from?

                  Comment

                  • borked
                    Totally Borked
                    • Feb 2005
                    • 6284

                    #10
                    Originally posted by Davy
                    Running your php code on my server?
                    I don't think so... no thanks.
                    What is the point of that comment? The code is all open so you can check yourself that nothing is untoward.

                    Jeese, some people are so damn suspicious.
                    Would it make you feel better if I charged you $100 for it

                    For coding work - hit me up on andy // borkedcoder // com
                    (consider figuring out the email as test #1)



                    All models are wrong, but some are useful. George E.P. Box. p202

                    Comment

                    • borked
                      Totally Borked
                      • Feb 2005
                      • 6284

                      #11
                      Originally posted by rowan
                      Yep, I know about matching up nearby localities, do it with my photo website... I'm just curious where you got the loc db from?
                      Gotcha. But I can't give away all my things though, some things have gotta remain a trade secret

                      There are online lookups, like terraserver.net (free), and Microsoft's Mapthingy (paid) that can be used. I just fancied a home-grown one and so went the *very* long route.

                      see
                      http://www.geoplugin.com/webservices/extras

                      I was going to open it up to allow for radius changes, but the cpu spikes if some tit puts in a massive radius, so I left it at default 10miles.

                      For coding work - hit me up on andy // borkedcoder // com
                      (consider figuring out the email as test #1)



                      All models are wrong, but some are useful. George E.P. Box. p202

                      Comment

                      • Dopy
                        Confirmed User
                        • Feb 2001
                        • 1572

                        #12
                        borked

                        Why are you offering a service thats using your server for free ?

                        Comment

                        • borked
                          Totally Borked
                          • Feb 2005
                          • 6284

                          #13
                          because there are lots of things I do which aren't for commercial gain.

                          This particular venture was because when I was doing something that used geo stuff a long long time ago, I was frustrated as hell as to how difficult it was to do. So I set this up to help others. No ulterior motives at all. People that use it are programmers, and that's what it's all about.

                          For coding work - hit me up on andy // borkedcoder // com
                          (consider figuring out the email as test #1)



                          All models are wrong, but some are useful. George E.P. Box. p202

                          Comment

                          • mrkris
                            Confirmed User
                            • May 2005
                            • 2737

                            #14
                            You can also use the Net_GeoIP package + Cache_Lite from PEAR. That's what I use and cache per IP. If anyone wants to know how to use that, hit me up. My results thus far have been very accurate using the free Maxmind DB.

                            Good post regardless Borked. Why aren't you ever on icq/aim anymore?

                            PHP-MySQL-Rails | ICQ: 342500546

                            Comment

                            • TheDoc
                              Too lazy to set a custom title
                              • Jul 2001
                              • 13827

                              #15
                              Or you can just download the free db and the scripts they provide, upload it behind the web and ask your host to set that dir as global. Now just echo out the geoip call to anything, page, script, picture, with a single line.
                              ~TheDoc - ICQ7765825
                              It's all disambiguation

                              Comment

                              • borked
                                Totally Borked
                                • Feb 2005
                                • 6284

                                #16
                                whadya mean? Course I'm on!

                                BTW, do some benchmarking with Net_GeoIP compared to a C wrapper or the apache module - net_geoip is dog slow....

                                When you compile the maxmind source, look in the examples folder - there's a cool shell script in there. Modify it a bit to take into account the new values, like continent code and some other new things, then have php call that script and parse the output. Far far faster for querying specific IP addresses.

                                Bit overkill to gain a few msecs, but thought I'd throw it out there. I needed to go that route, as I'm doing a shit load of lookups per day, so the diff between 1usec and 10msecs is huge.

                                For coding work - hit me up on andy // borkedcoder // com
                                (consider figuring out the email as test #1)



                                All models are wrong, but some are useful. George E.P. Box. p202

                                Comment

                                • borked
                                  Totally Borked
                                  • Feb 2005
                                  • 6284

                                  #17
                                  Originally posted by TheDoc
                                  Or you can just download the free db and the scripts they provide, upload it behind the web and ask your host to set that dir as global. Now just echo out the geoip call to anything, page, script, picture, with a single line.
                                  You didn't read the OP did you tut tut.

                                  For coding work - hit me up on andy // borkedcoder // com
                                  (consider figuring out the email as test #1)



                                  All models are wrong, but some are useful. George E.P. Box. p202

                                  Comment

                                  • Dopy
                                    Confirmed User
                                    • Feb 2001
                                    • 1572

                                    #18
                                    borked

                                    Thanks for the inspiring post, your php class has given me some new ideas for our flight info, weather and exchange rate feeds. I will probably end up using a paid for geo service but for now your class is a great experimental tool.

                                    Comment

                                    • TheDoc
                                      Too lazy to set a custom title
                                      • Jul 2001
                                      • 13827

                                      #19
                                      Originally posted by borked
                                      You didn't read the OP did you tut tut.
                                      Read the OP? Output?
                                      ~TheDoc - ICQ7765825
                                      It's all disambiguation

                                      Comment

                                      • mrkris
                                        Confirmed User
                                        • May 2005
                                        • 2737

                                        #20
                                        Originally posted by borked
                                        whadya mean? Course I'm on!

                                        BTW, do some benchmarking with Net_GeoIP compared to a C wrapper or the apache module - net_geoip is dog slow....

                                        When you compile the maxmind source, look in the examples folder - there's a cool shell script in there. Modify it a bit to take into account the new values, like continent code and some other new things, then have php call that script and parse the output. Far far faster for querying specific IP addresses.

                                        Bit overkill to gain a few msecs, but thought I'd throw it out there. I needed to go that route, as I'm doing a shit load of lookups per day, so the diff between 1usec and 10msecs is huge.
                                        Sometimes using a C wrapper or an apache2 module isn't an option, which is why I cache it.
                                        Last edited by mrkris; 12-07-2008, 09:44 AM. Reason: typo

                                        PHP-MySQL-Rails | ICQ: 342500546

                                        Comment

                                        • borked
                                          Totally Borked
                                          • Feb 2005
                                          • 6284

                                          #21
                                          original post

                                          For coding work - hit me up on andy // borkedcoder // com
                                          (consider figuring out the email as test #1)



                                          All models are wrong, but some are useful. George E.P. Box. p202

                                          Comment

                                          • borked
                                            Totally Borked
                                            • Feb 2005
                                            • 6284

                                            #22
                                            Originally posted by Dopy
                                            borked

                                            Thanks for the inspiring post, your php class has given me some new ideas for our flight info, weather and exchange rate feeds. I will probably end up using a paid for geo service but for now your class is a great experimental tool.
                                            You're very welcome.
                                            Just cos it's free, doesn't mean it's crap though

                                            If you need any help with your project, give me a shout

                                            For coding work - hit me up on andy // borkedcoder // com
                                            (consider figuring out the email as test #1)



                                            All models are wrong, but some are useful. George E.P. Box. p202

                                            Comment

                                            • borked
                                              Totally Borked
                                              • Feb 2005
                                              • 6284

                                              #23
                                              Dopy, just so you know (which isn't documented anywhere), queries are limited to a rate of 60/minute, which has never caused any probs amongst those that use it. If you hammer away at a faster rate than that, you'll get blacklisted for 1hr.

                                              I had to implement that, cos it was being abused.

                                              For coding work - hit me up on andy // borkedcoder // com
                                              (consider figuring out the email as test #1)



                                              All models are wrong, but some are useful. George E.P. Box. p202

                                              Comment

                                              • TheDoc
                                                Too lazy to set a custom title
                                                • Jul 2001
                                                • 13827

                                                #24
                                                Originally posted by borked
                                                original post
                                                Ah, I did read the Original Post.. It's a nice thing to have access to the City DB at no charge, don't get me wrong.

                                                But if someone can download and setup this up then setting up and using what maxmind provides for free isn't going to trip the person up.


                                                Personally, I purchase the City DB, some hosts provide it free. Anyway, Konrad took the base Maxmind scripts, made a couple quick adjustments and all was set. Over the last several years we have shared the setup with lots of people. No host, program or Webmaster has ever came back saying it was slow.

                                                Not saying what you have won't work like a champ, I'm sure it will.. But the real basic setup and use of GEOIP is easier than setting up a Web Form.
                                                ~TheDoc - ICQ7765825
                                                It's all disambiguation

                                                Comment

                                                • Dopy
                                                  Confirmed User
                                                  • Feb 2001
                                                  • 1572

                                                  #25
                                                  Originally posted by borked
                                                  Dopy, just so you know (which isn't documented anywhere), queries are limited to a rate of 60/minute, which has never caused any probs amongst those that use it. If you hammer away at a faster rate than that, you'll get blacklisted for 1hr.

                                                  I had to implement that, cos it was being abused.
                                                  Thanks for the info, I'm out of high traffic porn and in the quiet life real estate business these days. 1 or 2k/day is our best shot.

                                                  Comment

                                                  • borked
                                                    Totally Borked
                                                    • Feb 2005
                                                    • 6284

                                                    #26
                                                    Doc -
                                                    Yeah, fair enough. Was just showing that the class outputs the "Nearby" stuff and the inbuilt currency converter, things that aren't simple at all to do and certainly imposs with maxmind.

                                                    The thread wasn't meant as a sales pitch at all, but was just making the point that it can be real easy, since there have been a few posts recently that have shown that it is quite difficult for some (and some don't even have dedi boxes to install the stuff on)

                                                    For coding work - hit me up on andy // borkedcoder // com
                                                    (consider figuring out the email as test #1)



                                                    All models are wrong, but some are useful. George E.P. Box. p202

                                                    Comment

                                                    • TheDoc
                                                      Too lazy to set a custom title
                                                      • Jul 2001
                                                      • 13827

                                                      #27
                                                      Originally posted by borked
                                                      Doc -
                                                      Yeah, fair enough. Was just showing that the class outputs the "Nearby" stuff and the inbuilt currency converter, things that aren't simple at all to do and certainly imposs with maxmind.

                                                      The thread wasn't meant as a sales pitch at all, but was just making the point that it can be real easy, since there have been a few posts recently that have shown that it is quite difficult for some (and some don't even have dedi boxes to install the stuff on)
                                                      I sale short script - each dollars only 2!
                                                      ~TheDoc - ICQ7765825
                                                      It's all disambiguation

                                                      Comment

                                                      • Bhunter
                                                        Confirmed User
                                                        • Dec 2006
                                                        • 1119

                                                        #28
                                                        it says Nijmegen (NL), while it should be Dronten (NL)

                                                        Comment

                                                        • ThumbLord

                                                          #29
                                                          same here is says either Den Haag or Ypenburg both in NL, not even close, considering the Netherlands is a small country but both are at least 50KM or more off.

                                                          Comment

                                                          • borked
                                                            Totally Borked
                                                            • Feb 2005
                                                            • 6284

                                                            #30
                                                            You guys are missing the point - geolocation by IP at the city level is never going to be 100% accurate, and especially so for small countries. If your in a small country, the ISP is going to be less likely to group IPs by city and simply assign an entire block to a very large region.

                                                            Accuracy wasn't the point of the thread

                                                            For coding work - hit me up on andy // borkedcoder // com
                                                            (consider figuring out the email as test #1)



                                                            All models are wrong, but some are useful. George E.P. Box. p202

                                                            Comment

                                                            • emjay
                                                              Confirmed User
                                                              • Dec 2004
                                                              • 4280

                                                              #31
                                                              Originally posted by borked
                                                              You guys are missing the point - geolocation by IP at the city level is never going to be 100% accurate, and especially so for small countries. If your in a small country, the ISP is going to be less likely to group IPs by city and simply assign an entire block to a very large region.

                                                              Accuracy wasn't the point of the thread
                                                              This is why we hone in on the surfer's country/language, based on a combination of maxmind's IP and browser language algorythms eg "click to enter" on:



                                                              Both the banner and underlying site automatically appear in one of 45 languages
                                                              I Run 500+ WhatsApp Groups. The Zuck Owns Me
                                                              www.emjayconsultancy.com

                                                              Comment

                                                              • borked
                                                                Totally Borked
                                                                • Feb 2005
                                                                • 6284

                                                                #32
                                                                Originally posted by emjay
                                                                This is why we hone in on the surfer's country/language, based on a combination of maxmind's IP and browser language algorythms eg "click to enter" on:
                                                                You don't need any geolocation software to do that. You simply take the browser's language preference from apache's HTTP_ACCEPT_LANGUAGE setting. No algorithm needed

                                                                Language-localised ads are a must imo. Geo-localising anything is pointless if you aren't displaying the text in the user's preferred language.

                                                                For coding work - hit me up on andy // borkedcoder // com
                                                                (consider figuring out the email as test #1)



                                                                All models are wrong, but some are useful. George E.P. Box. p202

                                                                Comment

                                                                • emjay
                                                                  Confirmed User
                                                                  • Dec 2004
                                                                  • 4280

                                                                  #33
                                                                  Originally posted by borked
                                                                  Language-localised ads are a must imo. Geo-localising anything is pointless if you aren't displaying the text in the user's preferred language.
                                                                  Agreed borked Money talks, in every language?
                                                                  I Run 500+ WhatsApp Groups. The Zuck Owns Me
                                                                  www.emjayconsultancy.com

                                                                  Comment

                                                                  • fuzebox
                                                                    making it rain
                                                                    • Oct 2003
                                                                    • 22352

                                                                    #34
                                                                    Man it pisses me off when people quote the distance that your geo targeting is off, as if that has anything to do with anything. All that proves is ignorance on how the technology works.

                                                                    Comment

                                                                    • tranza
                                                                      ICQ: 197-556-237
                                                                      • Jun 2003
                                                                      • 57559

                                                                      #35
                                                                      Usefull...! thanks.
                                                                      I'm just a newbie.

                                                                      Comment

                                                                      • TeenCat
                                                                        Too lazy to set a koala
                                                                        • Jan 2007
                                                                        • 16139

                                                                        #36
                                                                        hmm cool man this is the most accurate geo i saw ... everytime it was at least 50km, now you are 5 km from my location, great keep up the good work!

                                                                        6bot
                                                                        / Coming again very soon!
                                                                        Svit Zlin Radio 24/7!

                                                                        Comment

                                                                        • JJSLIMM
                                                                          Confirmed User
                                                                          • Jan 2002
                                                                          • 1414

                                                                          #37
                                                                          Awesome service Andy! Been using this for some time and love it..
                                                                          Email [email protected] | Skype: jjslimm

                                                                          Comment

                                                                          • Mike*
                                                                            Confirmed User
                                                                            • Sep 2008
                                                                            • 118

                                                                            #38
                                                                            Great information in this thread!

                                                                            Thanks borked

                                                                            Comment

                                                                            • Walter Gropius
                                                                              Confirmed User
                                                                              • Jun 2007
                                                                              • 397

                                                                              #39
                                                                              Top work borked, will defo be trying this out
                                                                              Adulterate | Porn Legends | Classic Porno | Porn Blog

                                                                              ICQ: 433306197

                                                                              Comment

                                                                              • Davy
                                                                                Confirmed User
                                                                                • Apr 2006
                                                                                • 4323

                                                                                #40
                                                                                Originally posted by borked
                                                                                What is the point of that comment? The code is all open so you can check yourself that nothing is untoward.
                                                                                The code is not open. You can do whatever you like on your server's side.

                                                                                Originally posted by borked
                                                                                because there are lots of things I do which aren't for commercial gain.

                                                                                No ulterior motives at all. People that use it are programmers, and that's what it's all about.
                                                                                There's no such thing as philanthropic motives in business.
                                                                                If you wanted to help programmers, you would release the full code, both on the client and server side.
                                                                                ---
                                                                                ICQ 14-76-98 <-- I don't use this at all

                                                                                Comment

                                                                                • quantum-x
                                                                                  Confirmed User
                                                                                  • Feb 2002
                                                                                  • 6863

                                                                                  #41
                                                                                  Originally posted by Davy
                                                                                  The code is not open. You can do whatever you like on your server's side.



                                                                                  There's no such thing as philanthropic motives in business.
                                                                                  If you wanted to help programmers, you would release the full code, both on the client and server side.
                                                                                  His code, his service. He can do what he wants with it.
                                                                                  If you don't agree with his principles or methodology, don't use the service.
                                                                                  Noone is forcing you
                                                                                  PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

                                                                                  Comment

                                                                                  • Davy
                                                                                    Confirmed User
                                                                                    • Apr 2006
                                                                                    • 4323

                                                                                    #42
                                                                                    Of course I won't use his service.
                                                                                    ---
                                                                                    ICQ 14-76-98 <-- I don't use this at all

                                                                                    Comment

                                                                                    • borked
                                                                                      Totally Borked
                                                                                      • Feb 2005
                                                                                      • 6284

                                                                                      #43
                                                                                      Originally posted by Davy
                                                                                      The code is not open. You can do whatever you like on your server's side.



                                                                                      There's no such thing as philanthropic motives in business.
                                                                                      If you wanted to help programmers, you would release the full code, both on the client and server side.
                                                                                      What was the purpose of bumping a 10-month old thread with a comment like this. The example code I gave is open. How my server disses up the geolocation is not open, nor are some of the databases used in the "extras" section.

                                                                                      I couldn't give a toss if you use it or not tbh, but there is zero financial gain or incentive in this operation, whether you believe it or not

                                                                                      For coding work - hit me up on andy // borkedcoder // com
                                                                                      (consider figuring out the email as test #1)



                                                                                      All models are wrong, but some are useful. George E.P. Box. p202

                                                                                      Comment

                                                                                      • quantum-x
                                                                                        Confirmed User
                                                                                        • Feb 2002
                                                                                        • 6863

                                                                                        #44
                                                                                        Originally posted by Davy
                                                                                        Of course I won't use his service.
                                                                                        ..and? Do you want a medal or something?
                                                                                        PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

                                                                                        Comment

                                                                                        Working...