#!/usr/bin/perl

# dnsman 0.66 - createreverse.cgi
#
# Copyright (C) 2000,2001 Hampton Maxwell <maxwell@101freeway.com>
# See COPYRIGHT for details
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; under version 2 of the License. If you
# wish to use a later version, you must obtain permission from the author.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

use CGI::Carp qw(fatalsToBrowser); # log errors to browser window

require './config.cgi';
require './functions.cgi';

# set values before parsing so they can't be overridden
use vars qw($basedir $chroot $dnsconf);

$basedir = $FORM{'BASEDIR'};
$chroot = $FORM{'CHROOT'};

if ($FORM{'CONFLOCATION'}) { $::dnsconf = $FORM{'CONFLOCATION'}; }
elsif ($FORM{'CONFIGFILE'}) { $::dnsconf = "$FORM{'CONFIGFILE'}"; }
else { $::dnsconf = "named.conf"; }
$::dnsconf = &clean_filename($::dnsconf);

&parse_form;

&html_header("Reverse DNS Zone Creation");

print("
<FORM Method=post Action=\"writereverse.cgi\">
<INPUT TYPE=submit NAME=SUBMITTYPE VALUE=Create><BR>
");

if ($FORM{'SHOWNS'} eq "yes") { &showns; }
if ($FORM{'SHOWTIMEOUTS'} eq "yes") { &showtimeouts; }

print "<B>Record filename: </B>(blank to automatically generate) \n";
&enter_filename("reverse", "RECDIR", "RECORDFILE", "", "REV");

print "<BR>Corresponding forward dns file (blank will not create): \n";
&enter_filename("forward", "FWDDIR", "FWDFILE", "", "FWD");

print ("<BR><BR>
Add forward file to domain using \$INCLUDE \? <SELECT NAME=\"INCLUDE\">
<OPTION>no</OPTION>
<OPTION>yes</OPTION>
</SELECT><BR>
If yes, name of domain file (blank to use domain name): \n");
&enter_filename("forward", "MSTRDIR", "MSTRFILE", "", "MSTR");

print ("<BR><BR>
<B>Start IP: </B><INPUT TYPE=text SIZE=20 NAME=STARTIP><BR>
<B>Stop IP: </B><INPUT TYPE=text SIZE=3 NAME=STOPIP> (within 1 class C)<BR>
<BR>

<B>Host: </B><INPUT TYPE=text SIZE=15 NAME=REVHOST><BR>
<B>Domain: </B><INPUT TYPE=text SIZE=20 NAME=DOMAIN VALUE=\"$FORM{'REVDOMAIN'}\"><BR>
Format of hostname (blank for default): <INPUT TYPE=text SIZE=30 NAME=REVFORMAT><B>\.DOMAIN</B><BR>
<I>HOST substitutes host segment.<BR>
IP1, IP2, IP3 and IP4 substitute the segment of the ip address (IP1.IP2.IP3.IP4)<BR>
The default is HOST-IP1-IP2-IP3-IP4.DOMAIN<BR>
which would produce a record like isp-192-168-0-1.myisp.net</I><BR>
<BR>

<INPUT TYPE=submit NAME=SUBMITTYPE VALUE=Create><BR><BR>
");
&html_footer;

exit;
