Advertisement
rdsedmundo

ip_loc

Sep 29th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. <?php
  2. /*
  3. Créditos: geoplugin
  4.  
  5. Adaptado por: Kyl3
  6. */
  7. $ip = $_SERVER['REMOTE_ADDR'];
  8. $response = file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip);
  9. $array = var_export( unserialize ( $response  ), 1);
  10. eval( '$array = '. $array .';');
  11. $data  = new stdClass();
  12. $data->city   = $array['geoplugin_city'].'|';
  13. $data->region = $array['geoplugin_region'].'|';
  14. $data->country     = $array['geoplugin_countryName'];
  15. /*$data->countrycode = $array['geoplugin_countryCode'];
  16. $data->lat         = $array['geoplugin_latitude'];*/
  17. $data->long        = $array['geoplugin_longitude'];
  18. $valor_q = '';
  19. foreach($data as $valor) {
  20.     $valor_q .= $valor;
  21. }
  22. $d = explode('|',$valor_q);
  23.     $cidade = $d[0];
  24.     $estado = $d[1];
  25.     $pais = $d[2];
  26. $gmt = round($data->long / 15);
  27. $gmt > 0 ? $gmt = "+".$gmt : $gmt;
  28. date_default_timezone_set("America/Sao_Paulo");
  29. $horalocal = date("H") + 3 + $gmt;
  30. echo $horalocal;
  31. exit;
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement