X-Git-Url: http://git.treefish.org/fex.git/blobdiff_plain/7fa382617fbaccc0ce522b2b3adbbee9db5ad227..20150826:/cgi-bin/rup?ds=sidebyside diff --git a/cgi-bin/rup b/cgi-bin/rup index 10a78b6..5b2d4e0 100755 --- a/cgi-bin/rup +++ b/cgi-bin/rup @@ -5,17 +5,16 @@ # Author: Ulli Horlacher # +BEGIN { ($ENV{PERLINIT}||'') =~ /(.+)/s and eval $1 } + use Fcntl qw(:flock :seek :mode); -use CGI qw(:standard); -use CGI::Carp qw(fatalsToBrowser); -use Fcntl qw(:flock); use Digest::MD5 qw(md5_hex); # add fex lib (our $FEXLIB) = $ENV{FEXLIB} =~ /(.+)/; die "$0: no $FEXLIB\n" unless -d $FEXLIB; -our ($keep_default,$dkeydir,$akeydir,$mdomain,$logdir,$fra); +our ($keep_default,$dkeydir,$akeydir,$mdomain,@logdir,$fra); our $akey = ''; # load common code, local config : $HOME/lib/fex.ph @@ -25,15 +24,15 @@ our $error = 'F*EX redirect ERROR'; chdir $spooldir or die "$spooldir - $!\n"; -my $log = "$logdir/rup.log"; - $from = $id = $oto = $nto = $file = ''; # look for CGI parameters -foreach my $v (param) { - $vv = param($v); +our %PARAM; +&parse_parameters; +foreach my $v (keys %PARAM) { + my $vv = $PARAM{$v}; $vv =~ s/[<>\'\`\"\000-\037]//g; - if ($v =~ /^akey$/i and $vv =~ /^(\w+)$/) { + if ($v =~ /^akey$/i and $vv =~ /^(\w+)$/) { $akey = $1; } elsif ($v =~ /^(from|user)$/i) { $from = normalize_address($vv); @@ -148,7 +147,7 @@ unless ($from and $id and $file and $oto and $nto) { } if ($nto) { - + # read aliases from address book if (open my $AB,'<',"$from/\@ADDRESS_BOOK") { while (<$AB>) { @@ -201,7 +200,7 @@ if (rename "$oto/$from/$fkey","$nto/$from/$fkey") { unlink "$nto/$from/$fkey/notify"; unlink "$nto/$from/$fkey/error"; unlink "$nto/$from/$fkey/download"; - if (slurp("$oto/$from/$fkey/$comment") =~ 'NOMAIL') { + if (slurp("$oto/$from/$fkey/comment")||'' =~ /NOMAIL/) { unlink "$nto/$from/$fkey/comment"; } $dkey = randstring(8); @@ -236,15 +235,18 @@ sub normalize_address { # standard log sub ruplog { my $msg = "@_"; - + $msg =~ s/\n/ /g; $msg =~ s/\s+$//; - - if (open $log,'>>',$log) { - flock $log,LOCK_EX; - seek $log,0,SEEK_END; - printf {$log} "%s [%s_%s] (%s) %s\n", - isodate(time),$$,$ENV{REQUESTCOUNT},$fra,$msg; - close $log; + $msg = sprintf "%s [%s_%s] (%s) %s\n", + isodate(time),$$,$ENV{REQUESTCOUNT},$fra,$msg; + + foreach my $log (@logdir) { + if (open $log,'>>',"$log/rup.log") { + flock $log,LOCK_EX; + seek $log,0,SEEK_END; + printf {$log} $msg; + close $log; + } } }