Posted By

irm on 10/10/09


Tagged

php web ip


Versions (?)

GEO Localizer


 / Published in: Python
 

URL: http://forum.zloy.bz/showthread.php?t=91783

by mrgrek

  1. <?php
  2.  
  3. include 'geoip.inc.php';
  4. $geo = geoip_open( "GeoIP.dat", GEOIP_STANDARD );
  5. $ip = $_SERVER['REMOTE_ADDR'];
  6. //$ip = '123.45.67.89';
  7.  
  8. $cntry = $geo->GEOIP_COUNTRY_NAMES[array_search(strtoupper(geoip_country_code_by_addr($geo, $ip)), $geo->GEOIP_COUNTRY_CODES)];
  9.  
  10. if (strlen($cntry) == 0)
  11. $cntry = 'Unknown';
  12.  
  13. echo 'your IP: <b>'.$_SERVER['REMOTE_ADDR'].'</b>; You are from: <b>'.$cntry.'</b>.';
  14.  
  15. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: grzyweasel on October 7, 2010

Not Python but PHP

You need to login to post a comment.