X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fbin%2Fadd2whitelist.cgi;h=6b80947dba5ced014c8ead7fac34b4773d6f8c50;hb=4e9f478e1417a38297ea9d3d659d9ce4cd572a57;hp=3e93d1d5df045fb8b2e110885156e1b96ed61a4b;hpb=f2415331badf75d03697d43bdaa67afc11fca436;p=clearscm.git diff --git a/maps/bin/add2whitelist.cgi b/maps/bin/add2whitelist.cgi index 3e93d1d..6b80947 100755 --- a/maps/bin/add2whitelist.cgi +++ b/maps/bin/add2whitelist.cgi @@ -18,11 +18,12 @@ use warnings; use FindBin; $0 = $FindBin::Script; -use lib $FindBin::Bin; +use lib "$FindBin::Bin/../lib"; use MAPS; use MAPSLog; use MAPSWeb; +use MAPSUtil; use CGI qw/:standard *table/; use CGI::Carp 'fatalsToBrowser'; @@ -31,9 +32,9 @@ my $userid; my $Userid; my $type = 'white'; -sub Add2List { +sub Add2List() { my $sender = ''; - my $nextseq = MAPSDB::GetNextSequenceNo $userid, $type; + my $nextseq = GetNextSequenceNo($userid, $type); while () { my $pattern = param "pattern$nextseq"; @@ -43,14 +44,14 @@ sub Add2List { last if ((!defined $pattern || $pattern eq '') && (!defined $domain || $domain eq '')); - $sender = lc "$pattern\@$domain"; + $sender = CheckEmail $pattern, $domain; - my ($status, $rule) = OnWhitelist $sender, $userid; + my ($status, $rule) = OnWhitelist($sender, $userid); if ($status != 0) { print br {-class => 'error'}, "The email address $sender is already on ${Userid}'s $type list"; } else { - my $messages = Add2Whitelist $sender, $userid, $comment; + my $messages = Add2Whitelist($sender, $userid, $comment); print br "The email address, $sender, has been added to ${Userid}'s $type list"; if ($messages > 0) { @@ -66,20 +67,20 @@ sub Add2List { } # if # Now remove this entry from the other lists (if present) - foreach my $otherlist ('black', 'null') { - my $sth = FindList $otherlist, $sender; + for my $otherlist ('black', 'null') { + my $sth = FindList($otherlist, $sender); my ($sequence, $count); - ($_, $_, $_, $_, $_, $sequence) = GetList $sth; + ($_, $_, $_, $_, $_, $sequence) = GetList($sth); if ($sequence) { - $count = DeleteList $otherlist, $sequence; + $count = DeleteList($otherlist, $sequence); print br "Removed $sender from ${Userid}'s " . ucfirst $otherlist . ' list' if $count > 0; - ResequenceList $userid, $otherlist; + ResequenceList($userid, $otherlist); } # if - } # foreach + } # for } # if $nextseq++; @@ -87,7 +88,7 @@ sub Add2List { } # Add2List # Main -$userid = Heading ( +$userid = Heading( 'getcookie', '', 'Add to White List', @@ -98,9 +99,9 @@ $userid ||= $ENV{USER}; $Userid = ucfirst $userid; -SetContext $userid; +SetContext($userid); -NavigationBar $userid; +NavigationBar($userid); Add2List; @@ -114,7 +115,7 @@ print '

', hidden ({-name => 'type', -default => $type}), submit ({-name => 'action', - -value => 'Add New Entry'}), + -value => 'Add'}), '
'; Footing;