Skip to content

Instantly share code, notes, and snippets.

@thiagotmendes
Created December 19, 2019 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagotmendes/d3b3a18b22ec9a343e87c6b2eb2470ac to your computer and use it in GitHub Desktop.
Save thiagotmendes/d3b3a18b22ec9a343e87c6b2eb2470ac to your computer and use it in GitHub Desktop.
<?php
$cidade = "belo horizonte";
echo $_SERVER['HTTP_CLIENT_IP'];
$ip = $_SERVER['HTTP_CLIENT_IP']; // your ip address here
$query = @unserialize(file_get_contents('http://ip-api.com/php/'.$ip));
if($query && $query['status'] == 'success')
{
if($cidade == strtolower($query['city'])){
echo "aqui é BH <br>";
}
echo 'Your City is ' . strtolower($query['city']);
echo '<br />';
echo 'Your State is ' . $query['region'];
echo '<br />';
echo 'Your Zipcode is ' . $query['zip'];
echo '<br />';
echo 'Your Coordinates are ' . $query['lat'] . ', ' . $query['lon'];
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment