#!/usr/bin/perl -wT # FEX CGI for (user) operation control # # Author: Ulli Horlacher # BEGIN { ($ENV{PERLINIT}||'') =~ /(.+)/s and eval $1 } use utf8; use Fcntl qw(:flock); use Digest::MD5 qw(md5_hex); # add fex lib ($FEXLIB) = $ENV{FEXLIB} =~ /(.+)/; die "$0: no $FEXLIB\n" unless -d $FEXLIB; our ($FEXHOME,$mdomain,$nomail,$faillog); our $akey = ''; # load common code, local config : $HOME/lib/fex.ph require "$FEXLIB/fex.pp" or die "$0: cannot load $FEXLIB/fex.pp - $!\n"; my $error = 'F*EX operation control ERROR'; chdir $spooldir or die "$spooldir - $!\n"; $akeydir = "$spooldir/.akeys"; $user = $id = ''; # look for CGI parameters our %PARAM; &parse_parameters; foreach my $v (keys %PARAM) { my $vv = $PARAM{$v}; # debuglog("Param: $v=\"$vv\""); if ($v =~ /^akey$/i and $vv =~ /^(\w+)$/) { $akey = $1; } elsif ($v =~ /^(from|user)$/i) { $user = normalize_email($vv); $user .= '@'.$mdomain if $mdomain and $user !~ /@/; } elsif ($v =~ /^id$/i) { $id = checkchars($vv); } } if ($akey and not $user and not $id) { if (open $akey,'<',"$akeydir/$akey/@" and $id = getline($akey)) { close $akey; $user = readlink "$akeydir/$akey" or http_die("internal server error: no $akey symlink"); $user =~ s:.*/::; $user = untaint($user); if ($akey ne md5_hex("$user:$id")) { $user = $id = ''; } } } $head = "$ENV{SERVER_NAME} F*EX operation control"; # display HTML form and request user data if ($user and $id) { my $idf; unless (open $idf,'<',"$user/@") { faillog("user $from, id $id"); html_error($error,"wrong user or auth-ID"); } &check_status($user); if (-e "$user/\@CAPTIVE") { html_error($error,"captive user") } $rid = getline($idf); close $idf; if ($id eq $rid) { unless ($akey) { $akey = untaint(md5_hex("$user:$id")); unlink "$akeydir/$akey"; symlink "../$user","$akeydir/$akey"; } } else { faillog("user $from, id $id"); html_error($error,"wrong user or auth-ID"); } unlink $faillog if $faillog; http_header("200 OK"); print html_header($head); # authorized login URL my $url = "$ENV{PROTO}://$ENV{HTTP_HOST}/fup/".b64("from=$user&id=$id"); pq(qq( '' '

for user $user

' '' )); ($quota,$du) = check_sender_quota($user); if ($quota) { pq(qq( )); } ($quota,$du) = check_recipient_quota($user); if ($quota) { pq(qq( )); } pq(qq( '
sender quota (used):$quota ($du) MB
recipient quota (used):$quota ($du) MB
' '


' '' 'Retrieve a list of all your received files in F*EX spool.' )); pq(qq( '


' '

' ' ' ' ' ' ' ' Change your auth-ID to' ' ' ' ' )); if (-s "$user/\@ALLOWED_RECIPIENTS") { # pq(qq( # ' (You are a restricted user)'; # '

' # )); # '


' # '' # 'Show download URLs of files you have sent.' unless ($nomail) { pq(qq( '


' '' 'Resend notification e-mails for files you have sent.' )); } } else { pq(qq( '


' '' 'Forward a copy of a file you already have uploaded to another recipient.' '


' '' 'Redirect files you have uploaded to a wrong or misspelled recipient.' )); unless ($nomail) { pq(qq( '


' '' 'Resend notification e-mails for files you have sent.' )); } pq(qq( '


' ' Create a subuser who can send you files. Enter his e-mail address:
' ' ' ' for only one upload
' )); if ($nomail) { pq(qq( ' ' )); } else { pq(qq( ' Comment to send with information e-mail:
' '
' ' ' )); } pq(qq( '


' ' Manage your subusers and groups' '


' ' Edit your address book' )); pq(qq( '


' ' ' ' Change the disclaimer to be sent with notification e-mail.' )); } pq(qq( '


' ' ' ' (De)activate e-mail encryption.' )) if -s "$ENV{HOME}/.gnupg/pubring.gpg"; if ((readlink "$user/\@NOTIFICATION"||'') =~ /short/i) { pq(qq( '


' ' Get detailed notification e-mails (current setting: brief).' )); } else { pq(qq( '


' ' Get brief notification e-mails (current setting: detailed).' )); } if ((readlink "$user/\@REMINDER"||'') =~ /no/i) { pq(qq( '


' ' Get reminder notification e-mails (current setting: no reminders).' )); } else { pq(qq( '


' ' Get no reminder notification e-mails (current setting: send reminders).' )); } if (-e "$user/\@MIME") { pq(qq( '


' ' Save files after download (current setting: display).' )); } else { pq(qq( '


' ' Display files when downloading with web browser (current setting: save).' )); } pq(qq( '


' ' Back to fup (upload page)' '

' )); print &logout; print "\n"; exit; } my $login = -x "$FEXHOME/login" ? 'login' : 'fup'; nvt_print( "HTTP/1.1 302 Found", "Location: $ENV{PROTO}://$ENV{HTTP_HOST}/$login", 'Expires: 0', 'Content-Length: 0', '' ); &reexec;