--- loncom/auth/restrictedaccess.pm 2006/07/21 18:52:32 1.4 +++ loncom/auth/restrictedaccess.pm 2006/07/21 19:42:12 1.5 @@ -45,32 +45,41 @@ sub handler { if (!defined($origurl)) { $origurl = $r->uri; } + my $msg=''; if (exists($env{'form.pass1'})) { my ($result,$end) = &check_pass($r,$origurl); if ($result eq 'ok') { - &Apache::lonnet::appenv(('user.passphrase_access_'.$origurl => - $end)); + &Apache::lonnet::allowuploaded('/adm/restrictedaccess', + $origurl); $env{'request.state'} = "published"; $env{'request.filename'} = $origurl; $r->header_out(Location => 'http://'.$ENV{'HTTP_HOST'}.$origurl); return REDIRECT; } else { - &print_entryform($r,$origurl,"Invalid passphrase"); - } - } else { - &print_entryform($r,$origurl); + $msg = 'Invalid passphrase'; + } } - return OK; -} -sub print_entryform { - my ($r,$origurl,$msg) = @_; - &Apache::lonlocal::get_language_handle($r); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; $r->print(&Apache::loncommon::start_page('Passphrase protected file')); + &print_entryform($r,$origurl,$msg); + + return OK; +} + +sub setup_handler { + my ($r) = @_; + $r->set_handlers('PerlHandler'=> + \&Apache::restrictedaccess::handler); + $r->content_type('perl-script'); +} + +sub print_entryform { + my ($r,$origurl,$msg) = @_; + $r->print(''); - $r->print(''.$msg.''); + if ($msg ne '') { + $r->print(''.$msg.''); + } $r->print('
'); $r->print('


'); $r->print(&Apache::loncommon::start_data_table()); $r->print(&Apache::loncommon::start_data_table_row()); $r->print(''.&mt('Passphrase: ').''. - ''); + ''); $r->print(&Apache::loncommon::end_data_table_row()); $r->print(&Apache::loncommon::start_data_table_row()); $r->print('
'.