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

📄 save_gen.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 $GENERATE records.#use strict;no strict 'vars';require './b9ddns-lib.pl';my $start = my $end = my $skip = my $i = 0;my $conf = my $zone = my $zone_conf = my $origin = my $file = '';my $lhs = my $lhsfull = my $rhs = my $rhsfull = '';my $gen = my $view = my $zone_hdr = '';my $fwdconf = my $fwdfile = my $fwdrec = '';my @recs = my @gens = my @gv = ();my $wildchar = ($config{'allow_wild'} ? '*' : '');my $underscore = $config{'allow_underscore'} ? '_' : '';&ReadParse();%access = &get_module_acl();unless ($access{'gen'}) {	&terror('gen_ecannot');}$conf = &get_config();if ($in{'view'}) {	$view = $conf->[$in{'view'}];	$conf = $view->{'members'};}$zone = $conf->[$in{'index'}];$zone_conf = $zone->{'members'};$origin = lc($zone->{'value'});$origin .= '.' unless ($origin =~ /\.$/o);unless (&can_edit_zone(\%access, $zone, $view)) {	&terror('recs_ecannot');}$file = $in{'file'};@recs = &get_zone(0, $file, $origin, undef, $in{'type'});@gens = grep { $_->{'generate'} } @recs;if ($in{'show'}) {	#	# Just show what would be generated.	#	$zone_hdr = &zone_header($in{'dynamic'}, $origin, $text{'Master'});	&header($text{'gen_title2'}, '', undef, 0, 0, 0, undef, undef, undef, $zone_hdr);	$zone_hdr = $origin;	unless ($config{'display_fqdn'}) {		$zone_hdr = &convert_fqdn(-1, $zone_hdr, '.', 1);	}	print '<center><font size=+2>', $zone_hdr, '</font></center>';	print '<hr>';	print '<table border width=100%>';	print "<tr $tb><td><b>$text{'recs_name'}</b></td>",	      '<td><b>', $text{'recs_type'}, '</b></td>',	      '<td><b>', $text{'recs_ttl'}, '</b></td>',	      '<td><b>', $text{'recs_vals'}, '</b></td>',	      '<td><b>', $text{'gen_raw'}, "</b></td></tr>\n";	foreach $gen (@gens) {		@gv = @{ $gen->{'generate'} };		if ($gv[0] =~ /^(\d+)-(\d+)\/(\d+)$/o) {			$start = $1; $end = $2; $skip = $3;		}		elsif ($gv[0] =~ /^(\d+)-(\d+)$/o) {			$start = $1; $end = $2; $skip = 1;		}		else {			next;		}		for ($i = $start; $i <= $end; $i += $skip) {			$lhs = $gv[1];			$lhs =~ s/\$\$/\0/go;			$lhs =~ s/\$/$i/g;			$lhs =~ s/\0/\$/go;			$lhsfull = ($lhs =~ /\.$/o) ? $lhs :				    ($origin eq '.') ? "$lhs." : "$lhs.$origin";			$rhs = $gv[3];			$rhs =~ s/\$\$/\0/go;			$rhs =~ s/\$/$i/g;			$rhs =~ s/\0/\$/go;			$rhsfull = ($rhs =~ /\.$/o) ? $rhs :				    ($origin eq '.') ? "$rhs." : "$rhs.$origin";			print "<tr $cb>\n";			print '<td>', &arpa_to_ip($lhsfull), '</td>';			print '<td>', $gv[2], '</td>';			print '<td>', $text{'default'}, '</td>';			print '<td>', &arpa_to_ip($rhsfull), '</td>';			print "<td><tt>$lhs IN $gv[2] $rhs</tt></td>\n";			print "</tr>\n";		}	}	print '</table><br>';	print '<hr>';	&footer("list_gen.cgi?index=$in{'index'}&view=$in{'view'}&type=$in{'type'}&file=${file}&dynamic=$in{'dynamic'}",		lc($text{'gen_title'}));	exit;}## Parse and validate inputs.#&error_setup($text{'gen_err'});for ($i = 0; defined($in{"type_$i"}); $i++) {	if ($in{"type_$i"}) {		@gv = ();		if ($in{"start_$i"} =~ /\D/o) {			&terror('gen_estart', $i + 1);		}		if ($in{"stop_$i"} =~ /\D/o) {			&terror('gen_estop', $i + 1);		}		if ($in{"start_$i"} > $in{"stop_$i"}) {			&terror('gen_erange', $i + 1);		}		unless ($in{"skip_$i"} =~ /^\d*$/o) {			&terror('gen_eskip', $i + 1);		}		unless ($in{"name_$i"} =~ /^[-.a-z\d\$$underscore$wildchar]+$/i) {			&terror('gen_ename', $i + 1);		}		unless ($in{"value_$i"} =~ /^[-.a-z\d\$$underscore$wildchar]+$/i) {			&terror('gen_evalue', $i + 1);		}		if ($in{"type_$i"} ne 'NS') {			if ($in{"type_$i"} eq 'PTR') {				($fwdconf, $fwdfile, $fwdrec) = &find_forward($in{"value_$i"}, undef, 1);				unless (&check_tld($in{"value_$i"}, $fwdconf,					\%access, 'master', $in{"type_$i"})) {					&terror('edit_tld');				}				unless (&check_sd($in{"value_$i"}, $fwdconf,					\%access, 'master', $in{"type_$i"})) {					&terror('edit_sd');				}			}			else {				unless (&check_tld($in{"name_$i"}, $origin,					\%access, 'master', $in{"type_$i"})) {					&terror('edit_tld');				}				unless (&check_sd($in{"name_$i"}, $origin,					\%access, 'master', $in{"type_$i"})) {					&terror('edit_sd');				}			}		}		push(@gv, $in{"start_$i"} . '-' . $in{"stop_$i"});		if ($in{"skip_$i"}) {			$gv[$#gv] .= '/' . $in{"skip_$i"};		}		push(@gv, $in{"name_$i"});		push(@gv, $in{"type_$i"});		push(@gv, $in{"value_$i"});		push(@gv, $in{"cmt_$i"}) if ($in{"cmt_$i"});		if ($i < @gens) {			&modify_generator($file, $gens[$i], @gv);		}		else {			&create_generator($file, @gv);		}	}	else {		if ($i < @gens) {			&delete_generator($file, $gens[$i]);			foreach $gen (@gens) {				if ($gen->{'line'} > $gens[$i]->{'line'}) {					$gen->{'line'}--;				}			}		}	}}&bump_soa_record($zone, \@recs);&redirect("edit_zone.cgi?index=$in{'index'}&view=$in{'view'}&type=$in{'type'}");exit;

⌨️ 快捷键说明

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