📄 save_virtuser.cgi
字号:
#!/usr/local/bin/perl# save_virtuser.cgi# Save, create or delete an address mappingrequire './sendmail-lib.pl';require './virtusers-lib.pl';&ReadParse();$access{'vmode'} > 0 || &error($text{'vsave_ecannot'});$conf = &get_sendmailcf();$vfile = &virtusers_file($conf);($vdbm, $vdbmtype) = &virtusers_dbm($conf);@virts = &list_virtusers($vfile);foreach $vu (@virts) { $already{$vu->{'from'}}++; }if (!$in{'new'}) { $v = $virts[$in{'num'}]; $access{'vmode'} == 1 || $v->{'from'} =~ /$access{'vaddrs'}/ || &error($text{'vsave_ecannot2'}); }elsif ($access{'vmax'}) { local @cvirts = grep { $access{"vedit_".&virt_type($_->{'to'})} } @virts; if ($access{'vmode'} == 2) { @cvirts = grep { $_->{'from'} =~ /$access{'vaddrs'}/ } @cvirts; } &error(&text('vsave_emax', $access{'vmax'})) if (@cvirts >= $access{'vmax'}); }if ($in{'delete'}) { # delete some mapping &delete_virtuser($v, $vfile, $vdbm, $vdbmtype); }else { # Saving or creating.. check inputs &error_setup($text{'vsave_err'}); if ($in{'from_type'} == 0) { $in{'from_addr'} =~ /^(\S+)\@(\S+)$/ || &error(&text('vsave_efrom', $in{'from_addr'})); $from = $in{'from_addr'}; if ($already{$from} && ($in{'new'} || $v->{'from'} ne $from)) { &error(&text('vsave_efromdup', $in{'from_addr'})); } } else { $in{'from_dom'} =~ /^([^\@ ]+)$/ || &error(&text('vsave_edom', $in{'from_dom'})); $from = "\@$in{'from_dom'}"; if ($already{$from} && ($in{'new'} || $v->{'from'} ne $from)) { &error(&text('vsave_edomdup', $in{'from_dom'})); } } $access{'vmode'} == 1 || $from =~ /$access{'vaddrs'}/ || &error(&text('vsave_ematch', $access{'vaddrs'})); if ($in{'to_type'} == 2) { $access{"vedit_2"} || &error($text{'vsave_ecannot3'}); $in{'to_addr'} =~ /^(\S+)$/ || &error($text{'vsave_eaddr'}); $to = $in{'to_addr'}; } elsif ($in{'to_type'} == 1) { $access{"vedit_1"} || &error($text{'vsave_ecannot4'}); $in{'to_dom'} =~ /^([^\@ ]+)$/ || &error(&text('vsave_edom', $in{'to_dom'})); $in{'from_type'} == 1 || &error($text{'vsave_edomdom'}); $to = "\%1\@$in{'to_dom'}"; } else { $access{"vedit_1"} || &error($text{'vsave_ecannot5'}); $to = "error:$in{'to_code'} $in{'to_error'}"; } $newv{'from'} = $from; $newv{'to'} = $to; if ($in{'new'}) { &create_virtuser(\%newv, $vfile, $vdbm, $vdbmtype); } else { &modify_virtuser($v, \%newv, $vfile, $vdbm, $vdbmtype); } }&redirect("list_virtusers.cgi");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -