#!/usr/bin/perl -Tw # # Author : C Matthew Curtin # Created On : <1997/11/18 16:53:21> # Last Modified By: $Author: cmcurtin $ # Last Modified On: $Date: 2003/07/23 15:31:53 $ # Update Count : # Status : # use strict; use CGI; $|=1; my $dig; my $cgi = new CGI; # Find where dig lives on this system if ( -x "/usr/local/bin/dig" ) { $dig = "/usr/local/bin/dig"; } elsif ( -x "/usr/bin/dig" ) { $dig = "/usr/bin/dig"; } elsif ( -x "/opt/bin/dig" ) { $dig = "/opt/bin/dig"; } else { print_header(); print $cgi->start_html(-bgcolor=>'#ffffff', -title=>'DiG: error', -author=>'cmcurtin@interhack.net', -base=>'true'), $cgi->h1("DiG: error"), $cgi->p("The dig command could not be found in any of the following directories on the host system: /usr/local/bin, /usr/bin, /opt/bin."), $cgi->hr; print < Interhack | Matt | Perl EOD print "
C Matthew Curtin
\n"; print $cgi->end_html; exit 1; } &print_header; &start_page; &print_page; print $cgi->hr; print < Interhack | Matt | Perl EOD print "
C Matthew Curtin
\n"; print $cgi->end_html; sub print_header() { print $cgi->header(-type => 'text/html', -expires => '+1h'); } sub start_page() { print $cgi->start_html(-bgcolor=>'#ffffff', -title=>'DiG', -author=>'cmcurtin@interhack.net', -base=>'true'); } sub print_page() { print $cgi->h1("DiG"); print $cgi->p("This is a utility that's like nslookup but more verbose. For folks behind firewalls or without access to a dig or nslookup program, this might be of use."); print $cgi->p("Feel free to throw me mail, and let me know what you think, or to suggest enhancements."); print $cgi->startform(-name => "dig", -method => "GET"); print $cgi->p("Search for what object in the directory?"); print $cgi->p($cgi->popup_menu(-name => 'type', -'values' =>['any', 'reverse', 'NS', 'A', 'MX', 'CNAME', 'SOA', 'MB', 'MG', 'MR', 'WKS', 'PTR', 'HINFO', 'RP'], -default =>'any'), $cgi->textfield(-name => "lookup", -size => "30")); print $cgi->p($cgi->reset, $cgi->submit); return unless $cgi->param; print $cgi->hr, $cgi->h2("Results of search for " . $cgi->param('lookup') . ""); print <
EOD

  my $type;

  if ($cgi->param('type') eq "reverse") {
    $type = "-x";
  } else {
    $type = $cgi->param('type');
  }
  system($dig, $type, $cgi->param('lookup'));
  print <
      
    
  
EOD
}