save_masq.cgi

来自「Unix下基于Web的管理工具」· CGI 代码 · 共 50 行

CGI
50
字号
#!/usr/local/bin/perl# save_masq.cgi# Save domain masqueradingrequire './sendmail-lib.pl';&ReadParse();$access{'masq'} || &error($text{'masq_ecannot'});&error_setup($text{'masq_err'});$conf = &get_sendmailcf();$in{'masq'} =~ /^[A-z0-9\-\.]*$/ ||	&error(&text('masq_edomain', $in{'masq'}));@mlist = split(/\s+/, $in{'mlist'});foreach $m (@mlist) {	$m =~ /^[A-z0-9\-\.]+$/ ||		&error(&text('masq_ehost', $m));	&check_ipaddress($m) &&		&error(&text('masq_eip', $m));	}@mlist = &unique(@mlist);# Update the DM directive (if there is one)foreach $d (&find_type("D", $conf)) {	if ($d->{'value'} =~ /^M/) { push(@dmconf, $d); }	}&save_directives($conf, \@dmconf,		 [ { 'type' => 'D', 'values' => [ "M$in{'masq'}" ] } ]);# Get old CM directives@old = grep { $_->{'value'} =~ /^M/ } &find_type("C", $conf);if ($in{'cmfile'}) {	# If there is a cm file, write all domains to it and take any	# out of sendmail.cf	open(CM, "> $in{'cmfile'}");	foreach $m (@mlist) { print CM $m,"\n"; }	close(CM);	}else {	# Put all domains in sendmail.cf	foreach $m (@mlist) {		push(@new, { 'type' => 'C',			     'values' => [ "M$m" ] });		}	}&save_directives($conf, \@old, \@new);&flush_file_lines();&restart_sendmail();&redirect("");

⌨️ 快捷键说明

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