Esempio 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;
}
Esempio n. 2
0
 /**
  * Fetch Archive Test
  *
  * The community fetchArchive version contains a cut down version of the device specs.
  * It has general_vendor, general_model, display_x, display_y, general_platform, general_platform_version,
  * general_browser, general_browser_version, general_app, general_app_version, general_language,
  * general_language_full, benahmark_min & benchmark_max
  *
  * @group community
  **/
 function test_ultimate_community_fetchArchive()
 {
     $hd = new HandsetDetection\HD4($this->ultimateConfig);
     $hd->setTimeout(500);
     // Purge store
     $hd->Store->purge();
     // Fetch new device specs into store.
     $result = $hd->communityFetchArchive();
     $data = $hd->getRawReply();
     $size = strlen($data);
     echo "Downloaded {$size} bytes ";
     if ($size < 1000) {
         $this->markTestSkipped($data);
     } else {
         $this->assertTrue($result);
         $this->assertGreaterThan(9000000, strlen($data));
         // Filesize greater than 9Mb
     }
 }