1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
#!/usr/bin/perl -wT
# FEX CGI for (user) operation control
#
# Author: Ulli Horlacher <framstag@rus.uni-stuttgart.de>
#
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(
'<script>'
' function show_user() { return(alert('
' "server:\\t$ENV{HTTP_HOST}\\n"+'
' "user:\\t$user\\n"+'
' "auth-ID:\\t$id\\n"+'
' "URL:\\t\\t$url"'
' ));}'
'</script>'
'<h2>for user <a href="#" onclick="show_user();" title="click to see account data">$user</a></h2>'
'<table>'
));
($quota,$du) = check_sender_quota($user);
if ($quota) {
pq(qq(
<tr title="You as the sender have a server disk quota of $quota MB and currently using $du MB">
<td>sender quota (used):<td align=\"right\">$quota ($du) MB
</tr>
));
}
($quota,$du) = check_recipient_quota($user);
if ($quota) {
pq(qq(
<tr title="You as the recipient have a server disk quota of $quota MB and currently using $du MB">
<td>recipient quota (used):<td align=\"right\">$quota ($du) MB
</tr>
));
}
pq(qq(
'</table>'
'<p><hr><p>'
'<a href="/fup?akey=$akey&command=LISTRECEIVED">'
'Retrieve a list of all your received files</a> in F*EX spool.'
));
pq(qq(
'<p><hr><p>'
'<form action="/fuc?akey=$akey"'
' method="post"'
' accept-charset="UTF-8"'
' enctype="multipart/form-data">'
' <input type="hidden" name="user" value="$user">'
' <input type="hidden" name="id" value="$id">'
' <script>function show_id() {return(alert("auth-ID: $id"));}</script>'
' Change your <a href="#" onclick="show_id();" title="$id">auth-ID</a> to'
' <input type="text" name="nid" size="16">'
' <input type="submit" value="remember it!">'
));
if (-s "$user/\@ALLOWED_RECIPIENTS") {
# pq(qq(
# ' (You are a restricted user)';
# ' <p>'
# ));
# '<p><hr><p>'
# '<a href="/fup?akey=$akey&command=LISTSENT">'
# 'Show download URLs of files you have sent</a>.'
unless ($nomail) {
pq(qq(
'<p><hr><p>'
'<a href="/fup?akey=$akey&command=RENOTIFY">'
'Resend notification e-mails for files you have sent</a>.'
));
}
} else {
pq(qq(
'<p><hr><p>'
'<a href="/fup?akey=$akey&command=LIST&to=*">'
'Forward a copy of a file</a> you already have uploaded to another recipient.'
'<p><hr><p>'
'<a href="/rup?akey=$akey">'
'Redirect files</a> you have uploaded to a wrong or misspelled recipient.'
));
unless ($nomail) {
pq(qq(
'<p><hr><p>'
'<a href="/fup?akey=$akey&command=RENOTIFY">'
'Resend notification e-mails for files you have sent</a>.'
));
}
pq(qq(
'<p><hr><p>'
' Create a subuser who can send you files. Enter his e-mail address:<br>'
' <input type="text" name="subuser" size="60">'
' <input type="checkbox" name="otuser" value="once">for only one upload<br>'
));
if ($nomail) {
pq(qq(
' <input type="submit" value="create subuser">'
));
} else {
pq(qq(
' Comment to send with information e-mail:<br>'
' <input type="text" name="comment" size="80"><br>'
' <input type="submit" value="create subuser and send e-mail">'
));
}
pq(qq(
' <p><hr><p>'
' <a href="/fuc?akey=$akey">Manage your subusers and groups</a>'
' <p><hr><p>'
' <a href="/fuc?ab=load&akey=$akey">Edit your address book</a>'
));
pq(qq(
' <p><hr><p>'
' <a href="/fuc?disclaimer=CHANGE&akey=$akey">'
' Change the disclaimer</a> to be sent with notification e-mail.'
));
}
pq(qq(
' <p><hr><p>'
' <a href="/fuc?encryption=CHANGE&akey=$akey">'
' (De)activate e-mail encryption</a>.'
)) if -s "$ENV{HOME}/.gnupg/pubring.gpg";
if ((readlink "$user/\@NOTIFICATION"||'') =~ /short/i) {
pq(qq(
' <p><hr><p>'
' Get <a href="/fuc?notification=detailed&akey=$akey">detailed</a> notification e-mails (current setting: <em>brief</em>).'
));
} else {
pq(qq(
' <p><hr><p>'
' Get <a href="/fuc?notification=short&akey=$akey">brief</a> notification e-mails (current setting: <em>detailed</em>).'
));
}
if ((readlink "$user/\@REMINDER"||'') =~ /no/i) {
pq(qq(
' <p><hr><p>'
' Get <a href="/fuc?reminder=yes&akey=$akey">reminder</a> notification e-mails (current setting: <em>no reminders</em>).'
));
} else {
pq(qq(
' <p><hr><p>'
' Get <a href="/fuc?reminder=no&akey=$akey">no reminder</a> notification e-mails (current setting: <em>send reminders</em>).'
));
}
if (-e "$user/\@MIME") {
pq(qq(
' <p><hr><p>'
' <a href="/fuc?mime=no&akey=$akey">Save</a> files after download (current setting: <em>display</em>).'
));
} else {
pq(qq(
' <p><hr><p>'
' <a href="/fuc?mime=yes&akey=$akey">Display</a> files when downloading with web browser (current setting: <em>save</em>).'
));
}
pq(qq(
' <p><hr><p>'
' <a href="/fup?akey=$akey">Back to fup (upload page)</a>'
'</form>'
));
print &logout;
print "</body></html>\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;
|