X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fbin%2Fadd2nulllist.pl;h=27d694e29680333ad9b824771c3389778f1b4c02;hb=fb0ec106a8deca35bebe0713ecd45b37fc41670c;hp=21755b38fd42f602a062935277a00b3d17200c4a;hpb=020a4a5ea2be725b155cae3a2cadc9aba3911b9b;p=clearscm.git diff --git a/maps/bin/add2nulllist.pl b/maps/bin/add2nulllist.pl index 21755b3..27d694e 100755 --- a/maps/bin/add2nulllist.pl +++ b/maps/bin/add2nulllist.pl @@ -30,9 +30,10 @@ sub GetItems { my @address = split /\@/, $fields [0]; - $item {pattern} = $address [0]; - $item {domain} = $address [1]; - $item {comment} = $fields [1] ? $fields [1] : ""; + $item{pattern} = $address[0]; + $item{domain} = $address[1]; + $item{comment} = $fields[1] ? $fields[1] : ''; + $itme{hit_count} = $fields[2] ? $fields[2] : 0; push @items, \%item; } # while @@ -41,37 +42,42 @@ sub GetItems { } # GetItems sub Add2List { - my @items = @_; + my @items = @_; - my $sender = ""; - my $nextseq = MAPSDB::GetNextSequenceNo $userid, $type; + my $sender = ""; + my $nextseq = MAPSDB::GetNextSequenceNo $userid, $type; foreach (@items) { - my %item = %{$_}; + my %item = %{$_}; - my $pattern = $item {pattern}; - my $domain = $item {domain}; - my $comment = $item {comment}; + my $pattern = $item{pattern}; + my $domain = $item{domain}; + my $comment = $item{comment}; + my $hit_count = $item{hit_count}; display_nolf "Adding $pattern\@$domain ($comment) to null list ($nextseq)..."; - last if ((!defined $pattern || $pattern eq "") && - (!defined $domain || $domain eq "")); - $sender = lc ("$pattern\@$domain"); + + last if ((!defined $pattern || $pattern eq '') && + (!defined $domain || $domain eq '')); + + $sender = lc ("$pattern\@$domain"); if (OnNulllist $sender) { display " Already on list"; } else { - Add2Nulllist $sender, $userid, $comment; + Add2Nulllist $sender, $userid, $comment, $hit_count; display " done"; - + # Now remove this entry from the other lists (if present) foreach my $otherlist ("white", "black") { - my $sth = FindList $otherlist, $sender; - my ($sequence, $count); - ($_, $_, $_, $_, $_, $sequence) = GetList $sth; - if (defined $sequence) { - $count = DeleteList $otherlist, $sequence; - } # if + my $sth = FindList $otherlist, $sender; + my ($sequence, $count); + + ($_, $_, $_, $_, $_, $sequence) = GetList $sth; + + if ($sequence) { + $count = DeleteList $otherlist, $sequence; + } # if } # foreach } # if $nextseq++; @@ -82,7 +88,7 @@ sub Add2List { my $filename; if ($ARGV [0]) { - $filename = $ARGV [0]; + $filename = $ARGV[0]; } else { error "Must specify a filename of addresses to null list", 1; } # if