"") { 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']); $host_esc = escapeshellarg(trim($_POST['host'])); if (!is_hostname($host) && !is_ipaddr($host)) $input_errors[] = gettext("Host must be a valid hostname or IP address."); // Test resolution speed of each DNS server. if ((is_hostname($host) || is_ipaddr($host))) { $dns_speeds = array(); list($pconfig['dns1'],$pconfig['dns2'],$pconfig['dns3'],$pconfig['dns4']) = $config['system']['dnsserver']; for ($dnscounter=1; $dnscounter<5; $dnscounter++) { $dns_server = $pconfig['dns' . $dnscounter]; $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 = split("\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']); } } } ?>




 
  ">