X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=maps%2Fbin%2Fexportlist.cgi;h=70907ba50995cedc8cec3ba5261187b93b4cc4ab;hb=4f37839bc9faacb57d9bce9196d916595f14b114;hp=c6cb30c89ac78708db44529667b7e435e38b3686;hpb=020a4a5ea2be725b155cae3a2cadc9aba3911b9b;p=clearscm.git diff --git a/maps/bin/exportlist.cgi b/maps/bin/exportlist.cgi index c6cb30c..70907ba 100755 --- a/maps/bin/exportlist.cgi +++ b/maps/bin/exportlist.cgi @@ -2,8 +2,8 @@ ################################################################################ # # File: $RCSfile: exportlist.cgi,v $ -# Revision: $Revision: 1.1 $ -# Description: Export an address list +# Revision: $Revision: 1.1 $ +# Description: Export an address list # Author: Andrew@DeFaria.com # Created: Mon Jan 16 20:25:32 PST 2006 # Modified: $Date: 2013/06/12 14:05:47 $ @@ -15,9 +15,10 @@ use strict; use FindBin; -$0 = $FindBin::Script; +local $0 = $FindBin::Script; -use lib $FindBin::Bin; +use lib "$FindBin::Bin/../lib"; +use lib "$FindBin::Bin/../../lib"; use MAPS; use MAPSWeb; @@ -25,17 +26,15 @@ use MAPSWeb; use CGI qw/:standard *table/; use CGI::Carp "fatalsToBrowser"; -my $type = param ("type"); -my $userid = cookie ("MAPSUser"); -my $Userid = ucfirst $userid; +my $type = param('type'); +my $userid = cookie("MAPSUser"); + $userid //= $ENV{USER}; +my $Userid = ucfirst $userid; -sub PrintList { - my $type = shift; +sub PrintList($) { + my ($type) = @_; - my $year = substr ((scalar (localtime)), 20, 4); - - my ($pattern, $domain, $comment, $hit_count, $last_hit); - my $sth = FindList $type; + my $year = substr((scalar(localtime)), 20, 4); print "\################################################################################\n"; print "\#\n"; @@ -47,22 +46,37 @@ sub PrintList { print "\#\n"; print "\################################################################################\n"; - while (($_, $_, $pattern, $domain, $comment, $_, $hit_count, $last_hit) = GetList $sth) { - last if !(defined $pattern or defined $domain); - $pattern = !defined $pattern ? "" : $pattern; - $domain = !defined $domain ? "" : $domain; - if ($domain eq "") { - print "$pattern,$comment,$hit_count,$last_hit\n"; + FindList( + userid => $userid, + type => $type, + ); + + while (my $rec = GetList) { + $rec->{pattern} //= ''; + $rec->{domain} //= ''; + $rec->{comment} //= ''; + $rec->{hit_count} //= 0; + $rec->{last_hit} //= ''; + $rec->{retention} //= ''; + + if ($rec->{domain} eq '') { + print "$rec->{pattern},$rec->{comment},$rec->{hit_count},$rec->{last_hit},$rec->{retention}\n"; } else { - print "$pattern\@$domain,$comment,$hit_count,$last_hit\n"; + print "$rec->{pattern}\@$rec->{domain},$rec->{comment},$rec->{hit_count},$rec->{last_hit},$rec->{retention}\n"; } # if } # while + + return; } # PrintList # Main -SetContext $userid; +SetContext($userid); + +print header( + -type => "application/octet-stream", + -attachment => "$type.list", +); + +PrintList($type); -print header (-type => "application/octet-stream", - -attachment => "$type.list"); -PrintList $type; exit;