943,147 Members | Top Members by Rank

Ad:
  • PHP Code Snippet
  • Views: 1309
  • PHP RSS
0

GeoIP tagging - Where to start?

by on Feb 21st, 2010
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 Code Snippet (Toggle Plain Text)
  1. <?php
  2.  
  3. $ip = getenv('REMOTE_ADDR');
  4. $url = "http://api.hostip.info/get_html.php?".$ip;
  5.  
  6. $contents = file_get_contents($url);
  7. $values = split("[\n|\r]",$contents);
  8.  
  9. foreach($values as $vals) {
  10. $myvalues = split(": ",$vals);
  11. $line = "<strong>".$myvalues[0].":</strong> ".$myvalues[1]."<br />";
  12. echo $line;
  13. }
  14.  
  15. ?>
Comments on this Code Snippet
Mar 26th, 2011
0

Re: GeoIP tagging - Where to start?

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
Newbie Poster
rom. is offline Offline
19 posts
since Oct 2010
Mar 27th, 2011
0

Re: GeoIP tagging - Where to start?

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.
Junior Poster
Wraithmanilian is offline Offline
195 posts
since Dec 2009
Message:
Previous Thread in PHP Forum Timeline: PHP to save as PDF
Next Thread in PHP Forum Timeline: Problem posting form to Self when using dropdowns.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC