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

📄 edit_recs.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.### Display records of some type from some domain.#use strict;no strict 'vars';require './b9ddns-lib.pl';my $read_only = my $dynamic = my $default_ttl = my $mid = 0;my $reverse = my $ipv4_zone = my $slave_upd = 0;my $total_count = my $visible_count = my $use_value = 0;my $conf = my $view = my $origin = my $type = my $file = my $value = '';my $zone = my $zone_conf = my $zone_ref = my $zone_hdr = my $rtype = '';my $hide_recs = my $show_recs = my $hidden_str = my $show_str = '';my $hide_url = my $show_url = my $re = '';my @recs = ();local %hmap = ();&ReadParse();$conf = &get_config();if ($in{'view'}) {	$view = $conf->[$in{'view'}];	$conf = $view->{'members'};}$zone = $conf->[$in{'index'}];$zone_conf = $zone->{'members'};%access = &get_module_acl();unless (&can_edit_zone(\%access, $zone, $view)) {	&terror('recs_ecannot');}$hide_recs = $in{'hide'};$hide_url = &urlize($hide_recs);$show_recs = $in{'show'};$show_url = &urlize($show_recs);$use_value = $in{'use_value'};$origin = lc($zone->{'value'});$origin .= '.' unless ($origin =~ /\.$/o);if ($origin =~ /\.(in-addr|ip6)\.arpa\.$/o) {	$reverse++;	$ipv4_zone++ if ($1 eq 'in-addr');}if ($hide_recs) {	$hidden_str = '(';	foreach $re (split(/\s+/, $hide_recs)) {		$hidden_str .= $re . '|';	}	$hidden_str =~ s/\|$/\)/o;}if ($show_recs) {	$show_str = '(';	foreach $re (split(/\s+/, $show_recs)) {		$show_str .= $re . '|';	}	$show_str =~ s/\|$/\)/o;}$zone_ref = &get_zone_data($zone);$dynamic = $zone_ref->[1];$default_ttl = $zone_ref->[2];$read_only = ($access{'ro'} || $dynamic == 2);$rtype = $in{'type'};$type = $in{'ztype'};$file = $in{'file'};$slave_upd++ if ($type eq 'slave' && $dynamic == 1);$zone_hdr = &zone_header($dynamic, $origin, $text{ucfirst($type)});&header(&text('recs_title', $text{"recs_$rtype"}), '', undef, 0, 0, 0, undef, undef, undef, $zone_hdr);$zone_hdr = $origin;unless ($config{'display_fqdn'}) {	$zone_hdr = &convert_fqdn(-1, $zone_hdr, '.', 1);}$zone_hdr = $text{'Root'} if ($zone_hdr eq '.');print '<center><font size=+2>', $zone_hdr, "</font></center><hr>\n";if (! $read_only && ($type eq 'master' || $slave_upd) && $rtype ne 'ALL') {	if ($rtype eq 'SRV') {		print $text{'srv_underscores'}, '<p>';	}	elsif ($reverse && ! $ipv4_zone && $rtype eq 'DNAME') {		print $text{'dname_zeros'}, '<p>';	}	&record_input($in{'index'}, $in{'view'}, $rtype, $file, $origin);}#@recs = grep { ! $_->{'generate'} } &get_zone($zone, $file, $origin);@recs = &get_zone($zone, $file, $origin);if ($rtype ne 'ALL') {	@recs = grep { $_->{'type'} eq $rtype } @recs;	$total_count = @recs;	if ($hidden_str) {		if ($use_value) {			@recs = grep { $_->{'values'}->[0] !~ /$hidden_str/ } @recs;		}		else {			@recs = grep { $_->{'fqdn'} !~ /$hidden_str/ } @recs;		}		$visible_count = @recs;	}	if ($show_str) {		if ($use_value) {			@recs = grep { $_->{'values'}->[0] =~ /$show_str/ } @recs;		}		else {			@recs = grep { $_->{'fqdn'} =~ /$show_str/ } @recs;		}		$visible_count = @recs;	}}if (($hidden_str || $show_str) && $rtype ne 'ALL' &&				($total_count - $visible_count) != 0) {	my $hidden = $total_count - $visible_count;	if ($total_count == $hidden) {		if ($total_count == 1) {			print &text('edit_filtered_all1', $total_count);		}		else {			print &text('edit_filtered_all', $total_count);		}	}	else {		print &text('edit_filtered_found', $total_count,						$hidden, $visible_count);	}	print '<br><br>';}if (@recs) {	$mid = 0;	if ($reverse) {		$mid = ($ipv4_zone) ? 1 : 2;	}	@recs = &sort_records(@recs, $mid, $origin);	foreach $value (keys(%text)) {		if ($value =~ /^value_(\S+)(\d+)$/o) {			$hmap{$1}->[$2 - 1] = $text{$value};		}	}	if ($rtype =~ /(HINFO|WKS|RP|KEY|LOC|TXT)/io ||	    ($reverse && ! $ipv4_zone && $config{'display_fqdn'}) ||	    (! $dynamic && $config{'allow_comments'})) {		&recs_table(@recs);	}	else {		$mid = int((@recs + 1) / 2);		print '<table width=100%><tr><td width=50% valign=top>';		&recs_table(@recs[0 .. ($mid - 1)]);		print '</td><td width=50% valign=top>';		if ($mid < @recs) {			&recs_table(@recs[$mid .. $#recs]);		}		print '</td></tr></table><p>';	}	print "<p>\n";}elsif ($access{'ro'} || ($type ne 'master' && ! $slave_upd)) {	print '<center>', $text{'no_specific_zone_recs'}, '</center>';}print '<hr>';$rtype = "edit_zone.cgi?index=$in{'index'}&view=$in{'view'}&type=$type";$rtype .= '&hide=' . $hide_url if ($hide_recs);$rtype .= '&show=' . $show_url if ($show_recs);$rtype .= '&use_value=1' if ($use_value);&footer('', $text{'index_return'}, $rtype, $text{'recs_return'});exit;sub recs_table {	my $ttl = my $i = my $j = my $k = 0;	my $name = my $ro = my $h = my $r = my $v = '';	my @hmap = ();	my $td = '<td>';	my $ntd = '</td>';	my $ntr = "</tr>\n";	my $default = $text{'default'};	my $invalid = $text{'invalid'};	my $display_fqdn = $config{'display_fqdn'};	my $display_ttl_secs = $config{'display_ttl_secs'};	my $addr_rec_type = ($rtype eq 'A' || $rtype eq 'AAAA');	my $url2 = "&sort=$in{'sort'}&view=$in{'view'}'>";	my $url = "$td<b><a href='edit_recs.cgi?index=$in{'index'}" .		  "&view=$in{'view'}&file=${file}&ztype=$type";	$url .= '&hide=' . $hide_url if ($hide_recs);	$url .= '&show=' . $show_url if ($show_recs);	$url .= '&use_value=1' if ($use_value);	$url .= '&type=';	my %known_recs = ('PTR' => 1, 'A' => 1, 'AAAA' => 1, 'NS' => 1,			  'CNAME' => 1, 'DNAME' => 1, 'MX' => 1, 'HINFO' => 1,			  'TXT' => 1, 'WKS' => 1, 'RP' => 1, 'LOC' => 1,			  'SRV' => 1, 'KEY' => 1);	print '<table border width=100%>';	print "<tr $tb>", $td, '<b>';	print "<a href='edit_recs.cgi?index=$in{'index'}&view=$in{'view'}&type=$rtype&sort=1&file=${file}&ztype=$type";	print '&hide=', $hide_url if ($hide_recs);	print '&show=', $show_url if ($show_recs);	print '&use_value=1' if ($use_value);	print "'>";	print $text{$reverse ? 'recs_addr' : 'recs_name'};	print '</a></b>';	if ($rtype eq 'A') {		print "&nbsp;&nbsp;&nbsp;<a href='edit_recs.cgi?index=$in{'index'}&view=$in{'view'}&type=$rtype&sort=5&file=${file}&ztype=$type";		print '&hide=', $hide_url if ($hide_recs);		print '&show=', $show_url if ($show_recs);		print '&use_value=1' if ($use_value);		print "'>(sd)</a>";	}	print $ntd;	if ($rtype eq 'ALL') {		print "$td<b><a href='edit_recs.cgi?index=$in{'index'}&view=$in{'view'}&type=$rtype&sort=4&file=${file}&ztype=${type}'>$text{'recs_type'}</a></b>$ntd";	}	print "$td<b>$text{'recs_ttl'}</b>$ntd\n";	if ($hmap{$rtype}) {		@hmap = @{ $hmap{$rtype} };		if ($rtype eq 'MX') {			print $url, "$rtype&sort=-1'>$hmap[0]</a></b>$ntd\n";			print $url, "$rtype&sort=-2'>$hmap[1]</a></b>$ntd\n";		}		elsif ($rtype eq 'SRV') {			print $url, "$rtype&sort=-1'>$hmap[0]</a></b>$ntd\n";			print $url, "$rtype&sort=-2'>$hmap[1]</a></b>$ntd\n";			print $url, "$rtype&sort=-3'>$hmap[2]</a></b>$ntd\n";			print $url, "$rtype&sort=-4'>$hmap[3]</a></b>$ntd\n";		}		elsif ($rtype eq 'KEY') {			print $td, '<b>', $hmap[0], '</b>', $ntd;			print $url, "$rtype&sort=-2'>$hmap[1]</a></b>$ntd\n";			print $td, '<b>', $hmap[2], '</b>', $ntd;			print $td, '<b>', $hmap[3], '</b>', $ntd;		}		elsif ($rtype eq 'RP') {			print $td, '<b>', $hmap[0], '</b>', $ntd;			print $url, "$rtype&sort=-2'>$hmap[1]</a></b>$ntd\n";		}		elsif ($rtype eq 'HINFO') {			print $url, "$rtype&sort=2'>$hmap[0]</a></b>$ntd\n";			print $url, "$rtype&sort=-2'>$hmap[1]</a></b>$ntd\n";		}		elsif ($rtype eq 'LOC') {			print $td, '<b>', $hmap[0], '</b>', $ntd;		}		elsif ($rtype eq 'WKS') {			print $url, "$rtype&sort=2'>$hmap[0]</a></b>$ntd\n";			print $url, "$rtype&sort=-2'>$hmap[1]</a></b>$ntd\n";			print $url, "$rtype&sort=-3'>$hmap[2]</a></b>$ntd\n";		}		else {			print $url, "$rtype&sort=2'>$hmap[0]</a></b>$ntd\n";		}	}	if ($rtype eq 'ALL') {		print $td, $text{'recs_vals'}, $ntd;	}	if (! $dynamic && $config{'allow_comments'}) {		print "<td width=50%><b>$text{'recs_comment'}</b>$ntd\n";	}	print $ntr;	$ro = $read_only || ($type ne 'master' && ! $slave_upd);	$url = "<a href='edit_record.cgi?index=$in{'index'}&type=$rtype&dynamic=${dynamic}&file=${file}&ztype=$type";	$url .= '&hide=' . $hide_url if ($hide_recs);	$url .= '&show=' . $show_url if ($show_recs);	$url .= '&use_value=1' if ($use_value);	$url .= '&num=';	for ($i = 0; $i < @_; $i++) {		$r = $_[$i];		$name = $r->{'fqdn'};		if ($rtype eq 'SRV') {			$name =~ s/^_//o;			$name =~ s/\._/\./o;		}		unless ($display_fqdn) {			$name = &convert_fqdn(-1, $name, $origin, 0);		}		$name = &html_escape($name);		if ($ro) {			print "<tr $cb>", $td, $name, $ntd;		}		else {			print "<tr $cb>", $td;			if (exists($known_recs{$r->{'type'}})) {				print $url, $r->{'num'}, $url2, $name, '</a>';			}			else {				print $name;			}			print $ntd;		}		if ($rtype eq 'ALL') {			print $td, $r->{'type'}, $ntd;		}		$ttl = &convert_time(! $display_ttl_secs, $r->{'ttl'});		$ttl = '<i>' . $invalid . '</i>' if (! $ttl && $r->{'ttl'});		$ttl = 0 if ($dynamic && ($r->{'ttl'} == $default_ttl));		print $td, $ttl ? $ttl : $default, $ntd;		for ($j = 0; $j < @hmap; $j++) {			$v = '';			if ($rtype eq 'RP' && $j == 0) {				$v = &html_escape(					&dotted_to_email($r->{'values'}->[$j]));			}			elsif (&convert_value($rtype, $j) >= 0 || ($j == 0 && $addr_rec_type)) {				$v = $r->{'values'}->[$j];				#				# Display the value correctly, that is, the FQDN				# or not, but if going across zones and about				# to display an IP address then show it in				# dotted-quad format.				#				unless ($display_fqdn) {					$v = &convert_fqdn(-1, $v, $origin, 0);				}				$v = &html_escape($v);			}			elsif ($rtype eq 'WKS' && $j == $#hmap) {				for ($k = $j; $r->{'values'}->[$k]; $k++) {					$v .= &html_escape($r->{'values'}->[$k]);					$v .= ' ';				}			}			elsif ($rtype eq 'LOC') {				$v = &html_escape(join(' ', @{ $r->{'values'} }));			}			elsif ($rtype eq 'TXT') {				foreach (@{ $r->{'values'} }) {					$_ =~ s/\\(.)/$1/g;					$v .= $_ . ' ';				}				$v = &html_escape($v);			}			elsif ($rtype eq 'KEY' && $j == 3) {				$v = substr($r->{'values'}->[$j], 0, 20) . '...';			}			else {				$v = &html_escape($r->{'values'}->[$j]);			}			print $td, $v, $ntd;		}		if ($rtype eq 'ALL') {			print $td, join(' ', @{ $r->{'values'} }), $ntd;		}		if (! $dynamic && $config{'allow_comments'}) {			print $td,			 ($r->{'comment'} ? &html_escape($r->{'comment'}) : ''),			      $ntd;		}		print $ntr;	}	print "</table>\n";	return;}

⌨️ 快捷键说明

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