2 ################################################################################
4 # File: $RCSfile: importlist.cgi,v $
5 # Revision: $Revision: 1.1 $
6 # Description: Export an address list
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 ################################################################################
18 local $0 = $FindBin::Script;
20 use lib $FindBin::Bin;
28 use CGI qw/:standard *table/;
29 use CGI::Carp "fatalsToBrowser";
31 my $type = param('type');
32 my $userid = cookie('MAPSUser');
33 $userid //= $ENV{USER};
34 my $Userid = ucfirst $userid;
37 usage => sub { pod2usage },
38 help => sub { pod2usage (-verbose => 2)},
39 file => param('file'),
47 open my $file, '<', $opts{file}
48 or die "Unable to open $opts{file} - $!\n";
55 my ($pattern, $comment, $hit_count, $last_hit) = split /,/;
59 if ($type eq 'white') {
60 $alreadyExists = OnWhitelist $pattern, $userid;
61 } elsif ($type eq 'black') {
62 $alreadyExists = OnBlacklist $pattern, $userid;
63 } elsif ($type eq 'null') {
64 $alreadyExists = OnNulllist $pattern, $userid;
67 unless ($alreadyExists) {
68 AddList ($type, $pattern, 0, $comment, $hit_count, $last_hit);
89 pod2usage "Type not specified" unless $type;
90 pod2usage '-file should be specified' unless $opts{file};
91 pod2usage "Unable to read $opts{file}" unless -r $opts{file};
102 NavigationBar $userid;
104 my $count = importList $type;
107 print br "$count list entry imported";
108 } elsif ($count == 0) {
109 print br 'No entries imported';
111 print br "$count list entries imported";