954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

GeoIP tagging - Where to start?

0
By Stan Kilgore on Feb 21st, 2010 11:11 pm

If you ever go to http://www.hostip.info/ , you will find a Community Geotarget IP Project. The great thing about it is that it is free to use. :)

Now, this is just a snippet of code to begin working in the world of GeoIPs. There's a lot more info to be gotten, and if you go to http://www.hostip.info/use.html , you will find many different ways of calling the information that you need.

Just my 2ยข. Thought I'd share.

<?php

$ip = getenv('REMOTE_ADDR');
$url = "http://api.hostip.info/get_html.php?".$ip;

$contents = file_get_contents($url);
$values = split("[\n|\r]",$contents);

foreach($values as $vals) {
	$myvalues = split(": ",$vals);
	$line = "<strong>".$myvalues[0].":</strong> ".$myvalues[1]."<br />";
	echo $line;
}

?>

geotargeting hadn't crossed my mind, cheers
makes for a nice IP logging system ;)
however split() has been deprecated as of 5.3.0, best to use preg_split()

thanks again

rom.
Newbie Poster
19 posts since Oct 2010
Reputation Points: 23
Solved Threads: 1
 

Thanks for the heads up on split(). 5.3.0 had only been out for 8 months or so and old habits are hard to break. :)

Wraithmanilian
Junior Poster
196 posts since Dec 2009
Reputation Points: 17
Solved Threads: 42
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: