#!/usr/local/bin/perl
# edit_white.cgi
# Display white and black lists of to and from addresses
require './spam-lib.pl';
&can_use_check("white");
&ui_print_header(undef, $text{'white_title'}, "");
$conf = &get_config();
print "$text{'white_desc'}
\n";
&start_form("save_white.cgi", $text{'white_header'});
print "
$text{'white_from'} ",
"$text{'white_unfrom'} \n";
print " \n";
@from = &find("whitelist_from", $conf);
&edit_textbox("whitelist_from", [ map { @{$_->{'words'}} } @from ], 40, 5);
print " \n";
@un = &find("unwhitelist_from", $conf);
&edit_textbox("unwhitelist_from", [ map { @{$_->{'words'}} } @un ], 40, 5);
print " \n";
if ($config{'show_global'}) {
print " $text{'white_gfrom'} ",
"$text{'white_gunfrom'} \n";
$gconf = &get_config($config{'global_cf'}, 1);
print " \n";
@gfrom = &find("whitelist_from", $gconf);
&edit_textbox("gwhitelist_from", [ map { @{$_->{'words'}} } @gfrom ], 40, 5);
print " \n";
@gun = &find("unwhitelist_from", $gconf);
&edit_textbox("gunwhitelist_from", [ map { @{$_->{'words'}} } @gun ], 40, 5);
print " \n";
print "\n";
}
else {
print " $text{'white_rcvd'} \n";
print " \n";
@rcvd = &find("whitelist_from_rcvd", $conf);
&edit_table("whitelist_from_rcvd",
[ $text{'white_addr'}, $text{'white_rcvdhost'} ],
[ map { $_->{'words'} } @rcvd ], [ 40, 30 ], undef, 3);
print " \n";
}
print " \n";
print " $text{'white_black'} ",
"$text{'white_unblack'} \n";
print " \n";
@from = &find("blacklist_from", $conf);
&edit_textbox("blacklist_from", [ map { @{$_->{'words'}} } @from ], 40, 5);
print " \n";
@un = &find("unblacklist_from", $conf);
&edit_textbox("unblacklist_from", [ map { @{$_->{'words'}} } @un ], 40, 5);
print " \n";
if ($config{'show_global'}) {
print " $text{'white_gblack'} ",
"$text{'white_gunblack'} \n";
print " \n";
@gfrom = &find("blacklist_from", $gconf);
&edit_textbox("gblacklist_from", [ map { @{$_->{'words'}} } @gfrom ], 40, 5);
print " \n";
@gun = &find("gunblacklist_from", $gconf);
&edit_textbox("gunblacklist_from", [ map { @{$_->{'words'}} } @gun ], 40, 5);
print " \n";
print "\n";
}
else {
print " \n";
push(@to, map { [ $_, 0 ] } map { @{$_->{'words'}} } &find("whitelist_to", $conf));
push(@to, map { [ $_, 1 ] } map { @{$_->{'words'}} } &find("more_spam_to", $conf));
push(@to, map { [ $_, 2 ] } map { @{$_->{'words'}} } &find("all_spam_to", $conf));
print " $text{'white_to'} \n";
print " \n";
&edit_table("whitelist_to", [ $text{'white_addr'}, $text{'white_level'} ],
\@to, [ 40, 0 ], \&whitelist_to_conv, 3);
print " \n";
}
&end_form(undef, $text{'save'});
# Show whitelist import form
print " \n";
print "$text{'white_importdesc'}\n";
print "
\n";
&ui_print_footer("", $text{'index_return'});
# whitelist_to_conv(col, name, size, value)
sub whitelist_to_conv
{
if ($_[0] == 0) {
return &default_convfunc(@_);
}
else {
local $rv = "\n";
foreach $l (0 .. 2) {
$rv .= sprintf "%s\n",
$l, $l == $_[3] ? "selected" : "", $text{"white_level$l"};
}
$rv .= " \n";
return $rv;
}
}