fix file_get_contents in helper

This commit is contained in:
Roland Schneider 2016-01-08 23:22:06 +01:00
parent c1a7615b5f
commit 5a98d128bc

View File

@ -176,9 +176,22 @@ class Helper {
return $ip; return $ip;
} }
public static function url_get_contents ($Url) {
if (!function_exists('curl_init')){
die('CURL is not installed!');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
public static function getGeoIp() { public static function getGeoIp() {
$ip = Helper::getRealUserIp (); $ip = Helper::getRealUserIp ();
$details = json_decode ( file_get_contents ( "http://ipinfo.io/{$ip}/json" ) ); $details = json_decode ( Helper::url_get_contents( "http://ipinfo.io/{$ip}/json" ) );
return $details; return $details;
} }
} }