ip — МиниКод http://minicode.ru записи кодов Wed, 05 Sep 2018 06:40:48 +0000 ru-RU hourly 1 https://wordpress.org/?v=4.8.14 geo ip example http://minicode.ru/geo-ip-example/ Thu, 28 Jan 2016 16:17:03 +0000 http://minicode.ru/?p=887
<?
$ip = '192.168.11.5';
if($ch = curl_init()){		
	$url = "http://freegeoip.net/json/". $ip; 
	$headers = array(
		"Content-type: application/json",
		"Accept: application/json",
		"Accept-Language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4"
	); 
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL,$url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);	
 
	$data = curl_exec($ch); 
 
	if (curl_errno($ch)) {

		// curl_error($ch);         

	  
	} else {		         
		$arData = json_decode($data, true) ; 
	}
	
	curl_close($ch);  
}
print_r($arData);
?>
]]>