Advertisement
diegodcpbr

SEM CIDADE

Apr 30th, 2020
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. <?php
  2. header('Content-Type: application/json; charset=utf-8');
  3. // PHP code to obtain country, city,  
  4. // continent, etc using IP Address
  5. date_default_timezone_set('America/Sao_Paulo');
  6.  
  7. function getVisIpAddr() {
  8.      
  9.     if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  10.         return $_SERVER['HTTP_CLIENT_IP'];
  11.     }
  12.     else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  13.         return $_SERVER['HTTP_X_FORWARDED_FOR'];
  14.     }
  15.     else {
  16.         return $_SERVER['REMOTE_ADDR'];
  17.     }
  18. }
  19.  
  20. // Store the IP address
  21. $vis_ip = getVisIPAddr();
  22.  
  23.  
  24.  
  25. // Use JSON encoded string and converts
  26. // it into a PHP variable
  27. $ipdat = @json_decode(file_get_contents(
  28.     "http://www.geoplugin.net/json.gp?ip=" . $vis_ip));
  29.    
  30. /*echo 'NOME PAÍS: ' . $ipdat->geoplugin_countryName . "\n";
  31. echo 'NOME CIDADE: ' . $ipdat->geoplugin_city . "\n";
  32. echo 'ESTADO: ' . $ipdat->geoplugin_continentName . "\n";
  33. echo 'Latitude: ' . $ipdat->geoplugin_latitude . "\n";
  34. echo 'Longitude: ' . $ipdat->geoplugin_longitude . "\n";
  35. echo 'MOEDA LOCAL: ' . $ipdat->geoplugin_currencySymbol . "\n";
  36. echo 'CODIGO MOEDA: ' . $ipdat->geoplugin_currencyCode . "\n";
  37. echo 'HORARIO LOCAL: ' . $ipdat->geoplugin_timezone; */
  38.  
  39.  
  40.  
  41.  
  42. $este_local = 'SEU IP É: ' . $vis_ip .' - NOME PAÍS: ' . $ipdat->geoplugin_countryName . ' -ESTADO: ' . $ipdat->geoplugin_continentName .  ' -Latitude: ' . $ipdat->geoplugin_latitude . ' -Longitude: ' . $ipdat->geoplugin_longitude .' -MOEDA LOCAL: ' . $ipdat->geoplugin_currencySymbol .' -CODIGO MOEDA: ' . $ipdat->geoplugin_currencyCode . ' -HORARIO LOCAL: ' . date('d/m/Y \à\s H:i:s');
  43.  
  44. $file = fopen("ip.txt","a+");
  45. fwrite($file,$este_local."\r\n");
  46. fclose($file);
  47.  
  48. echo $este_local." POLÍCIA FEDERAL";
  49.    
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement