diff --git a/spam/CHANGELOG b/spam/CHANGELOG index 4e1745554..e4818b50e 100644 --- a/spam/CHANGELOG +++ b/spam/CHANGELOG @@ -18,3 +18,5 @@ Added buttons to the auto-whitelist page for permanently allowing or denying sel ---- Changes since 1.440 ---- Corrected the columns on the auto-whitelist page, to show the message count and score. Improved support for multiple SpamAssassin config files, which can be specified by links into the module from other modules like Virtualmin. +Converted all pages to use the new Webmin UI library, for a more consistent look. +Cleaned up the layout of all pages to improve formatted, in particular the Allowed and Denied Addresses page which now uses tabs. diff --git a/spam/edit_white.cgi b/spam/edit_white.cgi index fb545a2f1..e648fd5ef 100755 --- a/spam/edit_white.cgi +++ b/spam/edit_white.cgi @@ -10,15 +10,16 @@ require './spam-lib.pl'; $conf = &get_config(); print "$text{'white_desc'}

\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"); @@ -58,60 +59,77 @@ print &ui_table_row($text{'white_rcvd2'}, [ $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 " $text{'white_black'} ", - "$text{'white_unblack'} \n"; -print " \n"; +# Start of spam addresses tab +print &ui_tabs_start_tab("mode", "spam"); +print $text{'white_spamdesc'},"

\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 " \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 " \n"; +print &ui_table_row($text{'white_unblack'}, + &edit_textbox("unblacklist_from", + [ map { @{$_->{'words'}} } @un ], 40, 5)); if ($config{'show_global'}) { - print " $text{'white_gblack'} ", - "$text{'white_gunblack'} \n"; - print " \n"; + # Global blacklist @gfrom = &find("blacklist_from", $gconf); - &edit_textbox("gblacklist_from", [ map { @{$_->{'words'}} } @gfrom ], 40, 5); - print " \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 " \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"; + 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'},"

\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'}

\n"; -print "

\n"; -print "\n"; -print "\n"; -print "\n"; -print "\n"; -print "\n"; -print "
$text{'white_import'}
$text{'white_sort'} $text{'yes'}\n"; -print " $text{'no'}
\n"; -print "
\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'}); @@ -122,13 +140,10 @@ if ($_[0] == 0) { return &default_convfunc(@_); } else { - local $rv = "\n"; - return $rv; + return &ui_select($_[1], $_[3], + [ [ 0, $text{"white_level0"} ], + [ 1, $text{"white_level1"} ], + [ 2, $text{"white_level2"} ] ]); } } diff --git a/spam/import.cgi b/spam/import.cgi deleted file mode 100755 index f3af09766..000000000 --- a/spam/import.cgi +++ /dev/null @@ -1,44 +0,0 @@ -#!/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 "

",&text('import_ok1', scalar(@newaddrs), - scalar(@addrs)),"

\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 "

",&text('import_ok2', scalar(@addrs)),"

\n"; - } -&webmin_log("import", scalar(@newaddrs)); -&unlock_spam_files(); - -&ui_print_footer("edit_white.cgi", $text{'white_return'}); - diff --git a/spam/lang/en b/spam/lang/en index c5512d871..cd0aad145 100644 --- a/spam/lang/en +++ b/spam/lang/en @@ -39,6 +39,10 @@ white_import=Import addresses from file white_sort=Sort allowed addresses after import? white_importok=Import Now white_return=allowed and denied addresses +white_tabham=Allowed addresses +white_tabspam=Denied addresses +white_tabsome=Destination addresses +white_tabimport=Import addresses score_title=Spam Classification score_desc=SpamAssassin assigns a score to each message based on its content and headers. The options on this page determine the score above which a message is considered spam, and some of the methods via which that score is calculated. diff --git a/spam/save_white.cgi b/spam/save_white.cgi index 7b8e0232a..8b3ff0209 100755 --- a/spam/save_white.cgi +++ b/spam/save_white.cgi @@ -4,7 +4,7 @@ require './spam-lib.pl'; &error_setup($text{'white_err'}); -&ReadParse(); +&ReadParseMime(); &set_config_file_in(\%in); &can_use_check("white"); &execute_before("white"); @@ -15,21 +15,39 @@ $conf = &get_config(); &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();