IP to Location?
Moderator: General Moderators
IP to Location?
Assuming I have nabbed a users IP address with $_SERVER['SERVER_ADDR']; ...
what can i realistically do with this?
using code, not ARIN, how do i match it up with their geography to sync up ads, weather, and other custom options without asking for their ZIP/Postal codes?
what can i realistically do with this?
using code, not ARIN, how do i match it up with their geography to sync up ads, weather, and other custom options without asking for their ZIP/Postal codes?
okay, ninja space goat i can understand that like with http_ref or any other global type server setting for that matter, there is a degree of unreliability, but this MaxMind was bang on for the IP I fed it.
Say, i was looking for an unreliable way to process these, what are some functions that might help me narrow geography for IP.
i have seen a few programs offering these services, displaying city, longitude, latitude... sometimes even postal codes
is this mindmax just querying the IANA? see the demo, it's pretty detailed.
Say, i was looking for an unreliable way to process these, what are some functions that might help me narrow geography for IP.
i have seen a few programs offering these services, displaying city, longitude, latitude... sometimes even postal codes
is this mindmax just querying the IANA? see the demo, it's pretty detailed.
i was given this link on another board to check out and it gives some more insight on the process.
http://www.ip2nation.com/
http://www.ip2nation.com/
Code: Select all
<?php
$server = ''; // MySQL hostname
$username = ''; // MySQL username
$password = ''; // MySQL password
$dbname = ''; // MySQL db name
$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$sql = 'SELECT
country
FROM
ip2nation
WHERE
ip < INET_ATON("'.$_SERVER['REMOTE_ADDR'].'")
ORDER BY
ip DESC
LIMIT 0,1';
list($country) = mysql_fetch_row(mysql_query($sql));
switch ($country) {
case 'se':
// Get the swedish to a swedish newssite
header('Location: http://www.thelocal.se/');
exit;
case 'us':
// And let the folks from american go to CNN
header('Location: http://www.cnn.com/');
exit;
default:
// The rest can go to BBC
header('Location: http://www.bbc.co.uk/');
exit;
}
?>-
brendandonhue
- Forum Commoner
- Posts: 71
- Joined: Mon Sep 25, 2006 3:21 pm
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
MaxMind seemed to work relatively well.
It told me I'm in Manchester on my dial-up connection but when trying two static IPs against it it completely bailed.
My VDS is apparently in Norfolk but it's actually at Redbus Interhouse at London Docklands.
Our work servers are based in Manchester but it said they are in Newcastle (about 250 miles out).
I guess dynamic IPs are easier to trace since they'll all be dished out via a large ISP in a certain area.
It told me I'm in Manchester on my dial-up connection but when trying two static IPs against it it completely bailed.
My VDS is apparently in Norfolk but it's actually at Redbus Interhouse at London Docklands.
Our work servers are based in Manchester but it said they are in Newcastle (about 250 miles out).
I guess dynamic IPs are easier to trace since they'll all be dished out via a large ISP in a certain area.