#!/usr/local/bin/perl
# edit_record.cgi
# Edit an existing record of some type

require './bind8-lib.pl';
&ReadParse();
$conf = &get_config();
if ($in{'view'} ne '') {
	$conf = $conf->[$in{'view'}]->{'members'};
	}
$zconf = $conf->[$in{'index'}];
$dom = $conf->[$in{'index'}]->{'value'};
%access = &get_module_acl();
&can_edit_zone(\%access, $conf->[$in{'index'}]) ||
	&error($text{'recs_ecannot'});
$file = &find("file", $zconf->{'members'})->{'value'};
@recs = &read_zone_file($file, $dom);
$rec = $recs[$in{'num'}];

&header(&text('edit_title', $text{"edit_".$rec->{'type'}}), "");
print "<center><font size=+2>",
      &text('edit_header', &ip6int_to_net(&arpa_to_ip($dom))),
      "</font></center>\n";
print "<hr>\n";

&record_input($in{'index'}, $in{'view'}, $in{'type'}, $file,
	      $zconf->{'value'}, $in{'num'}, $rec);
print "<hr>\n";
&footer("edit_recs.cgi?index=$in{'index'}&type=$in{'type'}",
	$text{'edit_return'});

