⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 save_soa.cgi

📁 BIND 9 dynamic DNS webmin module. This module supports both static and dynamic zones, and IPv4 and I
💻 CGI
字号:
#! /usr/bin/perl##    B9DDNS - BIND 9 dynamic DNS webmin module.#    Copyright (C) 2003 John Horne. <john.horne@plymouth.ac.uk>#    Copyright (C) 2004 John Horne. <john.horne@plymouth.ac.uk>##    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; either version 2 of the License, or#    (at your option) any later version.##    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., 675 Mass Ave, Cambridge, MA 02139, USA.### Save changes to an SOA record.#use strict;no strict 'vars';require './b9ddns-lib.pl';my $serial = my $new_serial = my $dynamic_zone = my $ttl = 0;my $conf = my $zone = my $view = my $old_rec = my $zone_ref = '';my $time = my $refresh = my $retry = my $expiry = my $neg_cache = '';my $serial_str = my $host = my $master = my $hostmaster = '';my $file = my $real_file = my $values = '';my @recs = ();my $space = ' ';my $nltabs = "\n\t\t\t";&ReadParse();&error_setup($text{'master_err2'});%access = &get_module_acl();$conf = &get_config();if ($in{'view'}) {	$view = $conf->[$in{'view'}];	$conf = $view->{'members'};}$zone = $conf->[$in{'index'}];unless (&can_edit_zone(\%access, $zone, $view)) {	&terror('master_ecannot');}if ($access{'ro'}) {	&terror('master_ero');}unless ($access{'params'}) {	&terror('master_esoacannot');}$zone_ref = &get_zone_data($zone);$dynamic_zone = $zone_ref->[1];if ($dynamic_zone == 2) {	&terror('recs_eupdate');}## Check the input values.#$file = $in{'file'};$real_file = $config{'chroot'} . &absolute_path($file) if ($file);$host = $in{'origin'};$master = $in{'master'};unless (&valdnsname($master, 0, $in{'origin'})) {	&terror('master_emaster', $master);}&trim($in{'email'});$hostmaster = $in{'email'};unless ($hostmaster) {	&terror('master_eemail_missing');}elsif ($hostmaster ne '.' && &valemail($hostmaster)) {	$hostmaster = &email_to_dotted($hostmaster, $in{'origin'});}else {	&terror('master_eemail', $hostmaster);}if (! $in{'serial'} || $in{'serial'} =~ /\D/o) {	&terror('master_eserial');}if ($in{'serial'} < $in{'oldserial'}) {	&terror('master_eserial_toolow');}$time = $in{'refresh'} . $in{'refunit'};$refresh = &convert_time(0, $time);unless ($refresh) {	&terror('master_erefresh', $time);}$time = $in{'retry'} . $in{'retunit'};$retry = &convert_time(0, $time);unless ($retry) {	&terror('master_eretry', $time);}$time = $in{'expiry'} . $in{'expunit'};$expiry = &convert_time(0, $time);unless ($expiry) {	&terror('master_eexpiry', $time);}if ($expiry < $refresh || $expiry < $retry) {	&terror('master_eexpiry_toolow');}$time = $in{'ncache'} . $in{'ncacheunit'};$neg_cache = &convert_time(0, $time);unless ($neg_cache) {	&terror('master_encache', $time);}unless ($dynamic_zone) {	&lock_file($real_file);		# Do this first so no-one changes the					# serial number beneath us.	@recs = &get_zone(0, $file, $in{'origin'}, undef, $in{'type'});	$old_rec = $recs[$in{'num'}];}## Check that we can update the serial number. For dynamic zones we must# increase the serial number otherwise the changes are ignored.#$new_serial = &check_serial_number($zone_ref, $zone, \@recs, undef);if ($dynamic_zone) {	$serial_str = &get_soa_rec($zone, undef, undef);	if ($serial_str =~ /^(\S+)\s+(\d+)\s+IN\s+SOA\s+\S+\s+\S+\s+(\d+)/o) {		$host = $1; $ttl = $2; 	}	else {		&terror('soa_serial_invalid');	}	if ($in{'serial'} == $in{'oldserial'}) {		if ($new_serial == 1) {			$new_serial = $3 + 1;		}	}	else {		$new_serial = $in{'serial'};	}}else {	$host = $old_rec->{'fqdn'};	$ttl = ($old_rec->{'ttl'} == 0) ? undef : $old_rec->{'ttl'};	if ($config{'updserial_on'}) {		if ($in{'serial'} != $in{'oldserial'}) {			$new_serial = $in{'serial'};		}	}	else {		$new_serial = $old_rec->{'values'}->[2];	}}## Check that the new serial number is valid.#if ($config{'soa_date_style'}) {	if ($config{'serial_exceed99'} == 0 &&			&calc_secs(substr($new_serial, 0, 8)) > time()) {		&terror('master_eserial_toohigh');	}	unless (&valid_date($new_serial)) {		&terror('soa_serial_invalid');	}}$values = sprintf('%s %s %s%s%s%s%s%s%s%s%s%s%s', $master, $hostmaster,			($dynamic_zone) ? ''     : "($nltabs", $new_serial,			($dynamic_zone) ? $space : $nltabs, $refresh,			($dynamic_zone) ? $space : $nltabs, $retry,			($dynamic_zone) ? $space : $nltabs, $expiry,			($dynamic_zone) ? $space : $nltabs, $neg_cache,			($dynamic_zone) ? ''     : ')');## Now we can update the SOA record.#&modify_record($zone, $file, $old_rec, $host, $ttl, 'IN', 'SOA', $values);&unlock_file($real_file);&webmin_log('soa', undef, $in{'origin'}, \%in);&redirect("edit_zone.cgi?index=$in{'index'}&view=$in{'view'}&type=$in{'type'}");exit;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -