#!/usr/bin/perl

# dnsman 0.66 - createslave.cgi
#
# Copyright (C) 2000 Hampton Maxwell, 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("DNS Header creation");

print "
<FORM Method=post Action=writezone.cgi>
<INPUT TYPE=hidden NAME=ACTION VALUE=createslave>
<INPUT TYPE=submit NAME=SUBMITTYPE VALUE=Create><BR>

<B>Domain:</B> <INPUT TYPE=text SIZE=20 NAME=DOMAIN>
(network's ip address may be used for reverse records)<BR>\n";

my @validviews;
if ($FORM{'BINDVERSION'} eq "BIND9") { @validviews = get_views(); }
if (@validviews) {
    print "Assign to the view: <SELECT NAME=VIEW>\n";
    my $view = shift(@validviews);
    print "<OPTION VALUE=\"\" SELECTED>Default View</OPTION>\n";
    print "<OPTION>$view</OPTION>\n";
    foreach $view (@validviews) {
        print "<OPTION>$view</OPTION>\n";
    }
    print "</SELECT>\n<BR>\n";
}

print "Record filename: (blank to use domain name) ";
&enter_filename("forward", "RECDIR", "RECORDFILE", "", "");

if (!$FORM{'SLAVESLURP'}) { $FORM{'SLAVESLURP'} = "no"; }

print "<BR>
<B>Master server</B> (to pull record from):
<INPUT TYPE=text NAME=MASTER SIZE=20 VALUE=\"$FORM{'MASTER'}\"><BR>
Generate zonefile by querying master:
<FONT SIZE=-1><A HREF=usageguide.html#slaveslurp>Help</A></FONT>
<SELECT NAME=SLAVESLURP>
<OPTION SELECTED>$FORM{'SLAVESLURP'}</OPTION>
<OPTION>yes</OPTION>
<OPTION>no</OPTION>
</SELECT><BR>
<BR>
<INPUT TYPE=submit NAME=SUBMITTYPE VALUE=Create>
</FORM>\n";

&html_footer;
exit;
