GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   All things geolocation ... (https://gfy.com/showthread.php?t=873995)

borked 12-07-2008 09:04 AM

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]

borked 12-07-2008 09:05 AM

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 :winkwink:

Dopy 12-07-2008 09:09 AM

Great for me, its only 1500 KM off position.

rowan 12-07-2008 09:10 AM

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)

borked 12-07-2008 09:12 AM

Quote:

Originally Posted by Dopy (Post 15157950)
Great for me, its only 1500 KM off position.

what is it saying? I think I have image caching on

Dopy 12-07-2008 09:16 AM

Quote:

Originally Posted by borked (Post 15157953)
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.

borked 12-07-2008 09:30 AM

Quote:

Originally Posted by rowan (Post 15157952)
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: http://www.geoplugin.com/geoexamples...rl/geogirl.gif and with Nearby OFF: http://www.geoplugin.com/geoexamples...gif?nearby=off

Davy 12-07-2008 09:55 AM

Running your php code on my server?
I don't think so... no thanks.

rowan 12-07-2008 10:01 AM

Quote:

Originally Posted by borked (Post 15157983)
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: http://www.geoplugin.com/geoexamples...rl/geogirl.gif and with Nearby OFF: http://www.geoplugin.com/geoexamples...gif?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?

borked 12-07-2008 10:04 AM

Quote:

Originally Posted by Davy (Post 15158029)
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 :1orglaugh

borked 12-07-2008 10:11 AM

Quote:

Originally Posted by rowan (Post 15158041)
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 :winkwink:

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.

Dopy 12-07-2008 10:29 AM

borked

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

borked 12-07-2008 10:52 AM

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.

mrkris 12-07-2008 11:20 AM

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?

TheDoc 12-07-2008 11:30 AM

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.

borked 12-07-2008 11:31 AM

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.

borked 12-07-2008 11:32 AM

Quote:

Originally Posted by TheDoc (Post 15158279)
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.

Dopy 12-07-2008 11:41 AM

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.

TheDoc 12-07-2008 11:43 AM

Quote:

Originally Posted by borked (Post 15158287)
You didn't read the OP did you tut tut.

Read the OP? Output?

mrkris 12-07-2008 11:44 AM

Quote:

Originally Posted by borked (Post 15158283)
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.

borked 12-07-2008 11:44 AM

original post

borked 12-07-2008 11:47 AM

Quote:

Originally Posted by Dopy (Post 15158315)
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 :winkwink:

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

borked 12-07-2008 11:55 AM

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.

TheDoc 12-07-2008 12:02 PM

Quote:

Originally Posted by borked (Post 15158331)
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.

Dopy 12-07-2008 12:04 PM

Quote:

Originally Posted by borked (Post 15158370)
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.

borked 12-07-2008 12:07 PM

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)

TheDoc 12-07-2008 12:09 PM

Quote:

Originally Posted by borked (Post 15158423)
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! :)

Bhunter 12-08-2008 12:42 PM

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

ThumbLord 12-08-2008 01:21 PM

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.

borked 12-08-2008 01:39 PM

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 :2 cents:

emjay 12-08-2008 01:58 PM

Quote:

Originally Posted by borked (Post 15163409)
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 :2 cents:

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:

http://www.pinaccesscode.com/gtib_ig...to_enter_$.gif

Both the banner and underlying site automatically appear in one of 45 languages:pimp

borked 12-08-2008 02:25 PM

Quote:

Originally Posted by emjay (Post 15163588)
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 :2 cents:

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.

emjay 12-08-2008 02:31 PM

Quote:

Originally Posted by borked (Post 15163779)
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? :winkwink:

fuzebox 12-13-2008 11:17 AM

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.

tranza 12-17-2008 06:49 AM

Usefull...! thanks.

TeenCat 12-17-2008 07:16 AM

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! :thumbsup

JJSLIMM 12-17-2008 02:41 PM

Awesome service Andy! Been using this for some time and love it..

Mike* 12-19-2008 01:49 PM

Great information in this thread!

Thanks borked

Walter Gropius 12-19-2008 03:53 PM

Top work borked, will defo be trying this out

Davy 09-14-2009 01:42 AM

Quote:

Originally Posted by borked (Post 15158047)
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.

Quote:

Originally Posted by borked (Post 15158164)
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. :2 cents:

quantum-x 09-14-2009 02:16 AM

Quote:

Originally Posted by Davy (Post 16316351)
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. :2 cents:

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 :)

Davy 09-14-2009 08:31 AM

Of course I won't use his service. :2 cents:

borked 09-14-2009 08:38 AM

Quote:

Originally Posted by Davy (Post 16316351)
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. :2 cents:

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 :2 cents:

quantum-x 09-14-2009 09:22 AM

Quote:

Originally Posted by Davy (Post 16317149)
Of course I won't use his service. :2 cents:

..and? Do you want a medal or something?


All times are GMT -7. The time now is 06:22 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123