<?php
echo "<br>";
echo $clientIP = $_SERVER['REMOTE_ADDR']; 
echo "<br>";
    $query = @unserialize(file_get_contents('http://ip-api.com/php/'.$clientIP));
	echo "<pre>";
	print_r($query);
	echo "http://ip-api.com   API ";
    if($query && $query['status'] == 'success')
    {
		echo "<br>";
        echo 'Your City is ' . $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'];
    }
	
echo $ip_address=$_SERVER['REMOTE_ADDR'];	
	
	// echo "<br>-------------------------------------------<br>";
// 
// /*Getting user IP address details with geoplugin.net*/
// $addr_details = @unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip_address));
// $city = $addr_details['geoplugin_city'];
// $countrycode = $addr_details['geoplugin_countryCode'];
// $country = $addr_details['geoplugin_countryName'];
// echo "<br>";
 // echo "<b>"."City Name:"."</b>".$city."<br>";
// echo "<b>"."Country Code:"."</b>".$countrycode."<br>";
// echo "<b>"."Country Name:"."</b>".$country."<br>";


echo "<br>---------------------------------------------<br>";

$ch = curl_init('http://ipwhois.app/json/' . $ip_address);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $json = curl_exec($ch);
        curl_close($ch);
        // Decode JSON response
        $ipWhoIsResponse = json_decode($json, true);
		echo "<pre>";
		print_r($ipWhoIsResponse);
		
		
		
 echo "---------------------------------------------<br>";

		
		// $apiURL = 'https://freegeoip.app/json/'.$ip_address; 
     
   
    // $ch = curl_init($apiURL); 
    // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    // $apiResponse = curl_exec($ch); 
    // if($apiResponse === FALSE) { 
        // $msg = curl_error($ch); 
        // curl_close($ch); 
        // return false; 
    // } 
    // curl_close($ch); 
     

    // $ipData = json_decode($apiResponse, true);
	// echo "<pre>";
// print_r($ipData);	
?>
