X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fbin%2Fimportlist.cgi;h=6f4e5f3a56a10980d5c6f4b3ef1cc3b9e09bc55d;hb=16babf81ce331af378de565ba73e927ff5491f65;hp=a8720a7a1f800d2b248ce404871e7c6ec78431a4;hpb=9f51fc95d361092058a17611614f31318a3fad0c;p=clearscm.git diff --git a/maps/bin/importlist.cgi b/maps/bin/importlist.cgi index a8720a7..6f4e5f3 100755 --- a/maps/bin/importlist.cgi +++ b/maps/bin/importlist.cgi @@ -17,7 +17,7 @@ use strict; use FindBin; local $0 = $FindBin::Script; -use lib $FindBin::Bin; +use lib "$FindBin::Bin/../lib"; use Getopt::Long; use Pod::Usage; @@ -28,7 +28,6 @@ use MAPSWeb; use CGI qw/:standard *table/; use CGI::Carp "fatalsToBrowser"; -my $type = param('type'); my $userid = cookie('MAPSUser'); $userid //= $ENV{USER}; my $Userid = ucfirst $userid; @@ -36,6 +35,7 @@ my $Userid = ucfirst $userid; my %opts = ( usage => sub { pod2usage }, help => sub { pod2usage (-verbose => 2)}, + type => param('type'), file => param('file'), ); @@ -57,17 +57,19 @@ sub importList ($) { my $alreadyExists; if ($type eq 'white') { - $alreadyExists = OnWhitelist $pattern, $userid; + ($alreadyExists) = OnWhitelist($pattern, $userid); } elsif ($type eq 'black') { - $alreadyExists = OnBlacklist $pattern, $userid; + ($alreadyExists) = OnBlacklist($pattern, $userid); } elsif ($type eq 'null') { - $alreadyExists = OnNulllist $pattern, $userid; + ($alreadyExists) = OnNulllist($pattern, $userid); } # if unless ($alreadyExists) { - AddList ($type, $pattern, 0, $comment, $hit_count, $last_hit); + AddList($type, $pattern, 0, $comment, $hit_count, $last_hit); $count++; + } else { + print br "$pattern is already on your " . ucfirst($type) . 'list'; } # unless } # while @@ -77,31 +79,32 @@ sub importList ($) { } # importList # Main -GetOptions ( +GetOptions( \%opts, 'usage', 'help', 'verbose', 'debug', 'file=s', + 'type=s', ); -pod2usage "Type not specified" unless $type; +pod2usage "Type not specified" unless $opts{type}; pod2usage '-file should be specified' unless $opts{file}; pod2usage "Unable to read $opts{file}" unless -r $opts{file}; -$userid = Heading ( +$userid = Heading( 'getcookie', '', 'Import List', 'Import List', ); -SetContext $userid; +SetContext($userid); -NavigationBar $userid; +NavigationBar($userid); -my $count = importList $type; +my $count = importList($opts{type}); if ($count == 1) { print br "$count list entry imported";