1) { $ips = array_map(array(&$this, "cleanIP"), $ips); $ips = array_unique($ips); $ip_chunks = array_chunk($ips,25); $ipinfo = array(); foreach($ip_chunks as $ipch) { $url = "http://ipinfodb.com/ip_query2.php?timezone=false&output=json&ip=".implode(',',$ipch); $val = $this->makeRequest($url); foreach($val['page']['Locations'] as $i) { $ipinfo[$i['Ip']] = $i; } } return $ipinfo; } else { $url = "http://ipinfodb.com/ip_query.php?timezone=false&output=json&ip=".$this->cleanIP($ips[0]); $val = $this->makeRequest($url); $ipinfo = array("{$ips[0]}" => $val['page']); return array("{$ips[0]}" => $val['page']); } } function cleanIP($ip) { return preg_replace('/[^0-9\.]/','',$ip); } private function makeRequest($url) { $referer = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 3); curl_setopt($ch, CURLOPT_REFERER, $referer); $tries=0; $page=false; while( $page===false && $tries<= 5) { $page = curl_exec($ch); $tries++; } $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return array('page'=>json_decode($page,true), 'tries'=>$tries, 'httpcode' => $httpcode); } } ?>