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;
35 my $type = param 'type';
36 my $file = param 'file';
39 usage => sub { pod2usage },
40 help => sub { pod2usage (-verbose => 2)},
50 open my $file, '<', $opts{file}
51 or die "Unable to open $opts{file} - $!\n";
58 my ($pattern, $comment, $hit_count, $last_hit) = split /,/;
62 if ($type eq 'white') {
63 ($alreadyExists) = OnWhitelist($pattern, $userid);
64 } elsif ($type eq 'black') {
65 ($alreadyExists) = OnBlacklist($pattern, $userid);
66 } elsif ($type eq 'null') {
67 ($alreadyExists) = OnNulllist($pattern, $userid);
70 unless ($alreadyExists) {
71 AddList($type, $pattern, 0, $comment, $hit_count, $last_hit);
75 print br "$pattern is already on your " . ucfirst($type) . 'list';
95 pod2usage "Type not specified" unless $opts{type};
96 pod2usage '-file should be specified' unless $opts{file};
97 pod2usage "Unable to read $opts{file}" unless -r $opts{file};
108 NavigationBar($userid);
110 my $count = importList($opts{type});
113 print br "$count list entry imported";
114 } elsif ($count == 0) {
115 print br 'No entries imported';
117 print br "$count list entries imported";