mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Completed ui-libification
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -10,15 +10,16 @@ require './spam-lib.pl';
|
||||
$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");
|
||||
@@ -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 "<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'});
|
||||
|
||||
@@ -122,13 +140,10 @@ if ($_[0] == 0) {
|
||||
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"} ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 "<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'});
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user