wow, thanks for quick reply.
it's totally fine that the code only accept IPv4 even if it accepts non-existing IPv4 addresses... and I don't think IPv6 is their DB yet anyway...
So, thanks for the code! but where would I place it in the original code you provided? or is this totally new code (i.e, not use original code you wrote) and no need to use Curl anymore?
original code you wrote:
function quovaXML($ip = '') {
These obviously need to be updated to match the user info provided to you by them
$quovaUser = 'username';
$quovaPass = 'password';
/* If no IP address is provided as function argument, use the IP address that
requested this script (i.e. the machine on which you are viewing this page)
As such, this will not work if you are running the script from CLI (command line interface)
*/
if (empty($ip)) $ip = $_SERVER['REMOTE_ADDR'];
// initiate curl and set options
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://webservices.quova.com/ipinfo/' . $ip);
curl_setopt($ch, CURLOPT_USERPWD, $quovaUser . ':' . $quovaPass);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
/* Normally, curl_exec returns true on success, false on error. With this option set
the body (and possibly headers) is returned on success, false on error.
*/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
# Since the request can fail completely, it's not enough to check for http status code 200
if (!($data = curl_exec($ch))) {
# error
echo curl_errno($ch) . ': ' . curl_error($ch);
curl_close($ch);
exit;
}
$headers = curl_getinfo($ch);
// close curl
curl_close($ch);
// return XML data
if ($headers['http_code'] != '200') {
return false;
} else {
return($data);
}
}
/ If your account only allows access from a specific IP address, that
IP address needs to be provided here
/
if (!($result = quovaXML('4.2.2.2')) {
echo 'HTTP status code is not 200';
}
else {
echo $result;
}