function getLocation( $ip ) { static $location = array(); if( !isset( $location[$ip] ) ) { $url = "http://www.hostip.info/api/get.html?ip=" . $ip . "&position=true&raandom=" . rand(0,500); /* cURL */ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); if ( curl_errno( $ch ) ) { print "Error: ".curl_error($ch); } else { curl_close($ch); $lines = split ("\n", $data); foreach($lines as $l): $prop = split(':',$l); $location[$ip][trim($prop[0])] = addslashes(trim($prop[1])); endforeach; } } return $location[$ip]; }
You need to create an account or log in to post comments to this site.