X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fbin%2Fimportlist.cgi;h=495da1508c88e3ddfc9ab35238723b0a9175adbf;hb=a77e38390a688e1d0a3709d21f42ac5c51a436db;hp=a8720a7a1f800d2b248ce404871e7c6ec78431a4;hpb=92a317c3620f3442f9452d834a1ed5f09bdddbf6;p=clearscm.git diff --git a/maps/bin/importlist.cgi b/maps/bin/importlist.cgi index a8720a7..495da15 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,15 +28,18 @@ 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; +my $type = param 'type'; +my $file = param 'file'; + my %opts = ( usage => sub { pod2usage }, help => sub { pod2usage (-verbose => 2)}, - file => param('file'), + type => $type, + file => $file, ); sub importList ($) { @@ -57,17 +60,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 +82,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";