rdsedmundo

ip location

Apr 21st, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2. $ip = $_SERVER['REMOTE_ADDR'];
  3. $response = file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip);
  4. $array = var_export( unserialize ( $response  ), 1);
  5. eval( '$array = '. $array .';');
  6. $data  = new stdClass();
  7. $data->city   = $array['geoplugin_city'].'|';
  8. $data->region = $array['geoplugin_region'].'|';
  9. $data->country     = $array['geoplugin_countryName'];
  10. /*$data->countrycode = $array['geoplugin_countryCode'];
  11. $data->long        = $array['geoplugin_longitude'];
  12. $data->lat         = $array['geoplugin_latitude'];*/
  13. $valor_q = '';
  14. foreach($data as $valor) {
  15.     $valor_q .= $valor;
  16. }
  17. $d = explode('|',$valor_q);
  18.     $cidade = $d[0];
  19.     $estado = $d[1];
  20.     $pais = $d[2];
  21. $msg = $cidade.','.$estado.','.$pais;
  22. echo $msg;
  23. exit;
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment