X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;ds=inline;f=maps%2Fbin%2Fadd2blacklist.cgi;h=cbc395f0465095d46c9e4aaf361781a527bf0224;hb=56d3fe8351c2eb173541afeb9445059fa452d73e;hp=6b5d14f9915e303e20ec162b2794dee45df28cac;hpb=020a4a5ea2be725b155cae3a2cadc9aba3911b9b;p=clearscm.git diff --git a/maps/bin/add2blacklist.cgi b/maps/bin/add2blacklist.cgi index 6b5d14f..cbc395f 100755 --- a/maps/bin/add2blacklist.cgi +++ b/maps/bin/add2blacklist.cgi @@ -2,7 +2,7 @@ ################################################################################ # # File: $RCSfile: add2blacklist.cgi,v $ -# Revision: $Revision: 1.1 $ +# Revision: $Revision: 1.1 $ # Description: Add an email address to the blacklist # Author: Andrew@DeFaria.com # Created: Mon Jan 16 20:25:32 PST 2006 @@ -16,9 +16,12 @@ use strict; use warnings; use FindBin; -$0 = $FindBin::Script; +local $0 = $FindBin::Script; -use lib $FindBin::Bin; +use lib "$FindBin::Bin/../lib"; +use lib "$FindBin::Bin/../../lib"; + +use Utils; use MAPS; use MAPSLog; @@ -27,80 +30,109 @@ use MAPSWeb; use CGI qw/:standard *table/; use CGI::Carp 'fatalsToBrowser'; -my $userid; -my $Userid; -my $type = 'black'; +sub Add2List(%) { + my (%rec) = @_; -sub Add2List { - my $sender = ''; - my $nextseq = MAPSDB::GetNextSequenceNo $userid, $type; + CheckParms(['userid', 'type'], \%rec); - while () { - my $pattern = param "pattern$nextseq"; - my $domain = param "domain$nextseq"; - my $comment = param "comment$nextseq"; + my $nextseq = GetNextSequenceNo(%rec); - last if ((!defined $pattern || $pattern eq '') && - (!defined $domain || $domain eq '')); + my $Userid = ucfirst $rec{userid}; - $sender = lc "$pattern\@$domain"; + while () { + $rec{pattern} = param "pattern$nextseq"; + $rec{domain} = param "domain$nextseq"; + $rec{comment} = param "comment$nextseq"; + $rec{hit_count} = param "hit_count$nextseq"; + $rec{retention} = param "retention$nextseq"; - my ($status, $rule) = OnBlacklist $sender; + last unless $rec{pattern} or $rec{domain}; - if ($status != 0) { - print br {-class => 'error'}, "The email address $sender is already on ${Userid}'s $type list"; - } else { - Add2Blacklist $sender, $userid, $comment; - print br "The email address, $sender, has been added to ${Userid}'s $type list"; + $rec{sender} = CheckEmail $rec{pattern}, $rec{domain}; - # Now remove this entry from the other lists (if present) - foreach my $otherlist ('white', 'null') { - my $sth = FindList $otherlist, $sender; - my ($sequence, $count); + my ($status) = OnBlacklist($rec{sender}); - ($_, $_, $_, $_, $_, $sequence) = GetList $sth; + if ($status) { + print br {-class => 'error'}, + "The email address $rec{sender} is already on ${Userid}'s $rec{type} list"; + } else { + my ($messages, $msg) = Add2Blacklist(%rec); - if ($sequence) { - $count = DeleteList $otherlist, $sequence; - print br "Removed $sender from ${Userid}'s " . ucfirst $otherlist . ' list' - if $count > 0; + if ($messages < -1) { + print br {-class => 'error'}, "Unable to add $rec{sender} to $rec{type} list"; + return; + } else { + print br "The email address, $rec{sender}, has been added to ${Userid}'s $rec{type} list"; + } # if - ResequenceList $userid, $otherlist; - } # if - } # foreach + # Now remove this entry from the other lists (if present) + for my $otherlist ('white', 'null') { + FindList( + userid => $rec{userid}, + type => $otherlist, + sender => $rec{sender}, + ); + + my $seq = GetList; + + if ($seq->{sequence}) { + my $err; + + ($err, $msg) = DeleteList( + userid => $rec{userid}, + type => $otherlist, + sequence => $seq->{sequence}, + ); + + croak $msg if $err < 0; + + print br "Removed $rec{sender} from ${Userid}'s " . ucfirst $otherlist . ' list' + if $err > 0; + + ResequenceList( + userid => $rec{userid}, + type => $otherlist, + ); + } # if + } # for } # if $nextseq++; } # while + + return; } # Add2List # Main -$userid = Heading ( +my $userid = Heading( 'getcookie', '', 'Add to Black List', 'Add to Black List', ); -$Userid = ucfirst $userid; +$userid ||= $ENV{USER}; -SetContext $userid; +my $type = 'black'; + +SetContext($userid); -NavigationBar $userid; +NavigationBar($userid); -Add2List; +Add2List( + userid => $userid, + type => $type, +); print start_form { - -method => 'post', - -action => 'processaction.cgi', - -name => 'list' + -method => 'post', + -action => 'processaction.cgi', + -name => 'list', }; print '