--- loncom/lonnet/perl/lonuploadrep.pm 2005/04/07 06:56:24 1.7 +++ loncom/lonnet/perl/lonuploadrep.pm 2007/10/02 01:09:53 1.10 @@ -28,12 +28,13 @@ package Apache::lonuploadrep; use strict; use Apache::Constants qw(:common :http); +use Apache::lonrep(); use Apache::lonnet; -use CGI::Cookie(); +use LONCAPA(); sub handler { my $r = shift; - if ($r->uri =~m|^/*uploaded/(\w+)/(\w+)/(.+)$|) { + if ($r->uri =~m{^/*uploaded/($LONCAPA::domain_re)/($LONCAPA::name_re)/(.+)$}) { my $chome=&Apache::lonnet::homeserver($2,$1); my @ids=&Apache::lonnet::current_machine_ids(); foreach my $id (@ids) { if ($id eq $chome) { return OK; } } @@ -46,21 +47,20 @@ sub handler { } elsif ( ($info > 0) && ($info =~ /\d+/) ) { my @statinfo = stat($filename); if ($statinfo[9] >= $info ) { - $r->filename($filename); + &Apache::lonrep::update_filename($r,$filename); return OK; } } } my $response=&Apache::lonnet::repcopy_userfile($r->uri); if ($response eq 'ok') { - $r->filename($filename); + &Apache::lonrep::update_filename($r,$filename); return OK; } } - my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); - my $lonid=$cookies{'lonID'}; - if ($lonid) { - $r->log_reason('Copying failed in lonuploadrep for '.$lonid->value); + my $handle = &Apache::lonnet::check_for_valid_session($r); + if ($handle) { + $r->log_reason('Copying failed in lonuploadrep for '.$handle); return HTTP_NOT_FOUND; } else { $r->log_reason('Copying failed in lonuploadrep for unknown user');