| 
<?phpinclude_once('./geoip.class.php');
 include_once('./ping.class.php');
 
 function PrintUsage($string = '')
 {
 if($string != '') {
 echo $string . "\n\n";
 }
 
 echo 'php index_dns.php [addr] [-r|-s]' . "\n";
 echo "\t" . '[addr] mandatory: The host (IP address or host name) to resolve...' . "\n";
 echo "\t" . '[-r] optionnal: send a reverse request (Name -> IP)' . "\n";
 echo "\t" . '[-s] optionnal: Query the status of the Domain Name Server' . "\n";
 echo "\t" . '[-a] optionnal: See ALL Domain Name Server' . "\n";
 die("\n");
 
 die("\n");
 }
 
 if($argc <= 1) {
 PrintUsage('Paramètre(s) invalide(s)...');
 die("\n");
 }
 
 $config = array();
 $config['value'] = $argv[1];
 // $config['provider'] = 'OVH';
 
 $ping = new CPing();
 switch($argv[2])
 {
 case '-a':
 $ping->FillDNSServerList();
 foreach($ping->m_straDNSServerList as $name => $servers)
 {
 echo $name . "\n";
 foreach($servers as $server)
 {
 if(is_array($server))
 continue;
 
 echo "\t" . $server . ' (IPV4)' . "\n";
 }
 if(isset($servers['ipv6']))
 {
 foreach($servers['ipv6'] as $server)
 echo "\t" . $server . ' (IPV6)' . "\n";
 }
 }
 break;
 case '-r':
 default:
 if($argc >= 3 && in_array('-r', $argv))
 $config['reverse'] = true;
 $output = $ping->DNSSolve($config);
 
 if($output === false)
 echo 'Erreur de requête DNS pour: ' . $argv[1] . "\n";
 else
 {
 $not_found = true;
 foreach($output['records'] as $record)
 {
 if($record->Type == DNS_CLASS_A && $record->TTL > 0)
 {
 echo 'Host IP: ' . $record->rdData->ip . "\n";
 $not_found = false;
 }
 else if($record->Type == DNS_CLASS_CNAME && $record->TTL > 0)
 {
 echo 'Host IP (alias): ' . $record->rdData->cname . "\n";
 $not_found = false;
 }
 else if($record->Type == DNS_CLASS_PTR && $record->TTL > 0)
 {
 echo 'Host name: ' . $record->rdData->ptrdname . "\n";
 $not_found = false;
 }
 else
 {
 echo 'Unknwon record: ' . "\n";
 var_dump($record);
 }
 }
 foreach($output['authority'] as $authority)
 {
 if($authority->Type == DNS_CLASS_SOA)
 {
 echo 'General informations: ' . "\n";
 echo "\t" . 'Original domain name: ' . $authority->rdData->mname . "\n";
 echo "\t" . 'Responsible person\'s mail: ' . $authority->rdData->rname . "\n";
 echo "\t" . 'Original version serial: ' . $authority->rdData->serial . "\n";
 echo "\t" . 'Refresh information every: ' . (int)($authority->rdData->refresh / 60) . ',' . ($authority->rdData->refresh % 60) . 's' . "\n";
 echo "\t" . 'Authoritative expire in: ' . (int)($authority->rdData->expire / 60) . ',' . ($authority->rdData->expire % 60) . 's' . "\n";
 
 }
 }
 
 if($not_found === true)
 echo $argv[1] . ' est incoonue...' . "\n";
 }
 
 break;
 
 case '-s':
 $output = $ping->DNSStatus();
 if($output['status'] === true)
 echo $output['name'] . ' (' . $output['ip'] . ') is ONLINE...' . "\n";
 else
 echo $output['name'] . ' (' . $output['ip'] . ') is OFFLINE...' . "\n";
 
 break;
 }
 
 ?>
 |