X-Git-Url: https://git.treefish.org/fex.git/blobdiff_plain/c65ee6f7429eff9a7f58aad7c0aec858ad473092..20160328:/cgi-bin/fup?ds=sidebyside diff --git a/cgi-bin/fup b/cgi-bin/fup index 7d222f9..2a799ac 100755 --- a/cgi-bin/fup +++ b/cgi-bin/fup @@ -58,6 +58,7 @@ my @header; # HTTP entity header my $fileid; # file ID my $captive; my $muser; # main user fur sub or group user +my %specific; # upload specific KEEP and AUTODELETE parameters # load common code, local config: $FEXLIB/fex.ph require "$FEXLIB/fex.pp"; @@ -109,7 +110,8 @@ if ($addto) { my %to; foreach $to (@to) { $to{$to} = 1 } push @to,$addto unless $to{$addto}; - if ($submit and @to == 1) { $addto = '' } + # user has submitted with [select from your address book] ? + # if ($submit and @to == 1) { $addto = '' } } $to = join(',',@to); @@ -631,11 +633,12 @@ if (($from and $id and $rid eq $id or $gkey or $skey) and $command) { foreach my $to (@group?@group:@to) { # my $options = sprintf "(autodelete=%s,keep=%s,locale=%s)", # readlink "$to/\@LOCALE"||$locale||$locale{$to}||$default_locale; - my $options = sprintf "(autodelete=%s,keep=%s,locale=%s,notification=%s)", + # my $options = sprintf "(autodelete=%s,keep=%s,locale=%s,notification=%s)", + my $options = sprintf "(autodelete=%s,keep=%s,locale=%s)", $autodelete{$to}||$autodelete, $keep{$to}||$keep_default, - readlink("$to/\@LOCALE")||$default_locale, - readlink("$to/\@NOTIFICATION")||'full'; + readlink("$to/\@LOCALE")||$locale{$to}||$default_locale; + # readlink("$to/\@NOTIFICATION")||'full'; nvt_print("X-Recipient: $to $options"); } nvt_print(''); @@ -840,6 +843,8 @@ unless ($file) { { present_locales('/fup'); + # print "[$addto] [$submit] [@to]

\n"; + @ab = (""); # select menu from server address book @@ -849,6 +854,7 @@ unless ($file) { if (/(\S+)[=\s]+(\S+@[\w.-]+\S*)/) { $_ = "$1 <$2>"; s/,.*/,.../g; + s/:.*/>/; push @ab,""; } } @@ -948,9 +954,6 @@ unless ($file) { print "Alternate Java client (for files > 2 GB or sending of more than one file)\n"; } print &logout; - if (-x "$FEXHOME/cgi-bin/login") { - print $info_login||$info_1; - } pq(qq( '


' '' @@ -962,8 +965,9 @@ unless ($file) { '

' 'Use a F*EX client if you want to send more than one file or resume an interrupted upload.' '' - '

+ '

' )); + print $info_1; exit; } @@ -1240,7 +1244,7 @@ unless ($file) { # } print "\n"; - print $info_1; + print $info_login||$info_1; if ($debug and $debug>1) { print "


\n
\n";
@@ -1417,11 +1421,12 @@ if ($nostore) {
     my $to = $_;
     $to =~ s/:\w+=.*//; # remove options from address
     my $file = "$to/$from/$fkey";
-    my $options = sprintf "(autodelete=%s,keep=%s,locale=%s,notification=%s)",
+    # my $options = sprintf "(autodelete=%s,keep=%s,locale=%s,notification=%s)",
+    my $options = sprintf "(autodelete=%s,keep=%s,locale=%s)",
       readlink("$file/autodelete")||$autodelete,
       readlink("$file/keep")||readlink("$to/\@KEEP")||$keep_default,
-      readlink("$to/\@LOCALE")||readlink("$file/locale")||$default_locale,
-      readlink("$to/\@NOTIFICATION")||'full';
+      readlink("$to/\@LOCALE")||readlink("$file/locale")||$default_locale;
+      # readlink("$to/\@NOTIFICATION")||'full';
     nvt_print("X-Recipient: $to $options");
     nvt_print("X-Location: $durl/$dkey{$to}/$fkey") unless $restricted;
   }
@@ -1510,7 +1515,13 @@ if ($okey) {
   print "&bwlimit=$bwlimit&autodelete=$autodelete&keep=$keep\">";
   print "send another file\n";
   if ($http_client !~ /fexsend/ and $http_client =~ /Linux/i) {
-    print qq'

Hi Linux-user, try fexsend! ☺

\n'; + print '

Hi Linux-user, try ', + '', + "fexsend! ☺

\n"; + } + if ($http_client !~ /fexit/ and $http_client =~ /Windows/i) { + print '

Hi Windows-user, try fexit! ', + "☺

\n"; } print &logout; } @@ -1558,6 +1569,9 @@ sub parse_request { if ($p eq 'KEEP' and /^\d+$/) { $specific{'keep'} = $keep = $v; } + # if ($p eq 'LOCALE') { + # $specific{'locale'} = $locale = $v; + # } } } } @@ -1677,23 +1691,39 @@ sub parse_request { # collect multiple addresses and check for aliases (not group) if (@to and "@to" !~ /^@[\w-]+$/ - and not ($gkey or $addto or $command =~ /^LIST(RECEIVED)?$/)) - { - + and not ($gkey or $addto or $command =~ /^LIST(RECEIVED)?$/)) { # read address book if ($from and open my $AB,'<',"$from/\@ADDRESS_BOOK") { - my ($alias,$address,$autodelete,$locale,$keep); + my ($alias,$addresses,$autodelete,$locale,$keep); while (<$AB>) { s/#.*//; $_ = lc $_; if (s/^\s*(\S+)[=\s]+(\S+)//) { - ($alias,$address) = ($1,$2); + ($alias,$addresses) = ($1,$2); + # alias specific options? $autodelete = $locale = $keep = ''; $autodelete = $1 if /autodelete=(\w+)/; $locale = $1 if /locale=(\w+)/; $keep = $1 if /keep=(\d+)/; - foreach my $address (split(",",$address)) { - $address .= '@'.$mdomain if $mdomain and $address !~ /@/; + foreach my $address (split(",",$addresses)) { + # alias address specific :options? + if ($address =~ s/(.+?):(.+)/$1/) { + my @options = split(':',$2); + $address = expand($address); + foreach (@options) { + if (/^keep=(\d+)$/i) { + $alias_keep{$alias}{$address} = $1 + } + if (/^autodelete=(yes|no|delay)$/i) { + $alias_autodelete{$alias}{$address} = $1 + } + if (/^locale=(\w+)$/i) { + $alias_locale{$alias}{$address} = $1 + } + } + } else { + $address = expand($address); + } push @{$ab{$alias}},$address; $autodelete{$alias} = $autodelete if $autodelete; $keep{$alias} = $keep if $keep; @@ -1707,46 +1737,86 @@ sub parse_request { # look for recipient's options and eliminate dupes %to = (); foreach my $to (my @loop = @to) { - # address book alias? - if ($to !~ /@/ and $ab{$to}) { - foreach my $address (my @loop = @{$ab{$to}}) { - $address .= '@'.$mdomain if $mdomain and $address !~ /@/; + # address book alias? + if ($to !~ /@/ and ($ab{$to} or $to =~ /(.+?):(.+)/ and $ab{$1})) { + my $alias = $to; + my @options = (); + $alias =~ s/:(.*)// and @options = split(':',$1); + if (@options) { + # alias with :options + $alias =~ s/:.*//; + foreach my $address (my @loop = @{$ab{$alias}}) { + $to{$address} = $address; # ignore dupes + foreach (@options) { + $keep{$address} = $1 if /^keep=(\d+)$/i; + $autodelete{$address} = $1 if /^autodelete=(yes|no|delay)$/i; + $locale{$address} = $1 if /^locale=(\w+)$/i; + } + } + } + foreach my $address (my @loop = @{$ab{$alias}}) { $to{$address} = $address; # ignore dupes - if ($specific{'autodelete'}) { - $autodelete{$address} = $specific{'autodelete'}; - } elsif ($autodelete{$to}) { - $autodelete{$address} = $autodelete{$to}; - } else { - $autodelete{$address} = readlink "$address/\@AUTODELETE" - || $autodelete; + unless ($keep{$address}) { + $keep{$address} = $keep{$alias} if $keep{$alias}; + if ($specific{'keep'}) { + $keep{$address} = $specific{'keep'} + } elsif (my $keep = $alias_keep{$alias}{$address}) { + $keep{$address} = $keep; + } elsif ($keep{$alias}) { + $keep{$address} = $keep{$alias} + } } - if (my $locale = readlink "$address/\@LOCALE") { - $locale{$address} = $locale; - } elsif ($locale{$to}) { - $locale{$address} = $locale{$to}; - } else { - $locale{$address} = $::locale ; + unless ($autodelete{$address}) { + if ($specific{'autodelete'}) { + $autodelete{$address} = $specific{'autodelete'}; + } elsif (my $autodelete = $alias_autodelete{$alias}{$address}) { + $autodelete{$address} = $keep; + } elsif ($autodelete{$alias}) { + $autodelete{$address} = $autodelete{$alias}; + } else { + $autodelete{$address} = readlink "$address/\@AUTODELETE" + || $autodelete; + } } unless ($locale{$address}) { - $locale{$address} = $default_locale || 'english'; + if (my $locale = readlink "$address/\@LOCALE") { + $locale{$address} = $locale; + } elsif ($locale{$alias}) { + $locale{$address} = $locale{$alias}; + } elsif ($locale = $alias_locale{$alias}{$address}) { + $locale{$address} = $locale; + } else { + $locale{$address} = $::locale ; + } + $locale{$address} ||= $default_locale || 'english'; } - if ($specific{'keep'}) { $keep{$address} = $specific{'keep'} } - elsif ($keep{$to}) { $keep{$address} = $keep{$to} } } } else { + # regular address, not an alias + if ($to =~ s/(.+?):(.+)/$1/) { + my @options = split(':',$2); + $to = expand($to); + foreach (@options) { + $keep{$to} = $1 if /^keep=(\d+)$/i; + $autodelete{$to} = $1 if /^autodelete=(yes|no|delay)$/i; + $locale{$to} = $1 if /^locale=(\w+)$/i; + } + } $to = expand($to); $to{$to} = $to; # ignore dupes unless ($autodelete{$to}) { - $autodelete{$to} = readlink "$to/\@AUTODELETE" || $autodelete; + $autodelete{$to} = untaint(readlink("$to/\@AUTODELETE") + ||$autodelete); + if ($specific{'autodelete'}) { + $autodelete{$to} = $specific{'autodelete'}; + } + } + unless ($keep{$to}) { + $keep{$to} = $keep_default; + $keep{$to} = $keep if $keep; + $keep{$to} = untaint(readlink "$to/\@KEEP") if -l "$to/\@KEEP"; + $keep{$to} = $specific{'keep'} if $specific{'keep'}; } - $autodelete{$to} = $specific{'autodelete'} if $specific{'autodelete'}; - $keep{$to} = $keep_default; - $keep{$to} = $keep if $keep; - $keep{$to} = untaint(readlink "$to/\@KEEP") if -l "$to/\@KEEP"; - $keep{$to} = $specific{'keep'} if $specific{'keep'}; - # recipient specific parameters - $keep{$to} = $1 if $to =~ /:keep=(\d+)/i; - $autodelete{$to} = $1 if $to =~ /:autodelete=(\w+)/i; } $autodelete{$to} = 'NO' if $to =~ /$amdl/; # mailing lists, etc if (-e "$to/\@CAPTIVE") { @@ -2435,7 +2505,7 @@ sub forward { } @to = keys %to; - + http_header('200 OK'); print html_header($head); @@ -2614,15 +2684,15 @@ sub setparam { $locale = $1; } elsif ($v eq 'REDIRECT' and $vv =~ /^([\w?=]+)$/) { $redirect = $1; - } elsif (($v eq 'KEY' or $v eq 'SKEY') and $vv =~ /^([\w:]+)$/) { + } elsif ($v eq 'SKEY' and $vv =~ /^([\w:]+)/) { $skey = $1; $restricted = $v; - } elsif ($v eq 'GKEY' and $vv =~ /^([\w:]+)$/) { + } elsif ($v eq 'GKEY' and $vv =~ /^([\w:]+)/) { $gkey = $1 unless $nomail; $restricted = $v; - } elsif ($v eq 'DKEY' and $vv =~ /^(\w+)$/) { + } elsif ($v eq 'DKEY' and $vv =~ /^(\w+)/) { $dkey = $1; - } elsif ($v eq 'AKEY' and $vv =~ /^(\w+)$/) { + } elsif ($v eq 'AKEY' and $vv =~ /^(\w+)/) { $akey = $1; } elsif ($v eq 'FROM' or $v eq 'USER') { $from = normalize_email($vv); @@ -2721,7 +2791,7 @@ sub setparam { $keep = $keep_max if $keep_max and $keep > $keep_max; $specific{'keep'} = $keep; } elsif ($v eq 'TIMEOUT' and $vv =~ /^(\d+)$/) { - $specific{'timeout'} = $timeout = $1; + $specific{'timeout'} = $timeout = $1; } } @@ -2827,6 +2897,11 @@ sub mail_forgotten { # lookup akey, skey and gkey (full and sub user and group) sub check_keys { + if (@to and "@to" ne '_') { + http_die("you cannot mix TO and SKEY URL parameters") if $skey; + http_die("you cannot mix TO and GKEY URL parameters") if $gkey; + } + # only one key can be valid $akey = $gkey = '' if $skey; $akey = $skey = '' if $gkey;