#native_company# #native_desc#
#native_cta#

Dig It

By Jason Chambers
on February 10, 2002

Version: 1.0

Type: Full Script

Category: Networking

License: GNU General Public License

Description: html/php uses unix dig to get host information

<html>
<head>
<title> :: Dig It :: </title>
<script>
function m(el) {
	if (el.defaultValue==el.value) el.value = ""
               }
</script>
</head>


<body bgcolor="#010190">
<div align="center">
   <form method="post" action="<? echo $PHP_SELF; ?>">
	<table align="center" width="50%" border="1" cellspacing="0" cellpadding="1">
	  <tr bgcolor="#3A3AF5">
	    <td width="40%" bgcolor="#B0AFB0"><font size="2" face="Verdana" color="#DCDBDC">
	      Dig up info for: 
	    </td>
	    <td width="60%" bgcolor="#B0AFB0"><font size="2" face="Verdana" color="#DCDBDC">
		<input type="text" name="target" value="domain.com" onFocus="m(this)">
	    </td>
	  </tr>
	  <tr>
	    <td width="40%" bgcolor="#DCDBDC"><font size="2" face="Verdana" color="#B0AFB0">
	      Choose Server: 
	    </td>
	    <td width="60%" bgcolor="#DCDBDC"><font size="2" face="Verdana" color="#B0AFB0">
	      <Select name="chServ">
		<option>ns1.telusplanet.net
		<option>ns2.telusplanet.net
		<option>ns1.cadvision.com
		<option>ns2.cadvision.com
                <option> add more name servers
			</select>
	    </td>
	  </tr>
	  <tr>
	    <td width="40%" bgcolor="#B0AFB0"><font size="2" face="Verdana" color="#DCDBDC">
	      Query Type:
	    </td>
	    <td width="60%" bgcolor="#B0AFB0"><font size="2" face="Verdana" color="#DCDBDC">
		<input type="radio" name="qt" value="any" checked>ANY &nbsp &nbsp
		<input type="radio" name="qt" value="a"> A &nbsp&nbsp
		<input type="radio" name="qt" value="mx"> MX <br>
		<input type="radio" name="qt" value="ns"> NS &nbsp&nbsp&nbsp
		<input type="radio" name="qt" value="soa">SOA &nbsp  
		<input type="radio" name="qt" value="hinfo"> HINFO
	    </td>
	  </tr>
	  <tr>
	    <td width="40%" bgcolor="#DCDBDC"><font size="2" face="Verdana" color="#B0AFB0">
	      READY?
	    </td>
	    <td width="60%" bgcolor="#DCDBDC"><font size="2" face="Verdana" color="#B0AFB0">
	      <input type="submit" name="submit" value="DIG IT!"
	    </td>
	  </tr>
	</table>
    </form>
</div>
<table border="0">
  <tr>
    <td width="200">
	<img src="./magglass.gif">
    </td>
    <td >

<?

#Start to produce some output

function message($msg){
echo "<font color=ffffff face="Verdana" size=2>$msg</font>";
flush();
                      }

function dig($target, $qt, $chServ){
message("<b>DIG Results:</b><br><blockquote>");
#$target = gethostbyaddr($target);
if (! eregi("[a-zA-Z]", ($target = gethostbyaddr($target))) )
	$msg .= "Can't do a DNS query without a hostname.";
else{
  if (! $msg .= trim(nl2br(`dig @'$chServ' any '$target' '$qt' +noquestion +noshort `)))
    $msg .= "The <i>dig</i> command is not working on your system.";
  }

$msg .= "</blockquote>";

$msg = str_replace(";", "", $msg);

message($msg);
}

if(!$qt)
  exit;

if( (!$target) || (!preg_match("/^[wd.-]+.[wd]{1,3}$/i",$target)) )
{ 
  message("Error: You did not specify a valid target host or IP.");
  exit;
}

dig($target, $qt, $chServ);


?>


  </td>
 </tr>
</table>
</body>
</html>