Handle hostnames with upper-case letters
[webmin.git] / spam / delete_awl.cgi
1 #!/usr/local/bin/perl
2 # Delete auto-whitelist entries
3
4 require './spam-lib.pl';
5 &error_setup($text{'dawl_err'});
6 &ReadParse();
7 &set_config_file_in(\%in);
8 &can_use_check("awl");
9 &can_edit_awl($in{'user'}) || &error($text{'dawl_ecannot'});
10 $conf = &get_config();
11
12 # Check stuff
13 &open_auto_whitelist_dbm($in{'user'}) || &error($text{'dawl_eopen'});
14 @d = split(/\0/, $in{'d'});
15 @d || &error($text{'dawl_enone'});
16
17 if ($in{'white'}) {
18         # Add to whitelist
19         @d = map { s/\|.*$//; $_ } @d;
20         @from = map { @{$_->{'words'}} } &find("whitelist_from", $conf);
21         @from = &unique(@from, @d);
22         &save_directives($conf, "whitelist_from", \@from, 1);
23         &flush_file_lines();
24         }
25 elsif ($in{'black'}) {
26         # Add to blacklist
27         @d = map { s/\|.*$//; $_ } @d;
28         @from = map { @{$_->{'words'}} } &find("blacklist_from", $conf);
29         @from = &unique(@from, @d);
30         &save_directives($conf, "blacklist_from", \@from, 1);
31         &flush_file_lines();
32         }
33 else {
34         # Delete from AWL hash
35         foreach $d (@d) {
36                 delete($awl{$d});
37                 delete($awl{$d."|totscore"});
38                 }
39         }
40
41 &close_auto_whitelist_dbm();
42 &redirect("edit_awl.cgi?search=".&urlize($in{'search'}).
43           "&user=".&urlize($in{'user'}).
44           "&file=".&urlize($in{'file'}).
45           "&title=".&urlize($in{'title'}));
46