$conf = &get_config();
print "$text{'white_desc'}<p>\n";
-print &ui_form_start("save_white.cgi", "post");
+print &ui_form_start("save_white.cgi", "form-data");
print $form_hiddens;
# Start of tabs
$url = "edit_white.cgi?file=".&urlize($in{'file'}).
"&title=".&urlize($in{'title'});
-print &ui_tabs_start("mode", $in{'mode'} || "ham",
- map { [ $_, $text{'white_tab'.$_}, $url."&mode=$_" ] }
- ( 'ham', 'spam', 'some', 'import' ));
+print &ui_tabs_start(
+ [ map { [ $_, $text{'white_tab'.$_}, $url."&mode=$_" ] }
+ ( 'ham', 'spam', 'some', 'import' ) ],
+ "mode", $in{'mode'} || "ham", 1);
# Start of ham addresses tab
print &ui_tabs_start_tab("mode", "ham");
[ $text{'white_addr'}, $text{'white_rcvdhost'} ],
[ map { $_->{'words'} } @rcvd ], [ 40, 30 ], undef, 3));
+print &ui_table_end();
print &ui_tabs_end_tab("mode", "ham");
-print "<tr> <td><b>$text{'white_black'}</b></td> ",
- "<td><b>$text{'white_unblack'}</b></td> </tr>\n";
-print "<tr> <td>\n";
+# Start of spam addresses tab
+print &ui_tabs_start_tab("mode", "spam");
+print $text{'white_spamdesc'},"<p>\n";
+print &ui_table_start(undef, undef, 2);
+
+# Blacklisted addresses
@from = &find("blacklist_from", $conf);
-&edit_textbox("blacklist_from", [ map { @{$_->{'words'}} } @from ], 40, 5);
-print "</td> <td>\n";
+print &ui_table_row($text{'white_black'},
+ &edit_textbox("blacklist_from",
+ [ map { @{$_->{'words'}} } @from ], 60, 10));
+
+# Exceptions to blacklist
@un = &find("unblacklist_from", $conf);
-&edit_textbox("unblacklist_from", [ map { @{$_->{'words'}} } @un ], 40, 5);
-print "</td> </tr>\n";
+print &ui_table_row($text{'white_unblack'},
+ &edit_textbox("unblacklist_from",
+ [ map { @{$_->{'words'}} } @un ], 40, 5));
if ($config{'show_global'}) {
- print "<tr> <td><b>$text{'white_gblack'}</b></td> ",
- "<td><b>$text{'white_gunblack'}</b></td> </tr>\n";
- print "<tr> <td>\n";
+ # Global blacklist
@gfrom = &find("blacklist_from", $gconf);
- &edit_textbox("gblacklist_from", [ map { @{$_->{'words'}} } @gfrom ], 40, 5);
- print "</td> <td>\n";
+ print &ui_table_row($text{'white_gblack'},
+ &edit_textbox("gblacklist_from",
+ [ map { @{$_->{'words'}} } @gfrom ], 40, 5, 1));
+
@gun = &find("gunblacklist_from", $gconf);
- &edit_textbox("gunblacklist_from", [ map { @{$_->{'words'}} } @gun ], 40, 5);
- print "</td> </tr>\n";
- print "<script>\n";
- print "document.forms[0].gblacklist_from.disabled = true;\n";
- print "document.forms[0].gunblacklist_from.disabled = true;\n";
- print "</script>\n";
- }
-else {
- print "<tr> <td colspan=2><hr></td> </tr>\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 "<tr> <td colspan=2><b>$text{'white_to'}</b></td> </tr>\n";
- print "<tr> <td colspan=2>\n";
- &edit_table("whitelist_to", [ $text{'white_addr'}, $text{'white_level'} ],
- \@to, [ 40, 0 ], \&whitelist_to_conv, 3);
- print "</td> </tr>\n";
+ print &ui_table_row($text{'white_gunblack'},
+ &edit_textbox("gunblacklist_from",
+ [ map { @{$_->{'words'}} } @gun ], 40, 5, 1));
}
-&end_form(undef, $text{'save'});
+print &ui_table_end();
+print &ui_tabs_end_tab("mode", "spam");
+
+print &ui_tabs_start_tab("mode", "some");
+print $text{'white_somedesc'},"<p>\n";
+print &ui_table_start(undef, undef, 2);
+
+# Addresses to allow some spam to
+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 &ui_table_row($text{'white_to'},
+ &edit_table("whitelist_to",
+ [ $text{'white_addr'}, $text{'white_level'} ],
+ \@to, [ 40, 0 ], \&whitelist_to_conv, 3));
+
+print &ui_table_end();
+print &ui_tabs_end_tab("mode", "some");
# Show whitelist import form
-print &ui_hr();
+print &ui_tabs_start_tab("mode", "import");
print "$text{'white_importdesc'}<p>\n";
-print "<form action=import.cgi method=post enctype=multipart/form-data>\n";
-print "<table>\n";
-print "<tr> <td><b>$text{'white_import'}</b></td>\n";
-print "<td><input type=file name=import></td> </tr>\n";
-print "<tr> <td><b>$text{'white_sort'}</b></td>\n";
-print "<td><input type=radio name=sort value=1> $text{'yes'}\n";
-print "<input type=radio name=sort value=0 checked> $text{'no'}</td> </tr>\n";
-print "</table>\n";
-print "<input type=submit value='$text{'white_importok'}'></form>\n";
+print &ui_table_start(undef, undef, 2);
+
+# File to import, uploaded
+print &ui_table_row($text{'white_import'}, &ui_upload("import"));
+
+# Sort addresses?
+print &ui_table_row($text{'white_sort'}, &ui_yesno_radio("sort", 0));
+
+print &ui_table_end();
+print &ui_tabs_end_tab("mode", "import");
+
+print &ui_tabs_end(1);
+print &ui_form_end([ [ undef, $text{'save'} ] ]);
&ui_print_footer($redirect_url, $text{'index_return'});
return &default_convfunc(@_);
}
else {
- local $rv = "<select name=$_[1]>\n";
- foreach $l (0 .. 2) {
- $rv .= sprintf "<option value=%d %s>%s\n",
- $l, $l == $_[3] ? "selected" : "", $text{"white_level$l"};
- }
- $rv .= "</select>\n";
- return $rv;
+ return &ui_select($_[1], $_[3],
+ [ [ 0, $text{"white_level0"} ],
+ [ 1, $text{"white_level1"} ],
+ [ 2, $text{"white_level2"} ] ]);
}
}
+++ /dev/null
-#!/usr/local/bin/perl
-# import.cgi
-# Add email addresses to the allowed list
-
-require './spam-lib.pl';
-&ReadParseMime();
-$in{'import'} || &error($text{'import_efile'});
-
-# Parse the file
-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,})+)))//) {
- push(@addrs, $1);
- }
-@addrs || &error($text{'import_enone'});
-@addrs = &unique(@addrs);
-
-&lock_spam_files();
-$conf = &get_config();
-@from = map { @{$_->{'words'}} } &find("whitelist_from", $conf);
-%already = map { $_, 1 } @from;
-@newaddrs = grep { !$already{$_} } @addrs;
-
-&ui_print_header(undef, $text{'import_title'}, "");
-
-if (@newaddrs) {
- print "<p>",&text('import_ok1', scalar(@newaddrs),
- scalar(@addrs)),"<p>\n";
- push(@from, @newaddrs);
- if ($in{'sort'}) {
- @from = sort { ($ua, $da) = split(/\@/, $a);
- ($ub, $db) = split(/\@/, $b);
- lc($da) cmp lc($db) || lc($ua) cmp lc($ub) }
- @from;
- }
- &save_directives($conf, 'whitelist_from', \@from, 1);
- &flush_file_lines();
- }
-else {
- print "<p>",&text('import_ok2', scalar(@addrs)),"<p>\n";
- }
-&webmin_log("import", scalar(@newaddrs));
-&unlock_spam_files();
-
-&ui_print_footer("edit_white.cgi", $text{'white_return'});
-
require './spam-lib.pl';
&error_setup($text{'white_err'});
-&ReadParse();
+&ReadParseMime();
&set_config_file_in(\%in);
&can_use_check("white");
&execute_before("white");
&parse_textbox($conf, 'unwhitelist_from');
-if (!$config{'show_global'}) {
- @rcvd = &parse_table("whitelist_from_rcvd", \&rcvd_parser);
- &save_directives($conf, 'whitelist_from_rcvd', \@rcvd, 1);
- }
+@rcvd = &parse_table("whitelist_from_rcvd", \&rcvd_parser);
+&save_directives($conf, 'whitelist_from_rcvd', \@rcvd, 1);
&parse_textbox($conf, 'blacklist_from');
&parse_textbox($conf, 'unblacklist_from');
-if (!$config{'show_global'}) {
- @to = &parse_table("whitelist_to", \&to_parser);
- @oldto = ( &find("whitelist_to", $conf),
- &find("more_spam_to", $conf),
- &find("all_spam_to", $conf) );
- &save_directives($conf, \@oldto, \@to, 0);
+@to = &parse_table("whitelist_to", \&to_parser);
+@oldto = ( &find("whitelist_to", $conf),
+ &find("more_spam_to", $conf),
+ &find("all_spam_to", $conf) );
+&save_directives($conf, \@oldto, \@to, 0);
+
+# Add any imported addresses
+if ($in{'import'}) {
+ @addrs = ( );
+ 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,})+)))//) {
+ push(@addrs, $1);
+ }
+ @addrs || &error($text{'import_enone'});
+ @addrs = &unique(@addrs);
+
+ @from = map { @{$_->{'words'}} } &find("whitelist_from", $conf);
+ %already = map { lc($_), 1 } @from;
+ @newaddrs = grep { !$already{lc($_)} } @addrs;
+ push(@from, @newaddrs);
+ if ($in{'sort'}) {
+ @from = sort { ($ua, $da) = split(/\@/, $a);
+ ($ub, $db) = split(/\@/, $b);
+ lc($da) cmp lc($db) || lc($ua) cmp lc($ub) }
+ @from;
+ }
+ &save_directives($conf, 'whitelist_from', \@from, 1);
}
&flush_file_lines();