"") { if(!$isfirst) $addresses .= " "; $addresses .= $re . "/32"; $isfirst = false; } } $newalias = array(); $aliasname = str_replace(array(".","-"), "_", $host); $alias_exists = false; $counter=0; foreach($a_aliases as $a) { if($a['name'] == $aliasname) { $alias_exists = true; $id=$counter; } $counter++; } if($override) $alias_exists = false; if($alias_exists == false) { $newalias['name'] = $aliasname; $newalias['type'] = "network"; $newalias['address'] = $addresses; $newalias['descr'] = "Created from Diagnostics-> DNS Lookup"; if($override) $a_aliases[$id] = $newalias; else $a_aliases[] = $newalias; write_config(); $createdalias = true; } } } if ($_POST) { unset($input_errors); $reqdfields = explode(" ", "host"); $reqdfieldsn = explode(",", "Host"); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); $host = trim($_POST['host'], " \t\n\r\0\x0B[]"); $host_esc = escapeshellarg($host); if (!is_hostname($host) && !is_ipaddr($host)) { $input_errors[] = gettext("Host must be a valid hostname or IP address."); } else { // Test resolution speed of each DNS server. $dns_speeds = array(); $resolvconf_servers = `grep nameserver /etc/resolv.conf | cut -f2 -d' '`; $dns_servers = explode("\n", trim($resolvconf_servers)); foreach ($dns_servers as $dns_server) { $query_time = `dig {$host_esc} @{$dns_server} | grep Query | cut -d':' -f2`; if($query_time == "") $query_time = gettext("No response"); $new_qt = array(); $new_qt['dns_server'] = $dns_server; $new_qt['query_time'] = $query_time; $dns_speeds[] = $new_qt; unset($new_qt); } } $type = "unknown"; $resolved = ""; $ipaddr = ""; $hostname = ""; if (!$input_errors) { if (is_ipaddr($host)) { $type = "ip"; $resolved = gethostbyaddr($host); $ipaddr = $host; if ($host != $resolved) $hostname = $resolved; } elseif (is_hostname($host)) { $type = "hostname"; $resolved = gethostbyname($host); if($resolved) { $dig=`dig $host_esc A | grep $host_esc | grep -v ";" | awk '{ print $5 }'`; $resolved = explode("\n", $dig); } $hostname = $host; if ($host != $resolved) $ipaddr = $resolved[0]; } if ($host == $resolved) { $resolved = gettext("No record found"); } } } include("head.inc"); ?>
= "") { echo $hostitem . "
"; $found++; } } } else { echo $resolved; } if($found > 0) { if($alias_exists) { echo "
An alias already exists for the hostname " . htmlspecialchars($host) . ". To overwrite, click here."; } else { if(!$createdalias) { echo "
Create alias out of these entries."; } else { echo "
Alias created with name " . htmlspecialchars($newalias['name']); } } } ?>




 
  ">