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";
22 use lib "$FindBin::Bin/../../lib";
30 use CGI qw/:standard *table/;
31 use CGI::Carp 'fatalsToBrowser';
36 CheckParms(['userid', 'type'], \%rec);
38 my $nextseq = GetNextSequenceNo(%rec);
40 my $Userid = ucfirst $rec{userid};
43 $rec{pattern} = param "pattern$nextseq";
44 $rec{domain} = param "domain$nextseq";
45 $rec{comment} = param "comment$nextseq";
46 $rec{hit_count} = param "hit_count$nextseq";
47 $rec{retention} = param "retention$nextseq";
49 last unless $rec{pattern} or $rec{domain};
51 $rec{sender} = CheckEmail $rec{pattern}, $rec{domain};
53 my ($status) = OnBlacklist($rec{sender});
56 print br {-class => 'error'},
57 "The email address $rec{sender} is already on ${Userid}'s $rec{type} list";
59 my ($messages, $msg) = Add2Blacklist(%rec);
62 print br {-class => 'error'}, "Unable to add $rec{sender} to $rec{type} list";
65 print br "The email address, $rec{sender}, has been added to ${Userid}'s $rec{type} list";
68 # Now remove this entry from the other lists (if present)
69 for my $otherlist ('white', 'null') {
71 userid => $rec{userid},
73 sender => $rec{sender},
78 if ($seq->{sequence}) {
81 ($err, $msg) = DeleteList(
82 userid => $rec{userid},
84 sequence => $seq->{sequence},
87 croak $msg if $err < 0;
89 print br "Removed $rec{sender} from ${Userid}'s " . ucfirst $otherlist . ' list'
93 userid => $rec{userid},
107 my $userid = Heading(
114 $userid ||= $ENV{USER};
120 NavigationBar($userid);
129 -action => 'processaction.cgi',
133 print '<p></p><center>',
134 hidden ({-name => 'type', -default => $type}),
135 submit ({-name => 'action', -value => 'Add'}),