2 ################################################################################
4 # File: $RCSfile: add2blacklist.cgi,v $
5 # Revision: $Revision: 1.1 $
6 # Description: Add an email address to the blacklist
7 # Author: Andrew@DeFaria.com
8 # Created: Mon Jan 16 20:25:32 PST 2006
9 # Modified: $Date: 2013/06/12 14:05:47 $
12 # (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
14 ################################################################################
19 local $0 = $FindBin::Script;
21 use lib "$FindBin::Bin/../lib";
29 use CGI qw/:standard *table/;
30 use CGI::Carp 'fatalsToBrowser';
35 CheckParms(['userid', 'type'], \%rec);
37 my $nextseq = GetNextSequenceNo(%rec);
39 my $Userid = ucfirst $rec{userid};
42 $rec{pattern} = param "pattern$nextseq";
43 $rec{domain} = param "domain$nextseq";
44 $rec{comment} = param "comment$nextseq";
45 $rec{hit_count} = param "hit_count$nextseq";
46 $rec{retention} = param "retention$nextseq";
48 last unless $rec{pattern} or $rec{domain};
50 $rec{sender} = CheckEmail $rec{pattern}, $rec{domain};
52 my ($status, $rule) = OnBlacklist($rec{sender});
55 print br {-class => 'error'},
56 "The email address $rec{sender} is already on ${Userid}'s $rec{type} list";
58 my ($messages, $msg) = Add2Blacklist(%rec);
61 print br {-class => 'error'}, "Unable to add $rec{sender} to $rec{type} list";
64 print br "The email address, $rec{sender}, has been added to ${Userid}'s $rec{type} list";
67 # Now remove this entry from the other lists (if present)
68 for my $otherlist ('white', 'null') {
70 userid => $rec{userid},
72 sender => $rec{sender},
77 if ($seq->{sequence}) {
80 ($err, $msg) = DeleteList(
81 userid => $rec{userid},
83 sequence => $seq->{sequence},
86 croak $msg if $err < 0;
88 print br "Removed $rec{sender} from ${Userid}'s " . ucfirst $otherlist . ' list'
92 userid => $rec{userid},
106 my $userid = Heading(
113 $userid ||= $ENV{USER};
119 NavigationBar($userid);
128 -action => 'processaction.cgi',
132 print '<p></p><center>',
133 hidden ({-name => 'type', -default => $type}),
134 submit ({-name => 'action', -value => 'Add'}),