| Current File : //var/wcp4/asartycr-suspend/public_html/scripts/scripts/dns/index.php |
<?
#Until I rewrite my scripts, this will suffice for compatibility
if(phpversion() >= "4.2.0"){
extract($_POST);
extract($_GET);
extract($_SERVER);
extract($_ENV);
}
?>
<html>
<head>
<title>DNS Query Tool</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function m(el) {
if (el.defaultValue==el.value) el.value = ""
}
</script>
<style>
.font { FONT-FAMILY: Verdana, Arial, Helvetica,sans-serif; font-size: 7.5pt;}
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<table width="600" border="0" cellspacing="1" cellpadding="1" align="center">
<form method="post" action="<? echo $PHP_SELF; ?>">
<input type="hidden" name="queryType" value="dig">
<tr bgcolor="#D1D1D1">
<td colspan="2" align="center" class="font">
<b>DNS Query Tool</b>
<input type="text" name="target" value="Enter Host Name" onFocus="m(this)">
<input type="submit" name="Submit" value="Do It">
</td>
</tr>
</form>
</table>
<table width="600" border="0" cellspacing="1" cellpadding="1" align="center">
<tr>
<td class="font">
<?
#Global kludge for new gethostbyaddr() behavior in PHP 4.1x
$ntarget = "";
#Some functions
function message($msg){
echo "$msg";
flush();
}
function dig($target){
global $ntarget;
message("<b>DNS Query Results:</b><br>");
#$target = gethostbyaddr($target);
#if (! eregi("[a-zA-Z]", ($target = gethostbyaddr($target))) )
if( (!eregi("[a-zA-Z]", $target) && (!eregi("[a-zA-Z]", $ntarget))))
$msg .= "Can't do a DNS query without a hostname.";
else{
if(!eregi("[a-zA-Z]", $target)) $target = $ntarget;
if (! $msg .= trim(nl2br(`dig any '$target'`))) #bugfix
$msg .= "The <i>dig</i> command is not working on your system.";
}
#TODO: Clean up output, remove ;;'s and DiG headers
message($msg);
}
#If the form has been posted, process the query, otherwise there's
#nothing to do yet
if(!$queryType)
exit;
#Make sure the target appears valid
if( (!$target) || (!preg_match("/^[\w\d\.\-]+\.[\w\d]{1,4}$/i",$target)) ){ #bugfix
message("Error: You did not specify a valid target host or IP.");
exit;
}
#Figure out which tasks to perform, and do them
if( ($queryType=="all") || ($queryType=="dig") )
dig($target);
?>
</td>
</tr>
</table>