port ip2locationlite to curl

This commit is contained in:
Dan Ballard 2014-01-06 22:30:02 -05:00
parent 4eb727e205
commit ce5987030a
1 changed files with 8 additions and 1 deletions

View File

@ -1,4 +1,6 @@
<?php <?php
# Patched to use CURL instead of file_get_contents
final class ip2location_lite{ final class ip2location_lite{
protected $errors = array(); protected $errors = array();
protected $service = 'api.ipinfodb.com'; protected $service = 'api.ipinfodb.com';
@ -30,7 +32,12 @@ final class ip2location_lite{
// if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){ // if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
if(filter_var($ip, FILTER_VALIDATE_IP)){ if(filter_var($ip, FILTER_VALIDATE_IP)){
$xml = @file_get_contents('http://' . $this->service . '/' . $this->version . '/' . $name . '/?key=' . $this->apiKey . '&ip=' . $ip . '&format=xml'); $url = 'http://' . $this->service . '/' . $this->version . '/' . $name . '/?key=' . $this->apiKey . '&ip=' . $ip . '&format=xml';
$ch =curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec($ch);
curl_close($ch);
//$xml = @file_get_contents('http://' . $this->service . '/' . $this->version . '/' . $name . '/?key=' . $this->apiKey . '&ip=' . $ip . '&format=xml');
if (get_magic_quotes_runtime()){ if (get_magic_quotes_runtime()){