Location: PHPKode > scripts > gDNS > gdns/Example/example.php
<?php
require_once("../gDNS.php");

/* CNAME TEST */
$dns = new gDNS(false);
$s_time = 0;
$s_time = time();
if( $dns->Query( "net-snmp.sourceforge.net", "*", true, "IN", "192.33.4.12" ) ) {
	gen_Output( $dns->cur_domain );
	$dns->clearRecords( $dns->cur_domain );
}
printf( "Query done in %03d Sec's.\n", time() - $s_time );
flush();

/** This domain dose not exists, the servers fail to respond
 * this is for failure test.
 * $s_time = time();
 * $dns->Query("taner.biz", "*", true, "IN", "192.33.4.12");
 * gen_Output( "taner.biz" );
 * $dns->clearRecords("taner.biz");
 * printf("Query done in %02d Sec's.\n", time() - $s_time);
 */

/* GENERAL AND LOC RECORD TEST */
$s_time = time();
if( $dns->Query( "yahoo.com", "*", true, "IN" ) ) {
	gen_Output( $dns->cur_domain );
	$dns->clearRecords( $dns->cur_domain );
}
printf( "Query done in %02d Sec's.\n", time() - $s_time );
flush();

/* GENERAL AND LOC RECORD TEST */
$s_time = time();
if( $dns->Query( "google.com", "*", true, "IN", "192.33.4.12" ) ) {
	gen_Output( $dns->cur_domain );
	$dns->clearRecords( $dns->cur_domain );
}
printf( "Query done in %02d Sec's.\n", time() - $s_time );
flush();

/* TEST FOR HINF AND LOC RECORDS */
$s_time = time();
if( $dns->Query( "hort.net", "*", true, "IN", "192.33.4.12" ) ) {
	gen_Output( $dns->cur_domain );
	$dns->clearRecords( $dns->cur_domain );
}
printf( "Query done in %02d Sec's.\n", time() - $s_time );
flush();

/* CNAME TEST AND AAAA RECORDS*/
$s_time = time();
if( $dns->Query( "www.email.ch", "*", true, "IN", "192.33.4.12" ) ) {
	gen_Output( $dns->cur_domain );
	$dns->clearRecords( $dns->cur_domain );
}
printf( "Query done in %02d Sec's.\n", time() - $s_time );
flush();


$replace = array("array", '(', ')', "=>", "'");

echo str_replace( $replace , "", var_export($dns->t_log , true) );

function gen_Output($domain) {
	global  $dns;
		$domains = $dns->getRecords($domain);
		if( count($domains) > 0 )
		foreach( $domains as $domain => $records ) {
			echo "Domain is " . $domain . ( (php_sapi_name() == "cli")? "\n" : "<br><br>\n" );
			foreach ($records["IN"] as $type => $record) {
				foreach ($record as $rec) {
					$replace = array("array", '(', ')', "=>", "'");
					$data = is_array($rec["Responce"])?
					str_replace( $replace , "", var_export($rec["Responce"], true) )
																		 		: $rec["Responce"];
					if(php_sapi_name() == "cli") {
						printf("%-4.2s|%8d | %-60s\n", $type, $rec["TTL"], $data);
					} else {
					echo "<table>\n<tr>";
						printf("<td>%s</td><td>%d</td><td>%s</td>\n", $type, $rec["TTL"], 
																				nl2br( $data ) );
					echo "<tr>\n</table>";
				}
			}
		}
	}
}
?>
Return current item: gDNS