Get Location By IP
Moderator: General Moderators
Get Location By IP
If I goto http://whois.sc/xxx.xxx.xxx.xxxx I can get the location (approx) of that particular person. I can obviously parse this and store it.
But is there any way to this directly using PHP ?
I want to do it the way whois.sc has done it.
Thanks
But is there any way to this directly using PHP ?
I want to do it the way whois.sc has done it.
Thanks
You might want to check http://www.maxmind.com/download/geoip/api/php/
I have a ip-to-country.csv list.
But it shows like this
I thought of converting to hex and then converting all the 2 hex values back to dec to get the real IP but thats not it.
Any idea on how this format is stored ?
Thanks
But it shows like this
Code: Select all
"50331648","69956103","US","USA","UNITED STATES"
"202031104","202033151","IN","IND","INDIA"Any idea on how this format is stored ?
Thanks
Last edited by anjanesh on Tue Aug 02, 2005 10:36 am, edited 1 time in total.
How complicated. Just convert from IP4 to long_ip before running the query. Here is the code to convert it.
Code: Select all
$ip4 = '12.34.56.78';
list($z, $y, $x, $w) = split('[[]]', $ip4);
$long_ip = ($w) + ($x * 256) + ($y * 256 * 256)+ ($z * 256 * 256 * 256);Thanks. ip2long returns -ve values too. Thanks bokehman.
But this csv file needs to be updated on a regular basis.
Is there anyway to hit some server's port directly just like the way Whois Servers are hit at port 43 for domain whois ?
Geobytes gives more accurate details like Region and City - Any API or db for that ?
Thanks
But this csv file needs to be updated on a regular basis.
Is there anyway to hit some server's port directly just like the way Whois Servers are hit at port 43 for domain whois ?
Geobytes gives more accurate details like Region and City - Any API or db for that ?
Thanks
If you want auto updating just set up a cron, but this seems a lot of trouble to me.anjanesh wrote:Thanks. ip2long returns -ve values too. Thanks bokehman.
But this csv file needs to be updated on a regular basis.
Is there anyway to hit some server's port directly just like the way Whois Servers are hit at port 43 for domain whois ?
Geobytes gives more accurate details like Region and City - Any API or db for that ?
Thanks
If you want greater accuracy than just the country you will have to pay and it's not cheap.
Long term shot.bokehman wrote: If you want auto updating just set up a cron
This is what im looking for. I just want to know how its done and I'll do the rest. Is there some place in IANA or ARIN to hit directly and get this result ?bokehman wrote: If you want greater accuracy than just the country you will have to pay and it's not cheap.
How is geobytes doing it ?