3 # Save white and black lists of to and from addresses
5 require './spam-lib.pl';
6 &error_setup($text{'white_err'});
8 &set_config_file_in(\%in);
9 &can_use_check("white");
10 &execute_before("white");
12 $conf = &get_config();
14 &parse_textbox($conf, "whitelist_from");
16 &parse_textbox($conf, 'unwhitelist_from');
18 @rcvd = &parse_table("whitelist_from_rcvd", \&rcvd_parser);
19 &save_directives($conf, 'whitelist_from_rcvd', \@rcvd, 1);
21 &parse_textbox($conf, 'blacklist_from');
23 &parse_textbox($conf, 'unblacklist_from');
25 @to = &parse_table("whitelist_to", \&to_parser);
26 @oldto = ( &find("whitelist_to", $conf),
27 &find("more_spam_to", $conf),
28 &find("all_spam_to", $conf) );
29 &save_directives($conf, \@oldto, \@to, 0);
31 # Add any imported addresses
34 while($in{'import'} =~ s/((([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+([a-zA-Z]{2,})+)))//) {
37 @addrs || &error($text{'import_enone'});
38 @addrs = &unique(@addrs);
40 @from = map { @{$_->{'words'}} } &find("whitelist_from", $conf);
41 %already = map { lc($_), 1 } @from;
42 @newaddrs = grep { !$already{lc($_)} } @addrs;
43 push(@from, @newaddrs);
45 @from = sort { ($ua, $da) = split(/\@/, $a);
46 ($ub, $db) = split(/\@/, $b);
47 lc($da) cmp lc($db) || lc($ua) cmp lc($ub) }
50 &save_directives($conf, 'whitelist_from', \@from, 1);
55 &execute_after("white");
57 &redirect($redirect_url);
61 return undef if (!$_[1]);
62 $_[1] =~ /^\S+$/ || &error(&text('white_efrom', $_[1]));
68 local $a = &from_parser($_[0], $_[1]);
69 return undef if (!$a);
70 $_[2] =~ /^[A-Za-z0-9\.\-]+$/ || &error(&text('white_ercvd', $_[2]));
76 local $a = &from_parser($_[0], $_[1]);
77 return undef if (!$a);
78 return { 'name' => $_[2] == 0 ? 'whitelist_to' :
79 $_[2] == 1 ? 'more_spam_to' : 'all_spam_to',