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/../lib";
28 use CGI qw/:standard *table/;
29 use CGI::Carp "fatalsToBrowser";
31 my $userid = cookie('MAPSUser');
32 $userid //= $ENV{USER};
33 my $Userid = ucfirst $userid;
36 usage => sub { pod2usage },
37 help => sub { pod2usage (-verbose => 2)},
38 type => param('type'),
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);
72 print br "$pattern is already on your " . ucfirst($type) . 'list';
92 pod2usage "Type not specified" unless $opts{type};
93 pod2usage '-file should be specified' unless $opts{file};
94 pod2usage "Unable to read $opts{file}" unless -r $opts{file};
105 NavigationBar($userid);
107 my $count = importList($opts{type});
110 print br "$count list entry imported";
111 } elsif ($count == 0) {
112 print br 'No entries imported';
114 print br "$count list entries imported";