Ejemplo n.º 1
0
// Query for some other information (remember the N95 headers are still set).
// Add detection options to query for additional reply information such as geoip information
// Note : We use the ipaddress to get the geoip location.
echo "<h1>Simple Detection - Passing a different ip address</h1><p>";
$hd->setDetectVar('ipaddress', '64.34.165.180');
if ($hd->siteDetect(array('options' => 'geoip,hd_specs'))) {
    $tmp = $hd->getReply();
    print_r($tmp);
} else {
    print $hd->getError();
}
echo "</p>";
// Ultimate customers can also download the ultimate database.
// Note  - Increase default timeout
echo "<h1>Archive Information</h1><p>";
$hd->setTimeout(500);
$time_start = _getmicrotime();
if ($hd->siteFetchArchive()) {
    $data = $hd->getRawReply();
    echo "Downloaded " . strlen($data) . " bytes";
} else {
    print $hd->getError();
}
$time_elapsed = _getmicrotime() - $time_start;
echo "<br/>Time elapsed " . $time_elapsed . "ms";
echo "</p>";
function _getmicrotime()
{
    list($usec, $sec) = explode(" ", microtime());
    return (double) $usec + (double) $sec;
}